AnswerBun.com

Tying playbooks together

DevOps Asked by bob-the-builder on August 22, 2021

Say, i have written bunch of ansible roles and playbooks, configured my playbooks structure and now i’m trying to tie them to one playbook which will do its thing depending on tags or inventory file provided. Should i strive for that? Or is it better to have bunch of playbooks and call them depending on the tasks/hosts needed? What is the best way to go about this? I can’t seem to find any example of tying it all together in one playbook or bunch of them which will do its thing to ones infrastructure depending on arguments provided.

Best practice in ansible docs covers organization of playbook structure but not organization of playbook use on infrastructure. Is there any examples of organizing playbooks use on infrastructure?

One Answer

What I have done before goes on the same direction as Zeitounator commented; you can have one or more "meta" or master playbooks that import the ones you need to run your entire automation. To add to Zaito's comment; you can use the when clause on import_playbook or include to control the execution of those "inner" playbooks; something like this:

Say you want to execute PlatformB playbooks only for an stg or prod environment using a defined env ansible variable:

- include: platformA/do_something_on_platformA.yml
- include: platformB/do_something_on_platformB.yml
  when: env == 'stg' or env == 'prod'

you could change the value of env using --extra-vars on execution time or something.

hope it helps, cheers.

Answered by Pablo Arango on August 22, 2021

Add your own answers!

Related Questions

Gitlab CI push to docker-registry fails

1  Asked on November 22, 2021 by sachith-muhandiram

       

Passing replicas number into container

4  Asked on November 20, 2021

   

jenkins – gitparam jobdsl – branchFilter

1  Asked on November 15, 2021 by joudaon

   

Logging & Monitoring on multiple servers

1  Asked on November 12, 2021 by aivanf

     

Releasing so many changes at once to production

1  Asked on November 7, 2021 by astroanu

 

What is a reasonable level of coding expertise expected of an SRE?

3  Asked on August 22, 2021 by codeforester

   

What’s in THIS environment?

1  Asked on August 22, 2021 by davetx

       

auto delete aws S3 backups

1  Asked on August 22, 2021 by scott-stensland

 

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP