Using Satellite parameters for complex Ansible provisioning.

Posted on

I am looking for way of simplifying the configuration parameters needed for one of my Ansible playbooks.

Scenario and current solution
I have an Ansible playbook used for provisioning and configuration management of a group of web servers. These servers host several sites and the web teams adds and removes sites to these servers on a regular basis.

Because of the time constraints at the time of original implementation, I have a parameter on the Satellite host group that contains a list of all of the sites the servers host. Such as:

sites_hosted = ["site1.com", "site2.com", site3.com"]

Then included in the Ansible role, there are var files used to configure each site. Such as: site1.com.yml

---
staging:
    deployment_user: devdeploy_stag
    site_alias: staging.site1.com
    ssl: false
    multisite: site2.com

production:
    deployment_user: devdeploy_prod
    site_alias: www.site1.com site1.com
    ssl: true
    multisite: site2.com
...

The workflow to making changes ends up being. 1) login into Satellite, modify the host group's sites_hosted parameter as needed, 2) check out the Ansible role from git and modify the var files as needed, then commit changes back to git. 3) using Ansible Tower, launch job to update the server configs.

I don't care for having part of the configuration in Satellite and part in the role and the workflow is cumbersome. My preference would be to move all of the settings and the role into Satellite, having a single place to make the configuration changes and push them to the servers.

I see two solutions for doing so.
1) Multiple parameters for such as:

sites_hosted = ["site1.com", "site2.com", site3.com"]
site1_staging_deployment_user = devdeploy_stag
site1_staging_site_alias: staging.site1.com

etc
But I'm afraid the sheer number of parameters needed to configure a dozen or more sites will be over whelming in practice.
2) Parameter values as dictionary:

sites_hosted = ["site1.com", "site2.com", site3.com"]
site1_staging = {"deployment_user": "devdeploy_prod", "site_alias": "staging.site1.com"}

etc
This is the solution I'm leaning towards.

Has anyone else ran into a similar situation, and if so, how did you solve it?

Thank you in advance,

Jeremy

Responses