0

I am writing a playbook where i need to select host which will be a part of group which starts with name "hadoop". The host will be supplied as an extra variable in term of parent group. The task is about upgrading the java on all machines with repo but there are certain servers which dont have repo configured or are in dmz and can only use there local repo... i need to enable local_rpm:true so that when the playbook execute the server which belong to hadoop group have this fact enabled.

I tried like below :

- hosts: '{{ target }}'
  gather_facts: no
  become: true
  tasks:
  - name: enable local rpm
    set_fact:
        local_rpm: true
    when: "'hadoop' in group_names"
    tags: always

and then importing my role based on tag

larsks
  • 277,717
  • 41
  • 399
  • 399

1 Answers1

0

It's probably better to use group_vars in this case.

https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#group-variables

sebthebert
  • 12,196
  • 2
  • 26
  • 37