Difference between revisions of "Ansible One-liners"

From UVOO Tech Wiki
Jump to navigation Jump to search
Line 3: Line 3:
  
 
ansible all --inventory host.example.com, --module-name=shell --args='whoami' -e ansible_password=$ANSIBLE_PASSWORD -e ansible_user=$ANSIBLE_USER
 
ansible all --inventory host.example.com, --module-name=shell --args='whoami' -e ansible_password=$ANSIBLE_PASSWORD -e ansible_user=$ANSIBLE_USER
 +
```
 +
 +
# SUDO
 +
```
 +
ansible all --inventory host.example.com, --module-name=shell --args='sudo whoami' -e ansible_password=$ANSIBLE_PASSWORD -e ansible_user=$ANSIBLE_USER  --become -e ansible_become_password=$ANSIBLE_PASSWORD
 
```
 
```
  

Revision as of 16:58, 11 June 2022

ansible all --inventory host.example.com, --module-name=win_shell --args='whoami' -e ansible_password=$ANSIBLE_PASSWORD -e ansible_user=$ANSIBLE_USER -e ansible_winrm_transport=ntlm -e ansible_connection=winrm

ansible all --inventory host.example.com, --module-name=shell --args='whoami' -e ansible_password=$ANSIBLE_PASSWORD -e ansible_user=$ANSIBLE_USER

SUDO

ansible all --inventory host.example.com, --module-name=shell --args='sudo whoami' -e ansible_password=$ANSIBLE_PASSWORD -e ansible_user=$ANSIBLE_USER  --become -e ansible_become_password=$ANSIBLE_PASSWORD
ansible 'Windows' -m win_shell -i inventory.txt -a 'cp C:\tmp\a.txt C:\tmp\b.txt'

ansible 'Windows' -m copy -a "src=/tmp/foo.txt dest=/tmp/foo.txt" -i inventory.txt  # https://www.middlewareinventory.com/blog/ansible-copy-file-or-directory-local-to-remote/

Testing only - not recommended

export ANSIBLE_HOST_KEY_CHECKING=False