Pure-Storage-Ansible / FlashArray-Collection

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

purestorage.flasharray.purefa_pg enabled snapshots or replication schedules #421

Closed jbe-dw closed 1 year ago

jbe-dw commented 1 year ago

Describe the bug Weither we configure a replication target or not, either snapshots schedule or replication schedule is enabled. If I use pgsched to disable both in a later task, the playbook alternate the setting on each run:

purefa_pg enables it purefa_pgsched disables it

To Reproduce

  1. Configure a task with a pg
  2. Configure a pgsched task with the schedules disabled
  3. Run the playbook multiple times
  4. See changes in both tasks on each run

Expected behavior Schedules should not be enabled

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

sdodsley commented 1 year ago

@jbe-dw please provide an example playbook for this issue.

jbe-dw commented 1 year ago
    - name: Ensure default protection group is up to date
      delegate_to: localhost
      run_once: true
      purestorage.flasharray.purefa_pg:
        fa_url: "{{ item.url }}"
        api_token: "{{ item.token }}"
        name: "backup-{{ env }}"
        target: >-
          {{
            ['Purestor-02-aub'] if item.name != "aub-02" else omit
          }}
        volume: "{{ filtered_pure_untagged_volumes[item.name] }}"
      loop:
        - name: aub-01
          url: pure-aub-01.local
          token: secret
        - name: aub-02
          url: pure-aub-02.local
          token: secret
      loop_control:
        label: "{{ item.name }}"

    - name: Ensure default protection group schedule is up to date (snapshots)
      delegate_to: localhost
      run_once: true
      purestorage.flasharray.purefa_pgsched:
        fa_url: "{{ item.url }}"
        api_token: "{{ item.token }}"
        name: "backup-{{ env }}"
        schedule: snapshot
        enabled: false
        snap_frequency: 86440
        snap_at: 12:00:00
        all_for: "{{ 7 * 24 * 3600 }}"
        per_day: 0
        days: 0
      loop:
        - name: aub-01
          url: pure-aub-01.local
          token: secret
        - name: aub-02
          url: pure-aub-02.local
          token: secret
      loop_control:
        label: "{{ item.name }}"

    - name: Ensure default protection group schedule is up to date (replication)
      delegate_to: localhost
      run_once: true
      purestorage.flasharray.purefa_pgsched:
        fa_url: "{{ item.url }}"
        api_token: "{{ item.token }}"
        name: "backup-{{ env }}"
        schedule: replication
        enabled: false
        replicate_frequency: "{{ 24 * 3600 }}"
        target_all_for: "{{ 7 * 24 * 3600 }}"
        target_per_day: 0
        target_days: 0
      loop:
        - name: aub-01
          url: pure-aub-01.local
          token: secret
        - name: aub-02
          url: pure-aub-02.local
          token: secret
      loop_control:
        label: "{{ item.name }}"
      when: item.name != 'aub-02'
jbe-dw commented 1 year ago
TASK [Ensure default protection group is up to date] *****************************************************************
changed: [host -> localhost] => (item=aub-01)              <- enables replication (with target)
changed: [host -> localhost] => (item=aub-02)              <- enables snapshots (no target)

TASK [Ensure default protection group schedule is up to date (snapshots)] ****************************************
ok: [host -> localhost] => (item=aub-01)                       <- ok snapshots still disabled
changed: [host -> localhost] => (item=aub-02)             <- disables snapshots

TASK [Ensure default protection group schedule is up to date (replication)] ****************************************
changed: [host -> localhost] => (item=aub-01)             <- disables replication
skipping: [host] => (item=aub02)                                  <- replication not set, never enabled
sdodsley commented 1 year ago

Thanks - I'll take a look a this shortly.

sdodsley commented 1 year ago

@jbe-dw please see if #422 resolves the issue

jbe-dw commented 1 year ago

it looks to me that furefa_pg is enabling snapshots schedule (if no target is added) or replication schedule (if target is added). Doing so, purefa_pgsched does its job by re-disabling them.

With your patch, schedules stays enabled when they are set to be disabled, not respecting the parameter.

jbe-dw commented 1 year ago

Note that there is no parameter for schedules in purefa_pg

sdodsley commented 1 year ago

@jbe-dw the is an enabled parameter in purefa_pg which defaults to true. what happens if you set this to false in the first task?

jbe-dw commented 1 year ago

Damn it it was there and my brain completely hide it to my sight.

I'd say that we can do whatever we want by correctly setting purefa_pg and purefa_pgsched's enabled parameter (But I'd suggest that you add a small sentence on this parameter for purefa_pg in the doc, stating that it will act on snapshots schedule if no replication target is set or on replication schedule if at least one is set).

A better option could be to change the parameter to "snapshots/replication/both" but it's not for a bug anymore.

Thank you for your time !