Skip to content

Instantly share code, notes, and snippets.

@revolunet
Created July 27, 2015 08:11
Show Gist options
  • Save revolunet/861775b516970267bbb0 to your computer and use it in GitHub Desktop.
Save revolunet/861775b516970267bbb0 to your computer and use it in GitHub Desktop.
Ansible memo

ANSIBLE MEMO

Cheatsheet

http://wall-skills.com/2014/ansible-cheat-sheet/

Reboot a server and wait for it to come back

https://support.ansible.com/hc/en-us/articles/201958037-Reboot-a-server-and-wait-for-it-to-come-back

discovered variables about a system

ansible all -i ./hosts -m setup

dry-run

use the --check option

Check target devices

use the --list-hosts option

Check tasks

ansible-playbook -i production webservers.yml --tags ntp --list-tasks

Ensure a package is installed, but don’t update it:

ansible webservers -m yum -a "name=acme state=present"

Copy files

ansible atlanta -m copy -a "src=/etc/hosts dest=/tmp/hosts"

Ensure a service is started

ansible webservers -m service -a "name=httpd state=started"

Adhoc commands

ansible boston -i production -m command -a '/sbin/reboot'

Generate crypted password

mkpasswd --method=SHA-512

Tags

ansible-playbook example.yml --tags "configuration,packages"

ansible-playbook example.yml --skip-tags "notification"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment