Ansible helps automating repetitive tasks in a reliable manner across *nix operating systems. Ansible’s few advantages are

  • YAML formatted, easily readable script (more like intent statements)
  • Tasks are executed in order
  • Agentless deployment
  • Uses SSH (available in all platforms)

After installing Ansible

Edit (or create) /etc/ansible/hosts and put one or more remote systems in it

192.168.2.1
aserver.example.org
bserver.example.org

Now ping all your nodes:

 $ ansible all -m ping
 # as bruce
 $ ansible all -m ping -u username
 # as bruce, sudoing to root
 $ ansible all -m ping -u username --sudo

More detailed tasks are accomplished via playbook. playbook.yml contents below

---
- hosts: webservers
  vars:
    http_port: 80
    max_clients: 200
  remote_user: root
  tasks:
  - name: ensure apache is at the latest version
    yum:
      name: httpd
      state: latest
  - name: write the apache config file
    template:
      src: /srv/httpd.j2
      dest: /etc/httpd.conf
    notify:
    - restart apache
  - name: ensure apache is running
    service:
      name: httpd
      state: started
  handlers:
    - name: restart apache
      service:
        name: httpd
        state: restarted

Run a playbook using a parallelism level of 10:

ansible-playbook playbook.yml -f 10