Thanks, Michael. One question about this bug/behavior, I want to verify. 
 If tags are applied at the role level, is it supposed to run each role, 
regardless of the when statement? 

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" }

In this case, both appserver and the hadoop_jobtracker roles are applied, 
disregarding my when statement. Do tags take precendence over other logic?

I am able to workaround this bug by adding an include statement in the 
tasks for each role, and everything works properly.

On Wednesday, September 24, 2014 11:30:37 AM UTC-7, Michael DeHaan wrote:
>
> Ok, please file a bug about this, that the when statements need to be 
> propagated to the role deps.
>
> Thanks!
>
>
>
> On Wed, Sep 24, 2014 at 12:41 PM, E.C. Raymond <[email protected] 
> <javascript:>> wrote:
>
>> Hi Michael,
>>
>> I am using 1.7.1, and tried on latest devel build.
>>
>> On Tuesday, September 23, 2014 6:57:02 PM UTC-7, Michael DeHaan wrote:
>>>
>>> For starters, can you share what version of Ansible you are using?
>>>
>>> Thanks!
>>>
>>>
>>>
>>> On Tue, Sep 23, 2014 at 6:24 PM, E.C. Raymond <[email protected]> wrote:
>>>
>>>> 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 
>>>> <https://groups.google.com/d/msgid/ansible-project/dac2a7a2-a8d7-40b8-b00d-2801ff9289a2%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>  -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/5e108fbe-0775-4b6f-86d0-b171c05660f1%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/5e108fbe-0775-4b6f-86d0-b171c05660f1%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/7b6d810e-cb65-45c3-8d08-c9ebc231e16a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to