Currently I use gitlab-ci.yml, gitlab runners to execute some various actions with ansible. I dynamically create an inventory file with a python script in a docker image, take the artifact and send to a downstream project that runs a docker image with ansible and executes a playbook on that inventory.
The inventory file has grown a bit too large and I want to break this up, then for each smaller inventory file launch docker image and ansible playbook in parallel.
I thought there should be something like foreach in gitlab-ci.yml but have not found anything like that in the documentation.
There isn’t anything like for-each. The
script sections in CI configs are just Bash commands. So, you can put a Bash loop in there if you like, with a multi-line statement. However, it’s probably neater just to write a Bash script in a separate file and execute it from your
ok, but how would i use the base script to kick off the jobs downstream like I do now?
Can you show me a rough outline of the YAML you have now?
- python3 /scripts/createinventory.py
expire_in: 30 days
- if: $CI_ENV_TRIGGERED == "ALL" && $CI_LOB == "ALL"
- ansible-playbook -i ./inventory.yml ./ansible-playbook.yml
- project: create_inventory_project
- $CI_PIPELINE_SOURCE == "pipeline"