Ansible ssh as user and execute has root (expect like)
Solution 1:
With ansible
, you can use sudo
or su
:
- hosts: example.com
gather_facts: False
su: yes
su_user: root
tasks:
- shell: whoami
You could also do that from the command line:
ansible-playbook --su --su-user=root --ask-su-pass playbook.yml
This functionality has been available since this pull request, and is present in current 1.6.6.