Reputation: 2080
I know I can run playbooks and tasks with sudo, but is there a way to run sudo with arguments? Specifically, I need to run sudo -E <command>
to preserve the environment of the logged-in user.
If this is not possible, are there good workarounds?
Edit
Two clarifications:
sudo -E
just for some tasks, not the whole playbookubuntu
user has some hosts configured under ~/.ssh/config
. I'd like to use those settings with the ansible git module without necessarily copying them into /root/.ssh
, and I'd like to use them to modify a directory not owned by the ubuntu
user. For pulling, for instance, one way to do this directly in the shell is to sudo -E git pull
. An ideal solution would let me (1) use the ansible git module, (2) allow me to sudo -E
for this task, and to sudo
without the -E
flag for other tasks.Upvotes: 5
Views: 2658
Reputation: 20759
You should be able to do this via the sudo_flags parameter in ansible.cfg
Upvotes: 2