On 31. okt. 2017 19:10, Aleks Przhelyaskovskiy wrote:
> Thank you for your reply. Your solution is indeed clean, and simple. It
> will work well for the exact problem I've described.
> However, I would like to explore a more generic case where one may need to
> run the same group of tasks /roles on N groups, where N can be between 1
> and 8. Just trying to minimize redundant code.

Something like this


playbook.yml
---
- hosts: group{{ g_nr }}
  tasks:
    - name: Only run on manager
      debug: msg='I'm running on manager'
      when: inventory_hostname == "manager" ~ g_nr

    - name: Run on all host in group
      debug: msg="I'm running on all hosts"


ansible-playbook playbook.tml -e g_nr=1


-- 
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/9f0d6e62-ef93-edf1-6364-026178f7c353%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to