andrei bio photo

andrei

Linux engineer, devops enthusiast

Email Github

Ansible quickreference

Note: ansible.cfg will be read in order from the following locations: ANSIBLE_CONFIG env variable, current dir, home_dir/.ansible.cfg, /etc/ansible/ansible.cfg

</tr> </tr> </tr> </tr> </tr> </tr> </tr> </tr> </tr> </tr> </tr> </tr> </tbody> </table>
CommandDescription
ansible -s -K -m command -a "/sbin/shutdown -t now"</td>Shutdown vms
ansible-doc -l List available modules
ansible all --list-hostsList all hosts defied in your inventory
ansible -m ping groupRun ping against all vms in group defined in hosts file
ansible -m ping -i ./hosts</td>Overwrite hostsfile
ansible all -m ping Run ping on all hosts in the inventory
ansible -m setup allRun setup module againsta all hosts defined in hosts file
ansible -m setup -a "filter=*address*"</td>Show all details containint address
ansible -m setup -a "filter=ansible_dist*"</td>Show distribution
ansible local -s -K -m setup --tree /tmp/factsSave json in a file
ansible -m setup -a 'filter=*ipv4*' </td>Get ip addresses
ansible -m file -a "path=/etc/fstab"</td>Show information of the file
ansible -s -K -m file -a "path=/tmp/etc state=directory mode=0700 owner=root"</td>Create a new folder. -s run as sudo, -K ask sudo pass
ansible -s -K -m copy -a "src=/etc/fstab dest=/tmp/etc/fstab"</td>Copy a file
ansible -s -K -m yum -a 'pkg=links state=installed update_cache=true'</td>Install package
ansible -s -K -m shell -a 'yum list installed|grep python' </td>Run shell command
ansible -s -K -m command -a "/sbin/shutdown -t now"</td>Shutdown vms
ansible -m command -a "/etc/init.d/tomcat7 status" --ask-pass</td>Get status of process on group of servers