CentOS infrastructure as code
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
playbooks
roles
tests/init/vagrant
.gitignore
.pre-commit-config.yaml
BEST_PRACTICES.md
LICENSE.txt
README.md
ansible.cfg
requirements.txt

README.md

ansible-sample-repository

This code contains a sample ansible repository. The main reason of it's existance is to provide a good example, how to develop and maintain ansible code.

Installation

  • First of all, prepare virtualenv.
$ virtualenv .venv --python=python2.7
$ source .venv/bin/activate
  • Install required packages, kept in requirements.txt
$ pip intall -r requirements.txt
  • Install pre-commit. It is recommended to install pre-commit separately from virtualenv. The installation procedure is well described at the following page.

After the installation is completed, activate the hooks.

$ pre-commit install

Testing-environment

The following tasks are super easy with homebrew.

$ brew cask install vagrant virtualbox
  • Install vagrant-hostmanager plugin.
$ vagrant plugin install vagrant-hostmanager
  • Make virtual-machines up.
$ cd tests/init/vagrant
$ vagrant up

The desired state is the following.

$ vagrant status
Current machine states:

host-00                   running (virtualbox)
host-01                   running (virtualbox)
host-02                   running (virtualbox)
$ cd -
  • Test ansible over virtual-machines.
$ ansible -m ping -o all

The desired output is the following.

$ ansible -m ping -o all
hosts-00.local | SUCCESS => {"changed": false, "ping": "pong"}
hosts-02.local | SUCCESS => {"changed": false, "ping": "pong"}
hosts-01.local | SUCCESS => {"changed": false, "ping": "pong"}