- Install python3
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.8
- Install pip3
sudo apt-get install python3-pip
- Install Ansible and check its version
sudo pip3 install ansible
ansible --version
[Sample output]
config file = None
configured module search path = ['/home/
ubuntu/.ansible/plugins/modules', '/usr/share/ansible/
plugins/modules']
ansible python module location = /home/ubuntu/.local/
lib/python3.8/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0]
- Create an inventory file with:
touch inventory
- Copy the following example:
[example]
192.168.60.5
ansible -i inventory example -m ping -u ubuntu
For more information regarding the installation of Vagrant, check the official documentation.
Go to the tests
folder and run the following command: vagrant up
. This will start the VM created for test purposes.
To ssh to the test VM, go to the tests
folder and run the following command: vagrant ssh test_sandbox
.
In the tests/roles
folder, you'll see a test role to configure our test VM (test_sandbox
). To execute that role, follow the steps below:
- Change to tests directory:
cd tests
. - Start VM:
vagrant up
. - Run the playbook:
ansible-playbook playbook.yml
.
sudo ansible-playbook -b --private-key $HOME/.ssh/<PRIVATE_KEY> playbook.yml