On 06. feb. 2017 16:38, 'Tom Bartsch' via Ansible Project wrote:
in my hosts file I have a group "product".
This group has 4 hosts: "product-et", "product-at", "product-qs" and
"product-pr".

"product" has special properties which are valid for all 4 hosts.
Each of the 4 hosts has special properties which are valid only for this
special host.

Now I want to write a playbook which generates jenkins-jobs.
I want to call this playbook with "hosts=product".

The playbook itself has to generate some jobs for the whole product. So
each of this jobs should exist only once in Jenkins.
Futher this playbook has to generate some jobs for each of the 4 hosts. So
each of this jobs should exist 4 times with only differences which depend
on the host properties.

For each of these jobs the properties of the group and the properties of
each of the hosts are necessary.

My problem now is that if I call this playbook with "hosts=product" it will
generate each of the group jobs 4 times. So it's 3 times to much.

So now my question is how to realize this that I am able to have a mix of
one time execution tasks (for the group) and tasks that have to be executed
for each host?

I might have misunderstood your, but I believe you are looking for run_once.

https://docs.ansible.com/ansible/playbooks_delegation.html#run-once

With run_once on a task, the task is only executed on one of the hosts in the play.

--
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/5be075c8-2c88-b263-6b08-950713101184%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to