Pure-Storage-Ansible / FlashArray-Collection

Ansible Collection for Pure Storage FlashArray
GNU General Public License v3.0
18 stars 23 forks source link

purefa_hg not idempotent #84

Closed coreywan closed 4 years ago

coreywan commented 4 years ago

Describe the bug In the collection version 1.2.3, purefa_hg doesn't appear to be idempotent.

To Reproduce Steps to reproduce the behavior:

Inventory:

[purefa]
purefa1.lab.local

group_var:

pure_api_token: hidden
pure_hosts_iscsi:
  esxi1:
    iqn: iqn.1998-01.com.vmware:esxi1-2bef2660
    personality: esxi
  esxi2: 
    iqn: iqn.1998-01.com.vmware:esxi2-2ce296a0
    personality: esxi
  esxi3:
    iqn: iqn.1998-01.com.vmware:esxi3-28f0242c
    personality: esxi
  winsrv01:
    iqn: iqn.1991-05.com.microsoft:winsrv01.lab.local
  winsrv02:
    iqn: iqn.1991-05.com.microsoft:winsrv02.lab.local

pure_host_groups:
  lab:
    - esxi1
    - esxi2
    - esxi3
  winsrv:
    - winsrv01
    - winsrv02

Playbook:

- hosts: purefa
  gather_facts: false
  tasks:
    - name: Configure iSCSI Hosts
      delegate_to: localhost
      loop: "{{ pure_hosts_iscsi | dict2items }}"
      purestorage.flasharray.purefa_host:
        fa_url: "{{ inventory_hostname }}"
        api_token: "{{ pure_api_token }}"
        host: "{{ item.key }}"
        iqn: "{{ item.value.iqn }}"
        personality: "{{ item.value.personality | default(omit) }}"

    - name: Configure Host Groups
      delegate_to: localhost
      loop: "{{ pure_host_groups | dict2items }}"
      purestorage.flasharray.purefa_hg:
        fa_url: "{{ inventory_hostname }}"
        api_token: "{{ pure_api_token }}"
        hostgroup: "{{ item.key }}"
        host: "{{ item.value }}"

Expected behavior Second run of the playbook shouldn't invoke a change.

Desktop (please complete the following information):

sdodsley commented 4 years ago

I think the issue you are seeing is that each time purefa_hg runs it does a compare of the existing hosts to the list of hosts provided in the play. In your case this will always be seen as a change because you are looping through the hosts one at a time. We'll have to see if we can recode for this use case. I'll have a dig into this now

sdodsley commented 4 years ago

@coreywan OK - yep - I see the problem - I'll work on a fix

sdodsley commented 4 years ago

Addressed in #88

sdodsley commented 4 years ago

Resolved and fix in Collection 1.2.7 (available immediately on Ansible Galaxy - AAE will take longer to release the new release)