nginxinc / ansible-role-nginx_controller_environment

Managing environments within NGINX Controller
Apache License 2.0
2 stars 1 forks source link

Conditional Check failed #15

Open mashoodakram opened 2 years ago

mashoodakram commented 2 years ago

Describe the bug

TASK [nginxinc.nginx_controller.nginx_controller_environment : create if environment is absent, update if present] *** failing with conditional check error after controller installs successfully.

To reproduce

Steps to reproduce the behaviour:

  1. As part of install of nginx collections after successful install of controller run environment role as task.

    - name: create environment
    hosts: role_nginx_controller_defraclouddev2
    gather_facts: no
    
    vars:
    nginx_controller_user_email: "xxxxxxx"
    nginx_controller_user_password: "xxxxxxxx"
    nginx_controller_fqdn: "nginx-controller2-dev.azure.defra.cloud"
    nginx_controller_validate_certs: false
    
    tasks:
    - name: Retrieve the NGINX Controller auth token
     include_role:
      name: nginxinc.nginx_controller.nginx_controller_generate_token
    
    - name: Configure the environment
     include_role:
      name: nginxinc.nginx_controller.nginx_controller_environment
     vars:
      nginx_controller_environment:
        metadata:
          name: "dev-sandbox2"
          displayName: "developer sandbox environment2"
          description: "sandbox environment for internal development2"
    
    tags:
    - create-environment
  2. See error

    2021-10-25T14:50:17.5158001Z TASK [nginxinc.nginx_controller.nginx_controller_environment : create if environment is absent, update if present] ***
    2021-10-25T14:50:17.5159052Z Monday 25 October 2021  14:50:17 +0000 (0:00:00.099)       0:12:32.759 ******** 
    2021-10-25T14:50:17.5160245Z Monday 25 October 2021  14:50:17 +0000 (0:00:00.099)       0:12:32.758 ******** 
    2021-10-25T14:50:17.9317312Z fatal: [SECNGXCTLSR1003]: FAILED! => {"msg": "The conditional check 'nginx_controller_environment_current_status.json.currentStatus.state.selfConfigState.isError | bool' failed. The error was: error while evaluating conditional (nginx_controller_environment_current_status.json.currentStatus.state.selfConfigState.isError | bool): 'dict object' has no attribute 'currentStatus'"}
    2021-10-25T14:50:17.9323107Z ...ignoring
    2021-10-25T14:50:17.9635823Z 
    2021-10-25T14:50:17.9637341Z TASK [nginxinc.nginx_controller.nginx_controller_environment : report failure details from Controller] ***
    2021-10-25T14:50:17.9638505Z Monday 25 October 2021  14:50:17 +0000 (0:00:00.447)       0:12:33.207 ******** 
    2021-10-25T14:50:17.9639498Z Monday 25 October 2021  14:50:17 +0000 (0:00:00.447)       0:12:33.206 ******** 
    2021-10-25T14:50:18.0202379Z fatal: [SECNGXCTLSR1003]: FAILED! => {"msg": "The conditional check 'nginx_controller_environment_current_status.json.currentStatus.state.selfConfigState.isError | bool' failed. The error was: error while evaluating conditional (nginx_controller_environment_current_status.json.currentStatus.state.selfConfigState.isError | bool): 'dict object' has no attribute 'json'\n\nThe error appears to be in '/ansibleagent/_work/1/s/collections/ansible_collections/nginxinc/nginx_controller/roles/nginx_controller_environment/tasks/main.yml': line 41, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n # above simply errors but does not include the informative failure messages from Controller\n- name: report failure details from Controller\n  ^ here\n"}

    Expected behavior

    Run role -name create environment after controller install then continue with steps defined in playbook - name: create location then agents tasks.

Your environment:

controller-installer-3.20.1.tar.gz remote controller Ubuntu 18.04.5 LTS Azure Database for PostgreSQL server PostgresSQL 9.6

ansible [core 2.11.4] config file = /etc/ansible/ansible.cfg configured module search path = ['/home/vmadmin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible ansible collection location = /home/vmadmin/.ansible/collections:/usr/share/ansible/collections executable location = /usr/local/bin/ansible python version = 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0] jinja version = 2.10 libyaml = True

Additional context

Add any other context about the problem here.

aknot242 commented 2 years ago

I am unable to reproduce your issue on Controller 3.20.1 using your given values. It is working for me. Can you please run the playbook with the -v option to see the response from the URI call at the create if environment is absent, update if present task?