If the same variable is defined for multiple parents ansible should be 
smart enough to return the value for the parent which is being referred to. 
At the very least, if this behavior is not going to be corrected, ansible 
should fail when the same variable is defined for multiple parents. 
Arbitrarily returning the value associated for any parent is a bug. I'll 
work around it.

On Monday, December 16, 2013 8:30:27 AM UTC-5, Michael DeHaan wrote:
>
> Your problem is that the router has been added to both groups, and the 
> variables overlap.
>
> You probably want to move the variable into play level, with vars_files, 
> or similar.
>
> The idea that variables are sourced from all groups is quite intentional, 
> hosts may group by behavior or geography -- for instance, a machine may be 
> a webserver and also be running out of a particular datacenter and it might 
> be addressed as "webservers" and need to pull in the info from the other 
> geography-oriented group, etc.
>
>
>
>
> On Sun, Dec 15, 2013 at 5:33 PM, Mike Cavedon <[email protected]<javascript:>
> > wrote:
>
>> https://gist.github.com/anonymous/7979176
>>
>> -bash-4.1$ ansible-playbook -v -i *hosts* kill.yml
>>
>> PLAY [request_router] 
>> ********************************************************* 
>>
>> GATHERING FACTS 
>> *************************************************************** 
>> ok: [router.releng.net]
>>
>> TASK: [Kill process if not stopped gracefully] 
>> ******************************** 
>> failed: [router.releng.net] => {"changed": true, "cmd": "pgrep -f* 
>> log4j-dxad-web.xml *&& (echo \"Killing\"; pkill -9 -f* 
>> log4j-dxad-web.xml*); ", "delta": "0:00:00.034292", "end": "2013-12-15 
>> 17:31:13.982646", "item": "", "rc": -9, "start": "2013-12-15 
>> 17:31:13.948354"}
>> stdout: 13506
>> Killing
>> ...ignoring
>>
>> PLAY [memcached_router] 
>> ******************************************************* 
>>
>> TASK: [Kill process if not stopped gracefully] 
>> ******************************** 
>> failed: [router.releng.net] => {"changed": true, "cmd": "pgrep -f 
>> *log4j-dxad-web.xml 
>> *&& (echo \"Killing\"; pkill -9 -f* log4j-dxad-web.xml*); ", "delta": 
>> "0:00:00.035120", "end": "2013-12-15 17:31:18.841508", "item": "", "rc": 
>> -9, "start": "2013-12-15 17:31:18.806388"}
>> stdout: 13523
>> Killing
>> ...ignoring
>>
>> PLAY RECAP 
>> ******************************************************************** 
>> router.releng.net          : ok=3    changed=2    unreachable=0   
>>  failed=0   
>>
>> -bash-4.1$ 
>>
>> ---------------------------------------------------------------------------------------------------------------------------------------
>>
>> -bash-4.1$ ansible-playbook -v -i *hosts2* kill.yml
>>
>> PLAY [request_router] 
>> ********************************************************* 
>>
>> GATHERING FACTS 
>> *************************************************************** 
>> ok: [router.releng.net]
>>
>> TASK: [Kill process if not stopped gracefully] 
>> ******************************** 
>> failed: [router.releng.net] => {"changed": true, "cmd": "pgrep -f 
>> *log4j-memcached-router.xml 
>> *&& (echo \"Killing\"; pkill -9 -f *log4j-memcached-router.xml*); ", 
>> "delta": "0:00:00.033928", "end": "2013-12-15 17:32:28.397941", "item": "", 
>> "rc": -9, "start": "2013-12-15 17:32:28.364013"}
>> stdout: 13580
>> Killing
>> ...ignoring
>>
>> PLAY [memcached_router] 
>> ******************************************************* 
>>
>> TASK: [Kill process if not stopped gracefully] 
>> ******************************** 
>> failed: [router.releng.net] => {"changed": true, "cmd": "pgrep -f 
>> *log4j-memcached-router.xml 
>> *&& (echo \"Killing\"; pkill -9 -f *log4j-memcached-router.xml*); ", 
>> "delta": "0:00:00.032951", "end": "2013-12-15 17:32:33.446863", "item": "", 
>> "rc": -9, "start": "2013-12-15 17:32:33.413912"}
>> stdout: 13596
>> Killing
>> ...ignoring
>>
>> PLAY RECAP 
>> ******************************************************************** 
>> router.releng.net          : ok=3    changed=2    unreachable=0   
>>  failed=0   
>>
>> -bash-4.1$ 
>>
>>
>> On Sunday, December 15, 2013 3:49:43 PM UTC-5, Michael DeHaan wrote:
>>
>>> Yeah, I mean the task files to see what variables you are using, whether 
>>> anything is hard coded, etc...
>>>
>>> (This is probably best uploaded to gist.github.com)
>>>
>>>
>>>
>>>
>>>
>>> On Sun, Dec 15, 2013 at 1:29 PM, Mike Cavedon <[email protected]> wrote:
>>>
>>>> I'm pretty sure everything is in the post.
>>>>
>>>> Re-post ansible/kill.yml:
>>>>
>>>> -bash-4.1$ cat ansible/kill.yml
>>>> - hosts: request_router
>>>>   user: dataxu
>>>>   vars_files:
>>>>     - vars/globals.yml
>>>>     - vars/realtime_system.yml
>>>>   tasks:
>>>>     - include: tasks/realtime_system/kill.yml
>>>>
>>>> - hosts: memcached_router
>>>>   user: dataxu
>>>>   vars_files:
>>>>     - vars/globals.yml
>>>>     - vars/realtime_system.yml
>>>>   tasks:
>>>>     - include: tasks/realtime_system/kill.yml
>>>> -bash-4.1$ 
>>>>
>>>> On Sunday, December 15, 2013 11:30:48 AM UTC-5, Michael DeHaan wrote:
>>>>
>>>>> It's hard to say what you've got in there wrong without seeing your 
>>>>> entire playbook.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Sat, Dec 14, 2013 at 11:43 PM, Mike Cavedon <[email protected]>wrote:
>>>>>
>>>>>> Here is the issue reproduced. router is a child of both 
>>>>>> request_router and memcached_router. In order to kill request_router, 
>>>>>> "log4j-dxad-web.xml" is looked for in the process running on the 
>>>>>> 'router' 
>>>>>> host. In order to kill memcached_router, "log4j-memcached-router.xml" is 
>>>>>> looked for in the process running on the 'router' host.
>>>>>>
>>>>>> (skytap_env)-bash-4.1$ cat hosts
>>>>>> [router]
>>>>>> router.releng.net    ansible_ssh_host=172.24.233.2
>>>>>>
>>>>>>
>>>>>> [router:vars]
>>>>>>
>>>>>>
>>>>>>
>>>>>> [request_router]
>>>>>>
>>>>>> [request_router:vars]
>>>>>> process_identifier=log4j-dxad-web.xml
>>>>>>
>>>>>> [request_router:children]
>>>>>> router
>>>>>>
>>>>>>
>>>>>>
>>>>>> [memcached_router]
>>>>>>
>>>>>>
>>>>>> [memcached_router:vars]
>>>>>> process_identifier=log4j-memcached-router.xml
>>>>>>  
>>>>>> [memcached_router:children]
>>>>>> router
>>>>>>
>>>>>>
>>>>>>
>>>>>> [matcher]
>>>>>> matcher.releng.net    ansible_ssh_host=172.24.233.3
>>>>>>
>>>>>>
>>>>>> [matcher:children]
>>>>>> ad_matcher
>>>>>> memcached_matcher
>>>>>>
>>>>>>
>>>>>>
>>>>>> [ad_matcher]
>>>>>>
>>>>>> [ad_matcher:vars]
>>>>>> process_identifier=log4j-admatcher.xml
>>>>>>
>>>>>>
>>>>>> [memcached_matcher]
>>>>>>
>>>>>> [memcached_matcher:vars]
>>>>>> process_identifier=log4j-memcached-matcher.xml
>>>>>>
>>>>>>
>>>>>>
>>>>>> [realtime_system_components]
>>>>>>
>>>>>> [realtime_system_components:vars]
>>>>>> rts_user=dxrts
>>>>>>
>>>>>>
>>>>>> [realtime_system_components:children]
>>>>>> request_router
>>>>>> ad_matcher
>>>>>> (skytap_env)-bash-4.1$ 
>>>>>>
>>>>>> (skytap_env)-bash-4.1$ cat ansible/kill.yml
>>>>>> - hosts: request_router
>>>>>>   user: dataxu
>>>>>>   vars_files:
>>>>>>     - vars/globals.yml
>>>>>>     - vars/realtime_system.yml
>>>>>>   tasks:
>>>>>>     - include: tasks/realtime_system/kill.yml
>>>>>>
>>>>>> - hosts: memcached_router
>>>>>>   user: dataxu
>>>>>>   vars_files:
>>>>>>     - vars/globals.yml
>>>>>>     - vars/realtime_system.yml
>>>>>>   tasks:
>>>>>>     - include: tasks/realtime_system/kill.yml
>>>>>> (skytap_env)-bash-4.1$ 
>>>>>>
>>>>>>
>>>>>> (skytap_env)-bash-4.1$ cat ansible/tasks/realtime_system/kill.yml 
>>>>>> - name: Kill process if not stopped gracefully
>>>>>>   shell: pgrep -f {{ process_identifier }} && (echo "Killing"; pkill 
>>>>>> -9 -f {{ process_identifier }});
>>>>>>   ignore_errors: True
>>>>>>
>>>>>>
>>>>>> In the following, the second pgrep/kill command should be looking for 
>>>>>> log4j-memcached-router.xml
>>>>>>
>>>>>> (skytap_env)-bash-4.1$ ansible-playbook -v -i hosts ansible/kill.yml 
>>>>>>
>>>>>> PLAY [request_router] ******************************
>>>>>> *************************** 
>>>>>>
>>>>>> GATHERING FACTS ******************************
>>>>>> ********************************* 
>>>>>> ok: [router.releng.net]
>>>>>>
>>>>>> TASK: [Kill process if not stopped gracefully] 
>>>>>> ******************************** 
>>>>>> failed: [router.releng.net] => {"changed": true, "cmd": "pgrep -f* 
>>>>>> log4j-dxad-web.xml* && (echo \"Killing\"; pkill -9 -f 
>>>>>> *log4j-dxad-web.xml*); ", "delta": "0:00:00.035682", "end": 
>>>>>> "2013-12-14 23:32:22.911873", "item": "", "rc": -9, "start": "2013-12-14 
>>>>>> 23:32:22.876191"}
>>>>>> stdout: 26041
>>>>>> Killing
>>>>>> ...ignoring
>>>>>>
>>>>>> PLAY [memcached_router] ******************************
>>>>>> ************************* 
>>>>>>
>>>>>> TASK: [Kill process if not stopped gracefully] 
>>>>>> ******************************** 
>>>>>> failed: [router.releng.net] => {"changed": true, "cmd": "pgrep -f 
>>>>>> *log4j-dxad-web.xml* && (echo \"Killing\"; pkill -9 -f 
>>>>>> *log4j-dxad-web.xml*); ", "delta": "0:00:00.030875", "end": 
>>>>>> "2013-12-14 23:32:28.376401", "item": "", "rc": -9, "start": "2013-12-14 
>>>>>> 23:32:28.345526"}
>>>>>> stdout: 26074
>>>>>> Killing
>>>>>> ...ignoring
>>>>>>
>>>>>> PLAY RECAP ******************************
>>>>>> ************************************** 
>>>>>> router.releng.net          : ok=3    changed=2    unreachable=0   
>>>>>>  failed=0   
>>>>>>
>>>>>>
>>>>>> If in the hosts file, I delete everything having to do 
>>>>>> with realtime_system_components (see first "cat hosts" above) which 
>>>>>> shouldn't have anything to do with the kill commands, the opposite log4j 
>>>>>> xml file is looked for both times.
>>>>>>
>>>>>> (skytap_env)-bash-4.1$ cat hosts
>>>>>> [router]
>>>>>> router.releng.net    ansible_ssh_host=172.24.233.2
>>>>>>
>>>>>>
>>>>>> [router:vars]
>>>>>>
>>>>>>
>>>>>>
>>>>>> [request_router]
>>>>>>
>>>>>> [request_router:vars]
>>>>>> process_identifier=log4j-dxad-web.xml
>>>>>>
>>>>>>  [request_router:children]
>>>>>> router
>>>>>>
>>>>>>
>>>>>>
>>>>>> [memcached_router]
>>>>>>
>>>>>>
>>>>>> [memcached_router:vars]
>>>>>> process_identifier=log4j-memcached-router.xml
>>>>>>  
>>>>>> [memcached_router:children]
>>>>>> router
>>>>>>
>>>>>>
>>>>>>
>>>>>> [matcher]
>>>>>> matcher.releng.net    ansible_ssh_host=172.24.233.3
>>>>>>
>>>>>>
>>>>>> [matcher:children]
>>>>>> ad_matcher
>>>>>> memcached_matcher
>>>>>>
>>>>>>
>>>>>>
>>>>>> [ad_matcher]
>>>>>>
>>>>>> [ad_matcher:vars]
>>>>>> process_identifier=log4j-admatcher.xml
>>>>>>
>>>>>>
>>>>>> [memcached_matcher]
>>>>>>
>>>>>> [memcached_matcher:vars]
>>>>>> process_identifier=log4j-memcached-matcher.xml
>>>>>>
>>>>>>
>>>>>> (skytap_env)-bash-4.1$ ansible-playbook -v -i hosts ansible/kill.yml 
>>>>>>
>>>>>> PLAY [request_router] ******************************
>>>>>> *************************** 
>>>>>>
>>>>>>  GATHERING FACTS ******************************
>>>>>> ********************************* 
>>>>>> ok: [router.releng.net]
>>>>>>
>>>>>> TASK: [Kill process if not stopped gracefully] 
>>>>>> ******************************** 
>>>>>> failed: [router.releng.net] => {"changed": true, "cmd": "pgrep -f 
>>>>>> *log4j-memcached-router.xml 
>>>>>> *&& (echo \"Killing\"; pkill -9 -f log4j-memcached-router.xml); ", 
>>>>>> "delta": "0:00:00.036037", "end": "2013-12-14 23:35:58.908763", "item": 
>>>>>> "", 
>>>>>> "rc": -9, "start": "2013-12-14 23:35:58.872726"}
>>>>>> stdout: 26152
>>>>>> Killing
>>>>>> ...ignoring
>>>>>>
>>>>>> PLAY [memcached_router] ******************************
>>>>>> ************************* 
>>>>>>
>>>>>> TASK: [Kill process if not stopped gracefully] 
>>>>>> ******************************** 
>>>>>> failed: [router.releng.net] => {"changed": true, "cmd": "pgrep -f 
>>>>>> *log4j-memcached-router.xml 
>>>>>> *&& (echo \"Killing\"; pkill -9 -f log4j-memcached-router.xml); ", 
>>>>>> "delta": "0:00:00.026807", "end": "2013-12-14 23:36:04.260145", "item": 
>>>>>> "", 
>>>>>> "rc": -9, "start": "2013-12-14 23:36:04.233338"}
>>>>>> stdout: 26185
>>>>>> Killing
>>>>>> ...ignoring
>>>>>>
>>>>>> PLAY RECAP ******************************
>>>>>> ************************************** 
>>>>>> router.releng.net          : ok=3    changed=2    unreachable=0   
>>>>>>  failed=0   
>>>>>>
>>>>>> Mike
>>>>>>
>>>>>> On Saturday, December 14, 2013 4:34:11 PM UTC-5, Michael DeHaan wrote:
>>>>>>
>>>>>>> So I am having trouble what children means here, this is not a 
>>>>>>> playbook keyword and the system will yell about that .. So a little 
>>>>>>> confused.
>>>>>>>
>>>>>>> -- Michael
>>>>>>>
>>>>>>> On Dec 14, 2013, at 4:30 PM, Mike Cavedon <[email protected]> wrote:
>>>>>>>
>>>>>>> I have the following: 
>>>>>>>
>>>>>>>   - name: router
>>>>>>>   - name: request_router
>>>>>>>     children: [router]
>>>>>>>     vars:       
>>>>>>>       component_script: 'requestrouter.sh'
>>>>>>>       process_identifier: 'log4j-dxad-web.xml'
>>>>>>>   - name: memcached_router
>>>>>>>     children: [router]
>>>>>>>     vars:       
>>>>>>>       component_script: 'memcached-router.sh'
>>>>>>>       process_identifier: 'log4j-memcached-router.xml'
>>>>>>>
>>>>>>> When the following executes component_script equals requestrouter.sh 
>>>>>>> when it should equal memcached-router.sh.
>>>>>>>
>>>>>>> - hosts: memcached_router
>>>>>>>   user: root
>>>>>>>   vars_files:
>>>>>>>     - vars/globals.yml
>>>>>>>   tasks:
>>>>>>>      - include: task-to-execute.yml.
>>>>>>>
>>>>>>> How do I get component_script to be set as memcached-router.sh when 
>>>>>>> using hosts: memcached_router?
>>>>>>>
>>>>>>>  -- 
>>>>>>> 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].
>>>>>>>
>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>
>>>>>>>  -- 
>>>>>> 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].
>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> Michael DeHaan <[email protected]>
>>>>>
>>>>> CTO, AnsibleWorks, Inc.
>>>>> http://www.ansibleworks.com/
>>>>>
>>>>>   -- 
>>>> 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].
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>
>>>
>>>
>>> -- 
>>> Michael DeHaan <[email protected]>
>>> CTO, AnsibleWorks, Inc.
>>> http://www.ansibleworks.com/
>>>
>>>   -- 
>> 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:>
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> -- 
> Michael DeHaan <[email protected] <javascript:>>
> CTO, AnsibleWorks, Inc.
> http://www.ansibleworks.com/
>
>  

-- 
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].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to