Difference between revisions of "Ansible One-liners"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
## Linux & Windows | ## Linux & Windows | ||
+ | |||
+ | use -e @vars/myfile.yaml for getting vars from file | ||
``` | ``` |
Latest revision as of 20:47, 29 November 2022
Linux & Windows
use -e @vars/myfile.yaml for getting vars from file
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
Other
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