Unify usage of sudo() and ansible(..., become=true, become_user="...")
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
調査の方向性
Start by tracing the sudo() context manager and the direct ansible module invocation shown in the example, then compare how explicit become and become_user arguments are handled. Done means an ansible module called inside sudo(user="root") runs as root without explicit become arguments, while the existing explicit-become behavior remains unchanged; verify this with the supplied example.
索引モデルが issue の本文から書いたものです。
説明
It's possible to elevate privileges with sudo() in a context manager. This works fine.
Unfortunately, the privilege elevation does not affect the direct invocation of Ansible modules. That means Ansible modules must get elevated privileges with become=True, become_user="root" additionally even if sudo permissions are already set.
Please extend Testinfra to automatically use the elevated privileges from the sudo context manager when calling Ansible modules.
Example:
def test_sudo(host):
with open("result.txt", "w") as f:
whoami_wo_sudo = ansiblehost.check_output("id")
shell_wo_sudo = ansiblehost.ansible("shell id", check=False)
with ansiblehost.sudo(user="root"):
whoami_w_sudo = ansiblehost.check_output("id")
shell_w_sudo = ansiblehost.ansible("shell id", check=False)
shell_w_become = ansiblehost.ansible("shell id", check=False, become=True, become_user="root")
print(f"""\
Test results
============
without sudo:
OS cmd "whoami": {whoami_wo_sudo}
Ansible module "shell": {shell_wo_sudo["stdout"]}
with sudo:
OS cmd "whoami": {whoami_w_sudo}
with sudo & without become:
Ansible module "shell": {shell_w_sudo["stdout"]}
with sudo & with become:
Ansible module "shell": {shell_w_become["stdout"]}
""", file=f)
# cat result.txt
Test results
============
without sudo:
OS cmd "whoami": uid=999(ansible) gid=999(ansible) groups=999(ansible)
Ansible module "shell": uid=999(ansible) gid=999(ansible) groups=999(ansible)
with sudo:
OS cmd "whoami": uid=0(root) gid=0(root) groups=0(root)
with sudo & without become:
Ansible module "shell": uid=999(ansible) gid=999(ansible) groups=999(ansible)
with sudo & with become:
Ansible module "shell": uid=0(root) gid=0(root) groups=0(root)
- 主要言語
- Python
- スター
- 2.5k
- フォーク
- 359
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pytest-dev/pytest-testinfra のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 58/100
pytest-dev/pytest-testinfra#815 ·
-
service is_enabled does not work with exit code 4対応中かも @pfuntner が 574 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
pytest-dev/pytest-testinfra#801 · コメント 1 件 ·
-
Chroot backendオープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
pytest-dev/pytest-testinfra#789 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
pytest-dev/pytest-testinfra#788 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
pytest-dev/pytest-testinfra#786 ·
pytest-dev/pytest-testinfra の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microsoft/agent-lightning#661 ·
メンテナーはふだん 2 日以内に返信
-
area/profiles comp/cli P3 type/feature
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
NousResearch/hermes-agent#146372 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] OpenAI-compatible embedding model alias breaks embedder construction対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
[oblt-aw][autodoc] Document obs-aw-automerge contract and fix automerge doc inconsistencies対応中かも @github-actions が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
GeoSeries scale and skew tests fail with pytest 9.2.0対応中かも @jiayuasu が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信