User Tools

Site Tools


ansible:ansible_cmd

This is an old revision of the document!


Ansible command examples

cmd

ansible all -m ping 
ansible foo.example.com -m yum -a "name=httpd state=installed"
ansible -i hosts all -m yum -a 'name=ncdu state=present'
ansible -i hosts all -m yum -a 'name=ncdu state=absent'
ansible foo.example.com -a "/usr/sbin/reboot"

Only way to pass a command on target without python installed

# ansible myhost --become -m raw -a "yum -y install python"
ansible-inventory --list
ansible-inventory -i ./sample.yml --graph
ansible-config dump --only-changed
ansible -m module_name -a attributes
ansible-config dump
ansible-config list
ansible-config view
# ansible all -m ping --one-line
lnx80 | SUCCESS => {"changed": false,"ping": "pong"}
lnx81 | SUCCESS => {"changed": false,"ping": "pong"}
aix01 | SUCCESS => {"changed": false,"ping": "pong"}
aix20 | SUCCESS => {"changed": false,"ping": "pong"}

playbook

ansible/ansible_cmd.1631615543.txt.gz · Last modified: 2021/09/14 12:32 by manu