Skip to content

m1820/atd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Tower Lab (With Demos) Using Vagrant For Mac OS

Created by Christian Trujillo

Follow me:

LinkedIn /trujillochristian
Twitter @hciadvisor
Website HCIBlos.com
YouTube HCIBlogs
Podcast Datacenter Evolution

Thank you Jerry @Corumj for your help!!

I have created an instructional video to walk you through the setup:

Ansible Tower Lab Setup Video

Jump to the Install Process

This project was created to generate a stable, portable, and permanent, Ansible Tower lab environment. The idea is to have a lab environment that can stay permanent so your configurations can be saved everytime you want to use it.

The demos will provide a way to create, recreate and destroy only the demo portion without hurting the base environment.

This was created with:

  • Virtual Box 6.1.4 Download VirtualBox
  • Vagrant 2.2.7 Download Vagrant
  • Ansible version 2.9.6 Install Ansible
  • Mac OSX 10.15.2
    You may be able to run through this instructions on a Windows/Linux based system.
    I have not tested so any help with this would be greatly appreciated.

The following instructions will help you create a demo/lab environment.
This demo will run locally on your MacOS machine

Lab Configuration

Base lab configuration to be use with all the available Demos

After you complete the install process you will have the following:

  • Ansible Tower Server
  • 2 Fedora servers
  • 2 Windows VMs (coming soon)

Inventory:

Ansible Tower Server
Hostname: tower
IP: 192.168.50.10
https://192.168.50.10

Static Website
Hostname: web1 (Fedora31)
IP: 192.168.50.11

WordPress
Hostname: web2 (Fedora31)
IP: 192.168.50.12

Install Process

Installing and running Ansible Tower Lab

Instructions:
  1. Download and install Virtual Box Download VirtualBox
  2. Download and install Vagrant Download Vagrant
  3. Install Ansible engine
  4. Create a folder called vagrant under "Documents"
  5. Download and copy "Vagrantfile" from the setup_files folder to the newly created folder
  6. Download and copy "server_access.yml" from the setup_files folder to the same folder
  7. Open terminal navigate to the "vagrant" folder you created under "Documents"
  8. Run the following command
    vagrant up
    This will do the following:
    - Run the vagrant config file you copied to the vagrant folder
    - Create the first 3 virtual machines (Ansible Tower, 2 Fedora servers)
    - Run through the server_access.yml file which will configure access to the VMs using ssh key pairs
    MacOS 10.9.3 and upwards might require to close VirtualBox and restart it with the following command:
    sudo "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart
    More information can be found here.
  9. Once the vagrant up command finishes you would have to login to the Ansible Tower Server and add a subscription
  10. Once you get the trial subscription for tower you will need to find out the login credentials to access the Tower Server:
    • On the terminal window under the same vagrant directory type: vagrant ssh tower
    • As soon as you login you will see the user name and password for the Tower server
  11. Login to the Tower server via the browser https://192.168.50.10
  12. Within Tower go the user menu on the left and change the admin password to something you can remember

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Now you have a fully functional Ansible Tower server with two Fedora VMs running.
You can access your Tower server and run playbooks etc.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Configuring Tower to run playbooks

  1. Login to Ansible Tower
  2. Add your Fedora servers to your invetory:
    • Resources > Inventory > Create new "inventory" (plus sign button top right)
    • Give it a name and save
    • Under the newly created inventory click on hosts
    • Click on the plus sign to add a new host
    • Under host name add the IP address of the web1 (192.168.50.11)
    • Follow the same procedure to add the second server web2 (192.168.50.12)
  3. Add a project:
  1. Add the credentials to manage your web hosts. The hosts were configured with SSH KeyPairs:
  • Navegate to the vagrant folder you created under your documents
  • Login to the Tower server by going to the terminal and entering the following command
    vagrant ssh tower
  • Get the ssh private key by entering the following command
    cat ~/.ssh/id_rsa
  • Copy the Private Key
    -----BEGIN RSA PRIVATE KEY----
    -----END RSA PRIVATE KEY-----
  • Now that you have the key go back to the Tower Server UI
  • Resources > Credentials
  • Select credential tye and select Machine
  • Give it a name
  • Under user name enter vagrant
  • Paste the Private Key you copied from the Tower server into the SSH Private Key section
  • Click Save

You have now confgured Ansible Tower with the inventory of the Fedora servers, added the github project which will give you access to the playbooks, and added the correct credentials.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
It's time to setup your Templates/Playbooks
Now you can run any of the available demos below
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Demos - Instructions

Linux Demos

Windows Demos