I am experiencing some strange behavior from what I understand to be 
applying tags to roles/dependencies. I wrote a facts plugin to gather 
information about a systems role, and it includes this in the playbook run. 
 Each system runs a playbook on its own, only managing itself.

# ansible_local facts
127.0.0.1 | success >> {
    "ansible_facts": {
        "ansible_local": {
            "host_roles": {
                "roles": [
                    "APPSERVERS",
                    "COMMON",
 
                ]
            }
        }
    },
    "changed": false
}

# site.yml
---
 - hosts: 127.0.0.1
   connection: local
   gather_facts: yes
   sudo: yes

   roles:
     - { role: appserver,             , when: "'APPSERVERS' in 
ansible_local.host_roles.roles" }
     - { role: hadoop_jobtracker, when: "'HADOOP_JOBTRACKER' in 
ansible_local.host_roles.roles" }


# roles/appserver/meta/main.yml
---
  dependencies:
    - { role: managed_interface, tags=initial }

This is the simplified output of my setup. I have a server that is acting 
with a local run of a playbook, and gathers its roles, and then grabs the 
dependencies from its role to call the manage_interface role when its 
tagged as initial.

# command line
ansible-playbook site.yml --tags "initial"

The command runs only its tasks/main.yml and not the dependencies.

When I tried applying at the site.yml level things got really weird. It 
runs both the appserver and hadoop_jobtracker roles, seemingiy ignoring the 
"when" statements.

   roles:
     - { role: appserver,               tags: ['initial'], when: 
"'APPSERVERS' in ansible_local.host_roles.roles" }
     - { role: hadoop_jobtracker, tags: ['initial'], when: 
"'HADOOP_JOBTRACKER' in ansible_local.host_roles.roles" }

Are there some rules in which these can be applied properly, or am I 
hacking at the system and making trouble again?

-- 
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/dac2a7a2-a8d7-40b8-b00d-2801ff9289a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to