Importing multiple ansible playbooks

188 views
Skip to first unread message

Chris Bidwell - NOAA Federal

unread,
Nov 2, 2022, 12:22:44 PM11/2/22
to ansible...@googlegroups.com
Hi all,

Is there a way, or what is the syntax since I can't seem to find it on importing an ansible playbook and with that applying a specific tag to one or some of those playbooks?

---
# Add tsg keys
- import_playbook: tsg.yml
- import_playbook: tsgkey.yml
 
# Connect to RHSM
- import_playbook: capsule.yml
 
# Install Server environment for RHEL8
- import_playbook: rhel8_svr_env.yml
  - add tag here??  Doesn't work.
 
# Setup puppet
- import_playbook: chrony.yml
 
# Do updates
- import_playbook: cfu.yml
 
# Reboot after updates
- import_playbook: cfr.yml
 
# Install EPEL
- import_playbook: epel.yml

Rowe, Walter P. (Fed)

unread,
Nov 2, 2022, 1:16:50 PM11/2/22
to ansible...@googlegroups.com
First you should read these pages that describe the difference between import vs include.



Do you want to import these playbooks and parse them once at load time, or "include" and parse them as they are encountered at run-time?

One reason to consider include vs import. If you have a when clause on an imported playbook, all the tasks within the playbook inherit that when clause and are evaluated individually. If you have a when clause on an included playbook, it applies to the include task itself (whether I include and execute the playbook). This can be a huge performance improvement.

Secondly you want to consider whether you want to include "playbooks" or "tasks" files. Task files inherit the inventory, become, gather_facts, etc of the parent playbook that includes them.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

--
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/CAHKi8CgZTe1dGG06KP%2BwO1Lm5FSspzKuH6N75fc2xdxj%2BxuuXQ%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages