Hi

I have playbook as bellow for retry and send REST API until node state will 
be 'ACTIVE'

- name: health checks - trigger GET node state.
        uri:
          url: "https://bitb.XXX.com/rest/zdu/state";
          method: GET
          validate_certs: false
          headers:
            Content-Type: application/json
          force_basic_auth: true
          user: XXX
          password: XXX
          status_code: 200
        register: response
        until: response.json.buildInfo.state == 'ACTIVE'
        retries: 720  #  720 * 5 seconds = 1hour (60*60/5)
        delay: 5  #  Every 5 seconds

I get the below error:
{"msg": "The conditional check 'response.json.buildInfo.state == 'ACTIVE'' 
failed. The error was: error while evaluating conditional 
(response.json.buildInfo.state == 'ACTIVE'): 'dict object' has no attribute 
'json'"}
any idea what I'm doing wrong ?

I run debug for response output:

ok: [test1] => {
    "response": {
        "changed": false,
        "connection": "close",
        "content_type": "application/json",
        "cookies": {
            "BIGipServerbitb-test-pool": "XX"
        },
        "cookies_string": "BIGipServerbitb-test-pool=XX",
        "date": "Sun, 12 Jun 2022 15:20:07 GMT",
        "elapsed": 0,
        "failed": false,
        "json": {
            "buildInfo": {
                "buildNumber": "7021000",
                "id": "1XX",
                "ipAddress": "X.X.X.X
                "links": [
                    {
                        "href": 
"/nodes/1bdec428-0d68-4381-b082-8661b17e357f",
                        "rel": "self"
                    }
                ],
                "local": true,
                "name": "test1",
                "state": "ACTIVE",
                "version": "7.21.0"
            },
            "state": "STABLE"
        },
        "msg": "OK (unknown bytes)",
        "redirected": false,
        "set_cookie": "BIGipServerbitb-test-pool=XX; path=/; Httponly; 
Secure",
        "status": 200,
        "transfer_encoding": "chunked",
        "url": "https://bitb.XXX.com/rest/zdu/state";,
        "vary": "accept-encoding",
        "x_arequestid": "*7AX",
        "x_auserid": "1",
        "x_ausername": "itadm",
        "x_content_type_options": "nosniff"
    }
}
ok: [test2] => {
    "response": {
        "changed": false,
        "connection": "close",
        "content_type": "application/json",
        "cookies": {
            "BIGipServerbitb-test-pool": "XX"
        },
        "cookies_string": "BIGipServerbitb-test-pool=8X",
        "date": "Sun, 12 Jun 2022 15:20:07 GMT",
        "elapsed": 0,
        "failed": false,
        "json": {
            "buildInfo": {
                "buildNumber": "7021000",
                "id": "1X",
                "ipAddress": "X.X.X.X",
                "links": [
                    {
                        "href": "/nodes/1bdX",
                        "rel": "self"
                    }
                ],
                "local": true,
                "name": "test1",
                "state": "ACTIVE",
                "version": "7.21.0"
            },
            "state": "STABLE"
        },
        "msg": "OK (unknown bytes)",
        "redirected": false,
        "set_cookie": "BIGipServerbitb-test-pool=88X; path=/; Httponly; 
Secure",
        "status": 200,
        "transfer_encoding": "chunked",
        "url": "https://bitb.XXX.com/rest/zdu/state";,
        "vary": "accept-encoding",
        "x_arequestid": "*7AX",
        "x_auserid": "1",
        "x_ausername": "itadm",
        "x_content_type_options": "nosniff"
    }
}

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5365eb08-fdea-4427-abb4-21b1710022dcn%40googlegroups.com.

Reply via email to