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