Skip to content

m-kraus/ansible-demo

Repository files navigation

Ansible Demo

Ansible demo environment with role "nagiosconfig" for generating nagios configs out of ansible facts.

Prerequisites

Vagrant and Virtualbox need to be installed to run this demo.

Note: Vagrant would be able to use Ansible-Playbooks for provisioning virtual machines. But to keep the dependencies on the host as small as possible, I opted to use Shell-script provisioning instead.

Starting the demo

After cloning this repository, change into the repo-directory:

cd ./ansible_demo/

vagrant up

First start take a couple of minutes to complete, since the Vagrant base-boxes need to be downloaded and the virtual machines have to be provisioned.

This demo creates five virtual machines: one controlnode which runs Ansible and four target machines (app1, app2, web1, web2).

Trying out Ansible

You can now SSH into the controlnode:

vagrant ssh controlnode

For a first start with Ansible, you can find the following sample commands also in the file .~/sample_commands:

ansible all -a "hostname"
ansible all -a "hostname" -k
ansible all -a "uptime" -k
ansible-playbook distribute-ssh-keys.yml -k
ansible web1 -m setup
ansible-playbook generate_nagios_config.yml

All Ansible commands are executed as user vagrant with the password vagrant.

The Ansible configuration file is located in ~/.ansible.cfg, it sets ~/inventory.ini as inventory file and adds some ssh options.

Two Ansible playbooks (distribute-ssh-keys.yml, generate_nagios_config.yml) are provided with the demo, as well as the Ansible role nagiosconfig, which is locted in ~/roles/nagiosconfig/.

Accessing the OMD web interface

You can access the OMD web interface on the following address:

https://10.0.15.10/monitoring/

After running the Ansible playbook generate_nagios_config, you can see here the newly created hosts (web1, web2, app1, app2) along with their service checks.

Stop the demo

If you want to halt the VMs to reuse them later, you can issue the vagrant halt command from the repo-directory. If you want to start the VMs again later, issue vagrant up.

If you do not need the demo VMs anymore, you can clean them up with vagrant destroy.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published