What is Ansible?
Ansible is a configuration management, deployment, and general command execution framework. This framework is similar to Chef, or Puppet, except that it is extremely lightweight, using only python and ssh to get the job done. It also requires very little learning before you can start managing your servers.
Getting Things Installed
Okay, so you’re excited and want to start managing your servers, so lets get some stuff installed first.
|
1 2 3 |
$ git clone git://github.com/ansible/ansible.git $ cd ./ansible $ source ./hacking/env-setup |
Believe it or not, you’re more than 50% done already. Time to install some python modules:
|
1 |
sudo easy_install jinja2 pyyaml paramiko |
The only other step you need to do now is to specify a server to manage.
|
1 2 |
$ echo "127.0.0.1" > ~/ansible_hosts $ export ANSIBLE_HOSTS=~/ansible_hosts |
Okay, so that’s it, you’re ready to rock. Just to test things out:
|
1 |
$ ansible all -m ping --ask-pass |
You should get something that looks a little bit like this:
|
1 2 3 4 5 |
SSH password: 127.0.0.1 | success >> { "changed": false, "ping": "pong" } |
Some Other Neat Stuff
What is the external IP address of all of my servers?
|
1 |
$ ansible all -a "wget -qO - http://ifconfig.me/ip" --ask-pass |
|
1 2 3 |
SSH password: 127.0.0.1 | success | rc=0 >> 1.2.3.4 |
How about restarting all of your webservers?
|
1 |
$ ansible webservers -m service -a "name=httpd state=restarted" |
There is plenty more that you can do with Ansible, this is just a quick getting started intro.
Some next steps would be to read through Ansible’s documentation, its pretty good.