"ONE" inventory question

55 views
Skip to first unread message

Xinhuan Zheng

unread,
Feb 26, 2020, 3:01:20 PM2/26/20
to Ansible Project
Hello,

We have ansible code that are in version control repository. This makes how to maintaining "ONE" inventory file difficult. If we need to create multiple repositories, for different purpose of Ansible playbook running, it breaks "ONE" inventory file assumption. In practice, does everyone maintain their inventory file in one single version control repository, or in multiple version control repositories? Would multiple inventory files in multiple version control repositories create inconsistency issue?

Thanks,

- Xinhuan Zheng

Dick Visser

unread,
Feb 26, 2020, 11:29:12 PM2/26/20
to ansible...@googlegroups.com
Hi 
Hard to tell without knowing what and how things are deployed, and by what people/teams. If you provide that context we can give it a try.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/570ae61f-90e9-4143-99ee-d33c1622cbbc%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Xinhuan Zheng

unread,
Feb 27, 2020, 8:53:12 AM2/27/20
to Ansible Project
Hi Dick,

So how do we construct inventory files depending on the factors of deployment process and people/teams, right? I once heard DevOps has people over process, process over automation wisdom, but I never understand what people means in DevOps. So we need first consider what teams/people are responsible first, then what is the process for those teams/people, right?

As people, we basically are divided into system people and development people. System people responsible for building, administering, operating, monitoring, incl, but not limited to computing resources, storage, network; while development people responsible for writing custom code. If the custom code depends on any 3rd party modules, system people typically responsible for installing/configuring/patching that 3rd party modules. Some times system people have to deal with testing in the case of changing one version from another version, like database.

The development team is using Gitlab as their versioning control system. Gitlab provides AutoDevOps, but we can't use. Our custom code isn't in those AutoDevOps areas. The infrastructure code is also versioning controlled in Gitlab. Gitlab has project repository. We try to keep infrastructure code in one repository. But it appears one repository is corresponding one pipeline. Per system perspective, all is infrastructure, until at the application level. So different applications may have different repository, and different set of infrastructure instances to serve them.

I don't know how people handle inventory file version controlling like us. Are you willing to share some of your insights?

Thanks,

- Xinhuan

On Wednesday, February 26, 2020 at 11:29:12 PM UTC-5, Dick Visser wrote:
Hi 
Hard to tell without knowing what and how things are deployed, and by what people/teams. If you provide that context we can give it a try.
On Wed, 26 Feb 2020 at 21:01, Xinhuan Zheng <xinhua...@gmail.com> wrote:
Hello,

We have ansible code that are in version control repository. This makes how to maintaining "ONE" inventory file difficult. If we need to create multiple repositories, for different purpose of Ansible playbook running, it breaks "ONE" inventory file assumption. In practice, does everyone maintain their inventory file in one single version control repository, or in multiple version control repositories? Would multiple inventory files in multiple version control repositories create inconsistency issue?

Thanks,

- Xinhuan Zheng

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.

Claudia de Luna

unread,
Feb 29, 2020, 8:44:04 AM2/29/20
to Ansible Project
HI,

You are certainly correct that adding your host file to each repository is not a solution.

As I see it you have a few options:

1.  Create an environment repository with your host file and your cfg file and anything else you might need and clone your playbook repositories underneath that repository.   Not ideal 

2.  Clone your hosts file repository within your playbook repository.  Also not ideal

3.  Use something like git submodule or git subtree to do option2 in a more structured manner

4. have your hosts/inventory repository somewhere outside your repo and reference that host file when you call your playbook

root@f23399314267:/ansible_local/cisco_aci# ansible-playbook -i ../global_hosts test.yml

PLAY [ACI Configuration Snapshot] *************************************************************************************************



or

root@f23399314267:/ansible_local/cisco_aci# ansible-playbook -i ../master_inventory/global_hosts test.yml

PLAY [ACI Configuration Snapshot] *************************************************************************************************


5.  Look at other, more dynamic ways to include your hosts file. Ansible has options for a dynamic inventory file because your inventory will likely be dynamic.  Not sure keeping it in git is the best long term action (but I do understand it). 

In a situation like yours where I have different playbooks in different environments that act against a single inventory file I use option 4 and option 5.

Claudia
Reply all
Reply to author
Forward
0 new messages