Ansible Tower Smarter inventories.

I love the idea of smart inventories, I want a large dynamic inventory and then create small subset inventories based on filters to pass onto my other groups. However; There is a huge issue with the smart inventory that it doesn’t present the group information down to them. So if my DBA team has Dev, QA and Prod environments I would need to create 3 inventories for them DB-Dev, DB-QA and DB-Prod instead of being able to just create one DB group and let them set there job template based on a limit to the environment.

The good news is by creating a custom inventory script we can fix this. For this to work you will need to install the networkx pip module onto the tower server/s, make sure that umask is set to 0022 before hand

umask 0022

pip install networkx

Next in Tower

Go to Inventory Scripts and create a new one call it Smarter Inventory and paste in the following.

https://raw.githubusercontent.com/p-avery/tower-inventory/master/tower.py

Next you will want to create an inventory to authenticate to the Tower Server that has access to the master inventory type.

The credential type is Ansible Tower

Next you need to know the Inventory ID number go to the master inventory you want to filter off and in the address bar you will see the id

Example would look like

https://tower.example.com/#/inventories/inventory/16?inventory_search=page_size:20;order_by:name

The Above inventory I went to has an ID of 16

Now we can put this all together

Create a new Inventory,

then go to Sources and create a new source with the Smarter Inventory and the Tower credentials

You need to have 2 Environment Variables set

TOWER_INVENTORY:
TOWER_INVENTORY_GROUP:

The TOWER_INVENTORY needs to be the ID number of the Master Inventory you want to use and the TOWER_INVENTORY_GROUP is going to be the filter/s you want set.

Finally set the permissions of this inventory to the team that would need it, this will bring in the filtered list with all the existing group information.

CloudForms Fix SmartState for VMWare 6.7

VMWare made significant changes of the API’s with the release of 6.7 and as such the way we mount vmdk and read then has changed, you will see once you upgrade that CloudForms can no longer perform a SSA, the error in the User interface will look similar to this.

Continue reading “CloudForms Fix SmartState for VMWare 6.7”

Set custom virtual environments and Ansible versions in Tower

Tower 3.3 introduced the ability to have multiple versions of Ansible availble, this can be really useful if we have custom python packages needed with dependencies we dont want to upgrade, or we want a specific version of Ansible being run to combat anything deprecated.

Continue reading “Set custom virtual environments and Ansible versions in Tower”

Auto Remediation with Zabbix and Ansible Tower Part 1

Objective Goals

1.) Automatically detect new systems and logically add them to a group

2.) If no Agent is found to be running, then to have Ansible Tower run a job to set it up

3.) Create a collection of playbooks that can be used for auto remediation

Continue reading “Auto Remediation with Zabbix and Ansible Tower Part 1”

Auto Patch schedule with Satellite 6.3 and Ansible Tower Part 3

From the previous 2 parts we have set up Satellite and created our Ansible Playbooks, now we want to put it all together on Tower by creating the Job Templates and Workflows to make this happen.

Continue reading “Auto Patch schedule with Satellite 6.3 and Ansible Tower Part 3”

Auto Patch schedule with Satellite 6.3 and Ansible Tower Part 2

In Part one we went over the setup of Satellite and Katello-cvmanager to perform the publish and promote in Satellite.

Now we want to create the playbooks that Ansible Tower with use in order to  patch the servers and then setup the next lifecycle environment.

You want to create these playbooks, You can skip this section and grab them from my github repo HERE but as always understand what is being done before you just run them.

Continue reading “Auto Patch schedule with Satellite 6.3 and Ansible Tower Part 2”

Auto Patch schedule with Satellite 6.3 and Ansible Tower Part 1

The Problem

When it comes to Satellite the flow to patch our life cycle environments feels like a very manual process, after our sync plan completes, I need to publish a new version and then promote this through my environments ( Dev, QA, Prod etc ) What I want is this to be fairly hands off and have it done in the background automatically for me. And so let’s go over the steps needed to achieve this. Continue reading “Auto Patch schedule with Satellite 6.3 and Ansible Tower Part 1”

CloudForms create AD DNS with Ansible

I have come up many times where people request to be able to create AD DNS A Records or CNames for Linux Servers that are not going to be joined to the domain, I will go through how we can use Ansible Tower to do this for us. This is very similar to the AD Computer object however we also need to get the IP address as an extra variable for an A Record.

Continue reading “CloudForms create AD DNS with Ansible”

CloudForms create AD Computer Objects with Ansible

I often get asked to setup CloudForms to create AD Computer objects, this will show how to do this with Ansible Tower, the interesting issue we face is CloudForms by default sends the vm name as the limit field but for this we want to run the playbook on a set host and pass the vm name as a variable.

Continue reading “CloudForms create AD Computer Objects with Ansible”