f5-ansible icon indicating copy to clipboard operation
f5-ansible copied to clipboard

bigip_gtm_server in CHECK mode does not verify datacenter existence

Open pbystrov opened this issue 1 year ago • 1 comments

COMPONENT NAME

bigip_gtm_server

Environment

ANSIBLE VERSION
ansible [core 2.15.12]
  config file = /home/pbystrov-a/.ansible.cfg
  configured module search path = ['/home/pbystrov-a/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/pbystrov-a/venv/f5/lib/python3.9/site-packages/ansible
  ansible collection location = /home/pbystrov-a/.ansible/collections
  executable location = /home/pbystrov-a/venv/f5/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] (/home/pbystrov-a/venv/f5/bin/python3)
  jinja version = 3.1.4
  libyaml = True
BIGIP VERSION
Sys::Version
Main Package
  Product     BIG-IP
  Version     17.1.1.3
  Build       0.0.5
  Edition     Point Release 3
  Date        Thu Mar 21 04:23:27 PDT 2024
CONFIGURATION
OS / ENVIRONMENT

N/A

SUMMARY

bigip_gtm_server in CHECK mode does not verify datacenter existence (re-opening #1976)

STEPS TO REPRODUCE
ansible-playbook playbooks/bigip-gtm-bug.yml --check --diff -v
---
- name: Reproduce bigip_gtm_server check mode
  hosts: localhost
  strategy: free
  gather_facts: no
  vars:
    provider:
      server: "{{ lookup('env', 'F5_GTM_HOST') }}"
      transport: rest
      user: "{{ lookup('env', 'F5_GTM_USER') }}"
      password: "{{ lookup('env', 'F5_GTM_PASSWORD') }}"
      validate_certs: no
      no_f5_teem: true

  tasks:
    - name: Create server(s)
      f5networks.f5_modules.bigip_gtm_server:
        provider: "{{ provider }}"
        name: TEST-SERVER
        server_type: generic-host
        devices:
          - name: TEST-SERVER
            address: "1.1.1.1"
        datacenter: NON-EXISTENT-DC
        monitors:
          - gateway_icmp
        prober_preference: inherit
        prober_fallback: any
        state: present
      delegate_to: localhost
EXPECTED RESULTS

I expect this task to fail check mode with 'Datacenter does not exist' error

ACTUAL RESULTS
$ ansible-playbook playbooks/bigip-gtm-bug.yml --check --diff -v
Using /home/pbystrov-a/.ansible.cfg as config file
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [Reproduce bigip_gtm_server check mode] *********************************************************************

TASK [Create server(s)] ******************************************************************************************
changed: [localhost] => changed=true
  availability_requirements:
    at_least: null
    number_of_probers: null
    number_of_probes: null
    type: all
  datacenter: /Common/NON-EXISTENT-DC
  devices:
  - deviceName: TEST-SERVER
    name: 1.1.1.1
    translation: none
  enabled: true
  link_discovery: disabled
  monitors:
  - /Common/gateway_icmp
  prober_fallback: any
  prober_preference: inherit
  server_type: generic-host
  virtual_server_discovery: disabled

PLAY RECAP *******************************************************************************************************
localhost                  : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
$ ansible-playbook playbooks/bigip-gtm-bug.yml --diff -v
Using /home/pbystrov-a/.ansible.cfg as config file
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [Reproduce bigip_gtm_server check mode] *********************************************************************

TASK [Create server(s)] ******************************************************************************************
fatal: [localhost]: FAILED! => changed=false
  msg: 'b''{"code":400,"message":"01070189:3: Server /Common/TEST-SERVER refers to a data center
  (/Common/NON-EXISTENT-DC) that does not exist","errorStack":[],"apiError":3}'''

PLAY RECAP *******************************************************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

pbystrov avatar Sep 17 '24 09:09 pbystrov

Hi,

Thanks for reporting. Reopening internal tracking ID for this request is: INFRAANO-227.

pgouband avatar Sep 23 '24 12:09 pgouband