On Wednesday, 20 December 2017 12.56.59 CET [email protected] wrote:
> I am trying to create multiple different directory structure using the
> with_items and again i need to refer the same directory structure in the
> other plays in the playbook.
>
> for example
>
> - file: name=/jenkins/data/{{item.dir1}}/{{item.dir2}}
> with_items:
> - {dir1: str-build, dir2: gitconfig_dev}
> - {dir1: btr-build, dir2: gitconfig_test}
> - {dir1: ctr-build, dir2: gitconfig_test6}
> ......................................
> there are around 20 items like this
> ......................................
> same variable i need to refer in the other play like
> - git: repo=http://github/.....
> dest=/jenkins/data/{{item1.dir1}}/{{item.dir2}} clone=yes
> with_items:
> - {dir1: str-build, dir2: gitconfig_dev}
> - {dir1: btr-build, dir2: gitconfig_test}
> - {dir1: ctr-build, dir2: gitconfig_test6}
>
> Again in some other play ...so how do i make this* global *so that we
> define once *with_items* and use it in all the other play..
> thank you.
Add it in a variable in group_vars/all.yml then it's global.
all.yml
---
jenkins_dir:
- {dir1: str-build, dir2: gitconfig_dev}
- {dir1: btr-build, dir2: gitconfig_test}
- {dir1: ctr-build, dir2: gitconfig_test6}
They you can use
with_items: '{{ jenkins_dir }}'
--
Kai Stian Olstad
--
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/9370214.p3PfHMhOmn%40x1.
For more options, visit https://groups.google.com/d/optout.