Ansible: fictional machine capable of instantaneous or superluminal communication.
$sudo apt-add-repository ppa:ansible/ansible$sudo apt-get update$sudo apt-get install ansible$sudo yum install ansible$sudo easy_install pip$sudo pip install ansiblemail.example.com
[webservers]
foo.example.com
bar.example.com
/etc/ansible/hosts$ssh-keygen~/.ssh/id_rsa.pub) into remote ~/.ssh/authorized_keys file$ansible all -m ping$ansible all -m ping -u root -k$ansible all -m ping -K$ansible all -m ping -f 10$ansible all -m command -a "ls"$ansible all -m command -a "df -h"$ansible all -m shell -a "ls"$ansible all -m shell -a "ls | grep txt"$ansible all -m shell -a "apt-get update"$ansible all -m ping$ansible all -m setup$ansible all -m hostname -a "name=web01"$ansible all -m service -a "name=nginx state=started"$ansible all -m user -a "name=jsmith generate_ssh_key=yes ssh_key_bits=2048 ssh_key_file=.ssh/id_rsa"$ansible all -m copy -a "src=/srv/myfiles/foo.conf dest=/etc/foo.conf"$ansible all -m find -a "paths=/tmp patterns=*.old"$ansible all -m stat -a "path=/path/to/something checksum_algorithm=sha256"$ansible all -m git -a "repo=git://git@github.com/mylogin/hello.git dest=/home/mylogin/hello"$ansible all -m git -a "repo=git://foosball.example.org/path/to/repo.git dest=/srv/checkout clone=no update=no"$ansible all -m apt -a "name=htop update_cache=yes"$ansible all -m apt -a "name=htop state=latest"$ansible all -m apt -a "name=htop state=absent"$ansible all -m apt -a "upgrade=dist"Basic Playbook nginx.yml example:
---
- hosts: local
tasks:
- name: Install Nginx
apt: pkg=nginx state=installed update_cache=true
To run Playbook : $ansible-playbook -b nginx.yml
---
- hosts: local
tasks:
- name: Install Nginx
apt: pkg=nginx state=installed update_cache=true
notify:
- Start Nginx
handlers:
- name: Start Nginx
service: name=nginx state=started