Hi, This has to do how we are managing inventory as per project requirements. We have some quite elaborate structure and it is now tried and tested. What i am doing now is automating routines stuff with Ansible and this cannot result in changing the existing structure. I gotta find ways with the current setup fixed.
And anyways, i would like to get a general answer if that would be possible, not just to solve my current problem but also to know that we have this 'possibility' in Ansible so that i can go on think of more automation ideas. On Wednesday, 21 June 2017 17:52:58 UTC+2, Dick Davies wrote: > > Why wouldn't you have a single repo in that case? > You can have multiple inventory folders under the playbooks e.g. > > .├── roles < - common roles > │ ├── bar > │ └── foo > ├── site.yml <- common playbooks > ├── dev <- dev inventory > │ ├── group_vars > │ │ └── all > │ └── hosts > ├── prod <- production inventory > │ ├── group_vars > │ │ └── all > │ └── hosts > > └── staging <- staging inventory > ├── group_vars > │ └── all > └── hosts > > Then your jenkins play just checks out the repo and runs > > ansible-playbook -i dev/ site.yml > > (i.e. just switch the inventory to the right one). > > On 20 June 2017 at 16:37, ishan jain <[email protected] <javascript:>> > wrote: > > I want to make it useful for others, thus trying to cut on an additional > GIT > > clone step. I will create a Jenkins job for this which would then just > need > > a parameter (with which i can figure out GIT repo). > > > > On Tuesday, 20 June 2017 17:24:37 UTC+2, Dick Davies wrote: > >> > >> Can't you just pull the git repo before you run the inventory? > >> > >> > >> On 20 June 2017 at 15:00, ishan jain <[email protected]> wrote: > >> > I keep my inventory files for each environment in GIT repositories. I > am > >> > working on some sort of a helper service which i am writing in > Ansible > >> > and > >> > this should perform some (housekeeping) tasks on the specified > servers, > >> > which i wish to specify using existing inventory files. I want to > make > >> > the > >> > GIT repo as a parameter for this script and then the script will have > >> > its > >> > target inventory file. I am not sure how to proceed from here. > >> > > >> > How can i load this inventory file within a task ? After loading, i > can > >> > either invoke next play or refresh the inventory with meta. Using > >> > add_host > >> > doesn't seem to be an option as there are elaborate inventory > >> > configurations > >> > which i want to reuse as it is rather than writing more logic to load > >> > it.I > >> > don't see any lookup/parser either. The only option remains for me is > to > >> > keep the second phase logic in different playbook and after fetching > the > >> > inventory just shoot a shell command executing this playbook with the > >> > inventory, but this method won't give me the logs like a regular > >> > playbook > >> > execution. > >> > > >> > -- > >> > 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 [email protected]. > >> > To post to this group, send email to [email protected]. > >> > To view this discussion on the web visit > >> > > >> > > https://groups.google.com/d/msgid/ansible-project/4e2c79d8-7190-4050-9977-ad994032794f%40googlegroups.com. > > > >> > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b7e869b3-8db6-4278-a6fb-fd72272c7140%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
