I've been wanting to use Chef or Puppet for a long time, but as a developer I've never had the time to automate my machines setup.
Chef and Puppet are well known solutions for a data center, used by sysadmins to deploy and sync on their machines. Here you'll only find a very simple Ansible example.
Context
I needed a tool to automate the recovery of my raspberry's machines in case of a natural disaster!
Before I was saving all my network, firewall, database, ... configuration files on a Git repository.
What I need now is a simple way of applying them to a running fresh system. That's were Ansible comes in...
Basics
The way Ansible works can be described in the following:
If you have SSH access to the machine, you can use Ansible.
The most basic ansible includes a playbook.yml
where all the instructions are, and an inventory
file that describes all the machines and variables.
ansible-playbook playbook.yml -i hosts -k
playbook.yml
---
- hosts: local
tasks:
- name: run command
command: touch {{ tmp_dir }}/example_playbook.txt
hosts
[local]
localhost
[local:vars]
tmp_dir=/tmp
Ansible playbook's API provides you canned methods for apt-get
, copying files, gem install
...
More complex examples can be found at my examples-ansible repo. You'll find a simple ansible role there!
Simple isn't it?
Oscar out.