How to pass 'hosts' value to an imported or included playbook?
903 views
Skip to first unread message
Peter Bi
unread,
May 18, 2020, 2:44:14 PM5/18/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
I've playbook A to include roles to conduct an operation. Now I want to create playbook B to import/include playbook A but want to pass 'hosts' value to A. In other words, I want to make A to work dynamically with different hosts depending on the playbooks (B/C/D/E/etc.) that include/import it.
I've searched around and couldn't find a good way to do it, I'm running Ansible 2.7.10
I tried in Playbook B like [ -import_playbook playbook-A.yml my-host='host_B_name'] (in playbook A [ hosts: {{'my-host'}}]), but got error: Invalid variable name in vars specified for PlaybookInclude: 'my-host' is not a valid variable name
Any help or idea here?
Thanks in advance!
Vladimir Botka
unread,
May 18, 2020, 3:38:39 PM5/18/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Peter Bi, ansible...@googlegroups.com
On Mon, 18 May 2020 11:44:13 -0700 (PDT)
Peter Bi <pybi...@gmail.com> wrote:
> ... make A to work dynamically with different hosts depending on the
> playbooks (B/C/D/E/etc.)
* At the moment, it's not possible to 'include' a playbook. There is only
'import_playbook'. There is no difference between importing a play and
putting the code in-line.