AD HOC Command - shekharshamra/ansible-playbooks GitHub Wiki
-
Check connectivity between servers.
ansible webserver -m ping
-
Copy file from source to destination
ansible webserver -m copy -a "src=/etc/hosts dest=/tmp/hosts"
ansible webserver -m copy -a "src=/etc/hosts dest=/tmp/hosts"
ansible webserver -m file -a "dest=/tmp/shekhar.txt mode=600 owner=shekhar group=shekhar"
-
Reboot server
ansible -a "/sbin/reboot" -f 10
-
Managing Packages A. Installing Package
ansible <HostGroup> -m yum -a "name=httpd state=present"
B. Ensure latest package is installed
ansible <HostGroup> -m yum -a "name=acme state=latest"
C. Uninstall/Remove Package
ansible <HostGroup> -m yum -a "name=acme state=absent"
-
Managing Services:
A. Start Service
Ansible webservers -m service -a "name=httpd state=started"
B. Restart service
ansible webservers -m service -a "name=httpd state=restarted"
C. Stop Service:
ansible webservers -m service -a "name=httpd state=stopped"
-
Add User:
ansible all -m user -a "name=foo password=<crypted password here>" ansible all -m user -a "name=foo state=absent"