Skip to content

Instantly share code, notes, and snippets.

@gipi
Last active August 29, 2015 13:59
Show Gist options
  • Save gipi/10591696 to your computer and use it in GitHub Desktop.
Save gipi/10591696 to your computer and use it in GitHub Desktop.
#ansible

Home page | Documentation | Variables | Handlers | Roles | Video

Principles

Playbook contains Plays contains Tasks call modules, Handlers can be triggered by tasks

INSTALLATION

$ git clone https://github.com/ansible/ansible.git && cd ansible
$ make deb
# dpkg -i ../ansible_XXX.deb

GETTING STARTED

Create an inventory file with hostname in it and then

$ ansible -i <inventory> all -m setup --tree /tmp/facts

CUSTOM MODULES

This is a simple bash module

#!/bin/bash

echo {\"args\": \"$(cat $1)\" }
exit 0

note that the argument to this is script is the file where the argument are written; it's possible to execute with

$ ansible -i inventory all -m testshell -a 'miao=bau foo=bar'
questionemeridionale | success >> {
    "args": "miao=bau foo=bar"
}

if you save the script into a file named library/testshell.

Vagrant

In order to provision with it

  config.vm.provision "ansible" do |ansible|
    ansible.playbook = "provisioning/playbook.yml"
    #ansible.verbose  = 'vvvv'
    ansible.extra_vars = {
        ansible_ssh_user: 'root',
        db_user: "astauser",
        db_name: "astadb",
        db_password: "asta"
    }
 
  end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment