f5devcentral / ansible-role-f5_atc_deploy_declaration

Ansible role used to deploy declaratives to F5 Automated Tool Chain services: AS3, DO, and TS
Apache License 2.0
7 stars 11 forks source link

The conditional check 'atc_AS3_result.json.results failed. #44

Open Zjemm opened 3 years ago

Zjemm commented 3 years ago

Adding an application via big-iq works as expected, but deleting results in the following error:

fatal: [localhost -> localhost]: FAILED! => {
    "msg": "The conditional check 'atc_AS3_result.json.results | map(attribute='message') | list | first != 'no change'' failed. The error was: error while evaluating conditional (atc_AS3_result.json.results | map(attribute='message') | list | first != 'no change'): 'dict object' has no attribute 'results'"
}

doing the same but then to the big-ip does work correctly

ADD application

---

- hosts: all
  connection: local

  vars:
    provider:
      user: admin
      server: 10.10.0.1
      server_port: 443
      password: Password
      validate_certs: no

  tasks:

    - name: ATC POST
      include_role:
        name: .ansible/roles/f5devcentral.atc_deploy
      vars:
        atc_method: POST
        atc_declaration_file: "my-as3-app.json"
        atc_delay: 10
        atc_retries: 5
        provider:
          server: 10.10.0.1
          server_port: "443"
          user: admin
          password: Password
          validate_certs: "false"
          auth_provider: tmos
        register: result

    # atc_AS3_status, atc_DO_status , atc_TS_status
    - debug: var=atc_AS3_status

DELETE application

---

- hosts: all
  connection: local

  vars:
    provider:
      user: admin
      server: 10.10.0.1
      server_port: 443
      password: Password
      validate_certs: no

  tasks:

    - name: ATC POST
      include_role:
        name: .ansible/roles/f5devcentral.atc_deploy
      vars:
        atc_method: DELETE
        atc_declaration_file: "my-as3-app.json"
        atc_delay: 10
        atc_retries: 5
        provider:
          server: 10.10.0.1
          server_port: "443"
          user: admin
          password: Password
          validate_certs: "false"
          auth_provider: tmos

    # atc_AS3_status, atc_DO_status , atc_TS_status
    - debug: var=atc_AS3_status

MY APP:

{
   "class": "AS3",
   "action": "deploy",
   "persist": true,
   "declaration": {
      "class": "ADC",
      "schemaVersion": "3.0.0",
      "target": {
         "address": "10.10.0.2"
       },
      "id": "urn:uuid:33045210-3ab8-4636-9b2a-c98d22ab915d",
      "label": "Sample 1",
      "remark": "Simple HTTP application with RR pool",
      "Sample_01": {
         "class": "Tenant",
         "A1": {
            "class": "Application",
            "service": {
               "class": "Service_HTTP",
               "virtualAddresses": [
                  "10.0.1.10"
               ],
               "pool": "web_pool"
            },
            "web_pool": {
               "class": "Pool",
               "monitors": [
                  "http"
               ],
               "members": [{
                  "servicePort": 80,
                  "serverAddresses": [
                     "192.0.1.10",
                     "192.0.1.11"
                  ]
               }]
            }
         }
      }
   }
}
rjouhann commented 2 years ago

Hello,

F5 has been working on a new module to deploy AS3 declaration via BIG-IQ. I would recommend you to use that module instead.

https://clouddocs.f5.com/products/orchestration/ansible/devel/f5_bigip/modules_2_0/bigiq_as3_deploy_module.html#bigiq-as3-deploy-module-2

Thanks & Regards, Roman

Zjemm commented 2 years ago

Hi @rjouhann

i have tested the new version, but ran into issue's talking to big-iq towards the big-ip, it seems to work ok, but to big-iq not.

i can deploy and patch via the API, using ansible or PHP. and using ATC (= also API)

but using the same json with the new module towards big-iq, i can't get to work and the repository isn't updated in a while

with the files beneath i get the following:

fatal: [localhost]: FAILED! => {"changed": false, "msg": "{'code': 422, 'message': 'status:422, body:{\"code\":422,\"message\":\"Invalid request value \\'[object Object]\\' (path: /declaration) : should have required property \\'class\\' {\\\\\"missingProperty\\\\\":\\\\\"class\\\\\"}\"}', 'originalRequestBody': '{\"code\":422,\"message\":\"Invalid request value \\'[object Object]\\' (path: /declaration) : should have required property \\'class\\' {\\\\\"missingProperty\\\\\":\\\\\"class\\\\\"}\"}', 'referer': '10.10.0.xxx', 'restOperationId': 57963195, 'errorStack': [], 'kind': ':resterrorresponse'}"}

- hosts: all
  collections:
    - f5networks.f5_bigip
  connection: httpapi

  vars:
    ansible_host: "10.10.0.xxx"
    ansible_user: "admin"
    ansible_httpapi_password: "xxxxx"
    ansible_network_os: f5networks.f5_bigip.bigiq
    ansible_httpapi_use_ssl: yes
    ansible_httpapi_validate_certs: no

  tasks:
    - name: Declaration test
      bigiq_as3_deploy:
        content: "{{ lookup('file', '1.json') }}"
        #service_type: "as3"
{
"applicationName": "O-E",
"appSvcsDeclaration": {
    "class": "AS3",
    "action": "deploy",
    "declaration": {
        "class": "ADC",
        "schemaVersion": "3.31.0",
        "target": {
            "address": "10.10.0.xxx"
        },
        "pco": {
            "class": "Tenant",
            "vip1_443": {
                "class": "Application",
                "template": "https",
                "serviceMain": {
                    "pool": {
                        "use": "pl_vip1_80"
                    },
                    "snat": "auto",
                    "enable": true,
                    "iRules": [
                        {
                            "use": "iRule_vip1_443"
                        }
                    ],
                    "remark": "lekker hoor",
                    "serverTLS": "clssl_vip1",
                    "profileTCP": {
                        "use": "tcp_vip1_443"
                    },
                    "virtualPort": 443,
                    "profileHTTP": {
                        "use": "http_vip1_443"
                    },
                    "virtualAddresses": [
                        "10.10.10.1"
                    ],
                    "persistenceMethods": [
                        {
                            "use": "sticky-default_vip1"
                        }
                    ],
                    "fallbackPersistenceMethod": {
                        "use": "sticky-fallback_vip1"
                    },
                    "serviceDownImmediateAction": "drop",
                    "class": "Service_HTTPS"
                },
                "mon_vip1_80": {
                    "send": "GET / HTTP/1.0\r\n\r\n",
                    "receive": "",
                    "receiveDown": "",
                    "class": "Monitor",
                    "monitorType": "http"
                },
                "pl_vip1_80": {
                    "members": [
                        {
                            "adminState": "enable",
                            "servicePort": 80,
                            "serverAddresses": [
                                "192.168.4.10"
                            ]
                        }
                    ],
                    "monitors": [
                        {
                            "use": "mon_vip1_80"
                        }
                    ],
                    "class": "Pool"
                },
                "iRule_vip1_443": {
                    "iRule": {
                        "text": "when HTTP_REQUEST { log local0. \"test irule\" }"
                    },
                    "class": "iRule"
                },
                "sticky-default_vip1": {
                    "persistenceMethod": "cookie",
                    "class": "Persist"
                },
                "sticky-fallback_vip1": {
                    "persistenceMethod": "source-address",
                    "class": "Persist"
                },
                "clssl_vip1": {
                    "certificates": [
                        {
                            "certificate": "crt_vip1"
                        }
                    ],
                    "class": "TLS_Server"
                },
                "crt_vip1": {
                    "privateKey": {
                        "bigip": "/Common/default.key"
                    },
                    "certificate": {
                        "bigip": "/Common/default.crt"
                    },
                    "class": "Certificate"
                },
                "tcp_vip1_443": {
                    "class": "TCP_Profile"
                },
                "http_vip1_443": {
                    "class": "HTTP_Profile"
                }
            }
        }
    }
}
}
rjouhann commented 2 years ago

Hello @Zjemm

If you are having a problem with the new Ansible Collection f5_bigip, I would recommend you to open up an issue here.

Thanks & Regards, Roman