romach
4/14/2017 - 5:02 PM

Ad-hoc commands

Ad-hoc commands

# ping servers
ansible all -i inventory.ini -u root -m ping
        │      │                │       └───── module
        │      │                └───────────── user
        │      └────────────────────────────── configuration file
        └───────────────────────────────────── server name (all - for all)
        
# run command on remote server
ansible all -i inventory.ini -u root -m command -a 'uptime'
# use command module by default
ansible all -i inventory.ini -u root -a 'uptime'
# run command on host
ansible all --limit my_host -i inventory.ini -u root -a 'uptime'