Skip to content

Instantly share code, notes, and snippets.

@hryamzik
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save hryamzik/36a078ec0d1be2f6d48c to your computer and use it in GitHub Desktop.

Select an option

Save hryamzik/36a078ec0d1be2f6d48c to your computer and use it in GitHub Desktop.
- hosts: all
  tasks:
    
    - name: set marker
      set_fact:
        marker: marker
    
    - name: group by marker
      group_by: key=marker
      changed_when: no
      
    - name: target task
      debug: msg="Performing task on {{ inventory_hostname }}, item is {{ item }}"
      with_items: groups['marker']
      when: "hostvars[item].inventory_hostname == inventory_hostname"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment