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

36 views
Skip to first unread message

Prudhvi A

unread,
Dec 6, 2019, 6:29:45 PM12/6/19
to Ansible Project


- 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] => {
    "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
Reply all
Reply to author
Forward
0 new messages