ansible-collections / community.vmware

Ansible Collection for VMware
GNU General Public License v3.0
348 stars 341 forks source link

vmware_vspan_session module is not idempotent #1404

Open Exerti0n opened 2 years ago

Exerti0n commented 2 years ago
SUMMARY

When attempting to create a new vspan session subsequent runs will create an identically named rule, End goal for me personally was to allow multiple destination_vms to be defined but this does not appear to be possible currently.

ISSUE TYPE
COMPONENT NAME

community.vmware.vmware_vspan_session

ANSIBLE VERSION
ansible [core 2.11.9] 
  config file = /home/xxx/projects/ansible-mn/ansible.cfg
  configured module search path = [u'/home/xxx/projects/ansible-mn/library']
  ansible python module location = /home/xxx/.local/lib/python2.7/site-packages/ansible
  ansible collection location = /home/xxx/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/xxx/.local/bin/ansible
  python version = 2.7.15+ (default, Oct  7 2019, 17:39:04) [GCC 7.4.0]
  jinja version = 2.10
  libyaml = True
COLLECTION VERSION
# /home/xxx/.local/lib/python2.7/site-packages/ansible_collections
Collection       Version
---------------- -------
community.vmware 1.17.0 
CONFIGURATION
CACHE_PLUGIN(/home/xxx/projects/ansible-mn/ansible.cfg) = memory
DEFAULT_ACTION_PLUGIN_PATH(/home/xxx/projects/ansible-mn/ansible.cfg) = [u'/home/xxx/projects/ansible-mn/plugins/action']
DEFAULT_CALLBACK_PLUGIN_PATH(/home/xxx/projects/ansible-mn/ansible.cfg) = [u'/home/xxx/projects/ansible-mn/plugins/callback']
DEFAULT_CONNECTION_PLUGIN_PATH(/home/xxx/projects/ansible-mn/ansible.cfg) = [u'/home/xxx/projects/ansible-mn/plugins/connection']
DEFAULT_FILTER_PLUGIN_PATH(/home/xxx/projects/ansible-mn/ansible.cfg) = [u'/home/xxx/projects/ansible-mn/plugins/filter']
DEFAULT_GATHERING(/home/xxx/projects/ansible-mn/ansible.cfg) = smart
DEFAULT_HOST_LIST(/home/xxx/projects/ansible-mn/ansible.cfg) = [u'/home/xxx/projects/ansible-mn/inventory']
DEFAULT_LOAD_CALLBACK_PLUGINS(/home/xxx/projects/ansible-mn/ansible.cfg) = False
DEFAULT_LOOKUP_PLUGIN_PATH(/home/xxx/projects/ansible-mn/ansible.cfg) = [u'/home/xxx/projects/ansible-mn/plugins/lookup']
DEFAULT_MANAGED_STR(/home/xxx/projects/ansible-mn/ansible.cfg) = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}
DEFAULT_MODULE_NAME(/home/xxx/projects/ansible-mn/ansible.cfg) = shell
DEFAULT_MODULE_PATH(/home/xxx/projects/ansible-mn/ansible.cfg) = [u'/home/xxx/projects/ansible-mn/library']
DEFAULT_POLL_INTERVAL(/home/xxx/projects/ansible-mn/ansible.cfg) = 15
DEFAULT_ROLES_PATH(/home/xxx/projects/ansible-mn/ansible.cfg) = [u'/home/xxx/projects/ansible-mn/roles']
DEFAULT_TIMEOUT(/home/xxx/projects/ansible-mn/ansible.cfg) = 10
DEFAULT_TRANSPORT(/home/xxx/projects/ansible-mn/ansible.cfg) = smart
DEFAULT_VARS_PLUGIN_PATH(/home/xxx/projects/ansible-mn/ansible.cfg) = [u'/home/xxx/projects/ansible-mn/plugins/vars']
DISPLAY_SKIPPED_HOSTS(/home/xxx/projects/ansible-mn/ansible.cfg) = True
HOST_KEY_CHECKING(/home/xxx/projects/ansible-mn/ansible.cfg) = False
INVENTORY_ENABLED(/home/xxx/projects/ansible-mn/ansible.cfg) = [u'generator', u'ini']
RETRY_FILES_ENABLED(/home/xxx/projects/ansible-mn/ansible.cfg) = False
OS / ENVIRONMENT

ESXi version 6.7

STEPS TO REPRODUCE

Run the below playbook with the requirements of this collection installed. Requires a DVS and a VM with the correct nic label within the targeted vcenter.

- name: Create Port Mirroring - remoteMirrorDest
  hosts: localhost
  connection: local
  vars_prompt:
    - name: ldap_password
      prompt: Please enter your credentials
  tasks:
  - community.vmware.vmware_vspan_session:
      hostname: "{{ vcenter_hostname }}"
      username: xxx
      password: "{{ ldap_password }}"
      validate_certs: no
      name: "Mirror - TEST "
      description: Mirroring configuration - TEST
      state: present
      enabled: no
      normal_traffic_allowed: yes
      sampling_rate: 1
      session_type: remoteMirrorDest
      switch: "DVS-LT"
      destination_vm:
        name: TEST_VM
        nic_label: "Network adapter 1"
EXPECTED RESULTS

Running this should produce a port mirror on the identified switch, running this subsequent times with no changes should not create additional identically named rules. I would also like to know how it would be possible to add multiple destination_vm's

ACTUAL RESULTS

Another identically named rule is configured every subsequent run.

Exerti0n commented 2 years ago

I'd also like to mention that the "Source" is confusing? How can I specify a VLAN for this?

Thanks!