Skip to content

rimelek/ansible-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible examples

About the project

This project contains Ansible examples and a Vagrantfile to create a virtual machine. The connection settings of the examples rely on the default SSH connection settings created by vagrant for the virtualbox virtual machine.

  • host: 127.0.0.1
  • port: 2222
  • ssh private key: $PROJECT_ROOT/.vagrant/machines/default/virtualbox/private_key
  • user: vagrant

You can create your own inventory files if you need: Ansible: Working with Inventory

Each example has a "run.sh" file which contains the command you can execute or create your own command based on the example.

Requirements:

  • Linux host machine (Tested on Kubuntu 19.04)
  • VirtualBox (Optional, Tested with VirtualBox 6.0)
  • Vagrant (Optional, Tested with Vagrant 2.2.3)
  • Python interpreter (Tested with Python 3)
  • Ansible (Tested with Ansible 2.8.4)

Install Ansible in virtualenv on Ubuntu

Make sure you have python3 and pip3 installed on your machine. Otherwise, install them or use "pip" and "python" instead if you want to try it with your default interpreter. Open a terminal, go to the project root and run the following commands:

sudo apt install python3 python3-pip
pip3 install --user --upgrade pip

The above command can change the path of python if they were already installed. Log out and log in again or just log in using su:

su - $USER

Or source the .bashrc file if you use Bash shell.

source $HOME/.bashrc

Install the virtualenv module:

pip3 install --user virtualenv

And create the virtual environment:

python3 -m virtualenv ansible-examples-env
source ansible-examples-env/bin/activate

You can finally install Ansible:

pip3 install -r requirements.txt

Create a virtual machine

This step is optional but recommended if you don't have your own test machine or you don't know how to configure Ansible to set that as target.

In the project root you will find a simple Vagrantfile to download and start an Ubuntu 18.04 LTS machine.

Open a terminal, navigate to the project root and run the following command:

vagrant up

Examples

The examples are in the examples folder. Step into the chosen example folder and execute the run.sh script.

Releases

No releases published

Packages

No packages published