# Finding a varialbe in Ansible Output, if a variable is present execute the next Role

**URL:** <https://forum.ansible.com/t/finding-a-varialbe-in-ansible-output-if-a-variable-is-present-execute-the-next-role/31785>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [December 6, 2019, 11:29pm UTC](https://forum.ansible.com/t/finding-a-varialbe-in-ansible-output-if-a-variable-is-present-execute-the-next-role/31785 "2019-12-06T23:29:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prudhvi1](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@Prudhvi1](https://forum.ansible.com/u/Prudhvi1)\
**Post date:** [December 6, 2019, 11:29pm UTC](https://forum.ansible.com/t/finding-a-varialbe-in-ansible-output-if-a-variable-is-present-execute-the-next-role/31785/1 "2019-12-06T23:29:45Z")

</div>

- name: Set Fact  
hosts: all  
connection: local  
tasks:

- set\_fact: junction\_detail\_ret\_obj=“{{ ret\_obj[‘data’][‘result’].split(‘\n’) }}”

- name: Output – Set fact  
hosts: all  
connection: local  
tasks:

- debug: var=junction\_detail\_ret\_obj

“junction\_detail\_ret\_obj”

TASK [debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [[zlt13273.enaf.vci.att.com](http://zlt13273.enaf.vci.att.com)] =\> {  
“junction\_detail\_ret\_obj”: [  
“cmd\> server task net-webseald-zlt13273 show /lo”,  
" Junction point: /lo",  
" Type: SSL",  
" Junction hard limit: 0 - using global value",  
" Junction soft limit: 0 - using global value",  
" Active worker threads: 0",  
" Basic authentication mode: filter",  
" Forms based SSO: disabled",  
" TFIM junction SSO: no",  
" Authentication HTTP header: insert - iv\_user “,  
" Remote Address HTTP header: do not insert”,  
" Stateful junction: no",  
" Boolean Rule Header: no",  
" Scripting support: no",  
" Preserve cookie names: no",  
" Cookie names include path: no",  
" Transparent Path junction: no",  
" Delegation support: no",  
" Mutually authenticated: no",  
" Insert WebSphere LTPA cookies: no",  
" Insert WebSEAL session cookies: no",  
" Request Encoding: UTF-8, URI Encoded",  
" Server 1:“,  
" ID: 61838f80-187f-11ea-b3fb-005056a4404b”,  
" Server State: not running",  
" Operational State: Online",  
" Hostname: zlt13273",  
" Port: 8445",  
" Virtual hostname: :8445",  
" Server DN: zlt13273",  
" local IP address: “,  
" Query\_contents URL: /sps/cgi-bin/query\_contents”,  
" Query-contents: unknown",  
" Case insensitive URLs: no",  
" Allow Windows-style URLs: no",  
" Current requests : 0",  
" Total requests : 1"  
]  
}

when Server State: not running",

I have to call another role as below

- name: Reload Junction  
hosts: all  
connection: local  
roles:
- role: set\_junction  
tags: [“junction”, “set”, “/lo”]  
set\_junction\_junction\_point: “/lo”  
set\_junction\_junction\_type: “ssl”  
set\_junction\_reverseproxy\_id: “{{ reverseproxy\_instance\_name }}”  
set\_junction\_virtual\_hostname: “”  
set\_junction\_server\_hostname: “{{ inventory\_hostname }}”  
set\_junction\_server\_port: “8445”  
set\_junction\_server\_dn: “”  
set\_junction\_mutual\_auth : “yes”  
set\_junction\_basic\_auth\_mode: “filter”  
set\_junction\_remote\_http\_header: [“iv\_user”]  
set\_junction\_client\_ip\_http: “no”  
set\_junction\_query\_contents: “/sps/cgi-bin/query\_contents”  
set\_junction\_scripting\_support: “no”  
set\_junction\_insert\_session\_cookies: “no”  
set\_junction\_cookie\_javascript\_block: “none”  
set\_junction\_stateful\_junction: “no”  
set\_junction\_request\_encoding: utf8\_uri  
changed\_when: “‘Server State: not running’ not in junction\_detail\_ret\_obj”

The when statement is not working, I have tried different when statments

when: junction\_detail\_ret\_obj.find(‘Online’) != -1  
when: junction\_detail\_ret\_obj | regex\_search(‘Server State: not running’)

Please help me on this
