Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement <remote_user> and <become> directives in python mode? #1378

Open
MaxDXDX opened this issue Jun 29, 2024 · 1 comment
Open

Comments

@MaxDXDX
Copy link

MaxDXDX commented Jun 29, 2024

I'm using runner in my python project as a python module (not via command line tool). And I do not use playbook files. I pass required parameters of tasks by module and module_args arguments of ansible_runner.run function.
So far so good.
But i got stuck then I needed to run tasks as root user. I connect to host under user with sudo rights, but i do not understand how to execute operations under sudo mode.
I used remote_user=root become=true earlier in my playbooks files (then i used ansible in CLI mode). How implement that pattern in ansible-runner?

@github-actions github-actions bot added the needs_triage New item that needs to be triaged label Jun 29, 2024
@Shrews
Copy link
Contributor

Shrews commented Jul 9, 2024

See the comments under issue #1082.

Basically, you need to use the cmdline keyword argument available in the ansible_runner.run() method to pass along options to do privilege escalation (example: cmdline="-K -b"). For the password prompt handling, you'll have to utilize the env/passwords file in the private data directory (see https://ansible.readthedocs.io/projects/runner/en/stable/intro/#env-passwords).

@Shrews Shrews removed the needs_triage New item that needs to be triaged label Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants