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

bigip_vcmp_guest module always reports changed

Open jasonjuenger opened this issue 1 year ago • 4 comments

COMPONENT NAME

bigip_vcmp_guest

Environment

ANSIBLE VERSION
ansible-playbook [core 2.15.8]
  config file = /runner/project/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /runner/requirements_collections:/root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-playbook
  python version = 3.9.18 (main, Sep 22 2023, 17:58:34) [GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] (/usr/bin/python3.9)
  jinja version = 3.1.2
  libyaml = True
BIGIP VERSION
15.1.10.2 Build 0.44.2
CONFIGURATION

None

OS / ENVIRONMENT

Ansible Automation Platform, execution environment based on ansible-automation-platform-24/ee-supported-rhel8 image.

SUMMARY

bigip_vcmp_guest module reports changed even when no changes are made on the vCMP guest. This was verified by comparing configs pre- and post-run in both the GUI and API (mgmt/tm/vcmp/guest endpoint). Additionally, running multiple playbook runs in a row with identical vars reports changed on every run. This was tested against a vCMP guest deployed manually via the GUI.

STEPS TO REPRODUCE

Deploy a vCMP guest via the GUI with the settings shown in the Ansible task below, with the guest state set to 'deployed'. Once the guest has finished provisioning and has completed bootup set a hostname on the vCMP guest from the host system. Run the Ansible task below. Ansible will report changed on this and all future playbook runs even if no changes are made to the guest configuration.

- name: Provision vCMP guest
  bigip_vcmp_guest:
    provider: REDACTED
    name: "testguest01"
    mgmt_network: "bridged"
    mgmt_address: "10.0.1.10/23"
    mgmt_route: "10.0.0.1"
    initial_image: "BIGIP-15.1.10.2-0.0.2.iso"
    vlans: [
        "peer-net"
    ],
    cores_per_slot": 2,
    number_of_slots": 1,
    min_number_of_slots": 1,
    allowed_slots": [
        "1"
    ],
    state: "present",
    delete_virtual_disk: false,
    partition: "Common"
  delegate_to: localhost
  register: deploy_guest
EXPECTED RESULTS

After initial deployment of the guest subsequent playbook runs should return OK, not changed. Additionally, existing guests deployed via another method should return OK when matching variables are supplied to the module.

ACTUAL RESULTS

Playbook runs always report changed, even when variables are unchanged. GUI and API both show no changes to the guest between playbook runs.

{
  "allowed_slots": [
    "1"
  ],
  "changed": true,
  "invocation": {
    "module_args": {
      "provider": {
        "server": "REDACTED",
        "user": "REDACTED",
        "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
        "validate_certs": false,
        "server_port": 443,
        "transport": "rest",
        "timeout": null,
        "no_f5_teem": false,
        "auth_provider": null
      },
      "name": "testguest01",
      "mgmt_network": "bridged",
      "mgmt_address": "10.0.1.10/23",
      "mgmt_route": "10.0.0.1",
      "initial_image": "BIGIP-15.1.10.2-0.0.2.iso",
      "vlans": [
        "peer-net"
      ],
      "cores_per_slot": 2,
      "number_of_slots": 1,
      "min_number_of_slots": 1,
      "allowed_slots": [
        "1"
      ],
      "state": "present",
      "delete_virtual_disk": false,
      "partition": "Common",
      "initial_hotfix": null
    }
  },
  "_ansible_no_log": null,
  "_ansible_delegated_vars": {
    "ansible_host": "localhost",
    "ansible_port": null,
    "ansible_user": "REDACTED",
    "ansible_connection": "local"
  }
}

jasonjuenger avatar Mar 01 '24 19:03 jasonjuenger

After additional testing I have narrowed the issue down to the 'allowed_slots' parameter. If I leave that parameter undefined the task returns 'ok' as expected, even with all other parameters defined as above. If I add that parameter back in then the task returns 'changed' every time.

Edit: The issue appears to be the data type this module is expecting for allowed_slots (list of str) and what F5 expects (list of int). I tested casting the allowed_slots param to a list of int and now the module returns OK as expected. I will submit a PR to change the parameter type to list of int.

jasonjuenger avatar Mar 04 '24 18:03 jasonjuenger

Hi @jasonjuenger,

Thanks for the feedback.

Individuals or business entities who contribute to this project must complete and submit the F5 Contributor License Agreement to [email protected] prior to their code submission being included in this project.

pgouband avatar Mar 06 '24 09:03 pgouband

Hi @pgouband,

I will not be able to complete that form in a timely manner. I am OK if someone else that is already an approved contributor wishes to create a new PR with the same change.

The change I submitted changes the variable type, which could be a breaking change for some users. If there is no appetite to make that change there is another option to cast the existing value retrieved from the F5 for comparison (self.have.allowed_slots) to a list of str to match the input type. Something like

@property
def allowed_slots(self):
    if self.want.allowed_slots is None:
        return None
    if self.have.allowed_slots is None:
        return self.want.allowed_slots
    have_allowed_slots = [str(x) for x in self.have.allowed_slots]
    if set(self.want.allowed_slots) != set(have_allowed_slots):
        return self.want.allowed_slots

jasonjuenger avatar Mar 06 '24 19:03 jasonjuenger

HI @jasonjuenger,

Thanks but without the CLA we can't add your code in our project.

pgouband avatar Mar 26 '24 09:03 pgouband