ansible-collections / netapp.ontap

Ansible collection to support NetApp ONTAP configuration.
https://galaxy.ansible.com/netapp/ontap
GNU General Public License v3.0
56 stars 36 forks source link

na_ontap_info job schedule error with ontap 9.1 #54

Closed tardfree closed 2 years ago

tardfree commented 2 years ago

Summary

Very basic playbook, calling na_ontap_info with no gather_subsets fails on job schedules with ontap 9.1. Documentation for this module says supported for ontap 9.1 onwards. Using gather_subset to exclude job_schedule_cron_info does work, so the issue is minor and isolated.

I totally understand that this is not likely worth the effort to fix due to 9.1 being way out of support - perhaps just document it.

This problem is likely caused by cron jobs moving from outside into a cluster vserver. Example cli outputs to highlight this: Ontap 9.1

cluster91::> cron show
  (job schedule cron show)
Name                Description
----------------    -----------------------------------------------------
4hour               @0:13,4:13,8:13,12:13,16:13,20:13
5min                @:00,:05,:10,:15,:20,:25,:30,:35,:40,:45,:50,:55
8hour               @2:15,10:15,18:15
daily               @0:10
hourly              @:05
weekly              Sun@0:15
6 entries were displayed.

Ontap 9.7 (has the cluster column in the table)

cluster97::> cron show
  (job schedule cron show)
Cluster       Name        Description
------------- ----------- -----------------------------------------------------
cluster97
              5min        @:00,:05,:10,:15,:20,:25,:30,:35,:40,:45,:50,:55
              8hour       @2:15,10:15,18:15
              daily       @0:10
              hourly      @:05
              monthly     1@0:20
<snip as cluster has way more schedules by default>

Component Name

na_ontap_info

Ansible Version

$ ansible --version
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.8 (default, Aug 13 2020, 07:46:32) [GCC 4.8.5 20150623 (Red Hat
 4.8.5-39)]. This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
ansible [core 2.11.9]
  config file = /home/myuseraccount/netapp-test/ansible.cfg
  configured module search path = ['/home/myuseraccount/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/myuseraccount/venvs/vmware-netapp/lib64/python3.6/site-packages/ansible
  ansible collection location = /home/myuseraccount/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/myuseraccount/venvs/vmware-netapp/bin/ansible
  python version = 3.6.8 (default, Aug 13 2020, 07:46:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
  jinja version = 3.0.3
  libyaml = True

ONTAP Collection Version

$ ansible-galaxy collection list
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.8 (default, Aug 13 2020, 07:46:32) [GCC 4.8.5 20150623 (Red Hat
 4.8.5-39)]. This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

# /home/myuseraccount/venvs/vmware-netapp/lib64/python3.6/site-packages/ansible_collections
Collection                    Version
----------------------------- -------
amazon.aws                    1.5.1
ansible.netcommon             2.5.0
ansible.posix                 1.3.0
ansible.utils                 2.4.3
ansible.windows               1.8.0
arista.eos                    2.2.0
awx.awx                       19.4.0
azure.azcollection            1.10.0
check_point.mgmt              2.2.0
chocolatey.chocolatey         1.1.0
cisco.aci                     2.1.0
cisco.asa                     2.1.0
cisco.intersight              1.0.18
cisco.ios                     2.6.0
cisco.iosxr                   2.6.0
cisco.meraki                  2.5.0
cisco.mso                     1.2.0
cisco.nso                     1.0.3
cisco.nxos                    2.8.2
cisco.ucs                     1.6.0
cloudscale_ch.cloud           2.2.0
community.aws                 1.5.0
community.azure               1.1.0
community.crypto              1.9.8
community.digitalocean        1.13.0
community.docker              1.10.2
community.fortios             1.0.0
community.general             3.8.3
community.google              1.0.0
community.grafana             1.3.0
community.hashi_vault         1.5.0
community.hrobot              1.2.1
community.kubernetes          1.2.1
community.kubevirt            1.0.0
community.libvirt             1.0.2
community.mongodb             1.3.2
community.mysql               2.3.2
community.network             3.0.0
community.okd                 1.1.2
community.postgresql          1.6.0
community.proxysql            1.3.0
community.rabbitmq            1.1.0
community.routeros            1.2.0
community.skydive             1.0.0
community.sops                1.2.0
community.vmware              1.17.0
community.windows             1.8.0
community.zabbix              1.5.1
containers.podman             1.9.0
cyberark.conjur               1.1.0
cyberark.pas                  1.0.13
dellemc.enterprise_sonic      1.1.0
dellemc.openmanage            3.6.0
dellemc.os10                  1.1.1
dellemc.os6                   1.0.7
dellemc.os9                   1.0.4
f5networks.f5_modules         1.13.0
fortinet.fortimanager         2.1.4
fortinet.fortios              2.1.3
frr.frr                       1.0.3
gluster.gluster               1.0.2
google.cloud                  1.0.2
hetzner.hcloud                1.6.0
hpe.nimble                    1.1.4
ibm.qradar                    1.0.3
infinidat.infinibox           1.3.0
inspur.sm                     1.3.0
junipernetworks.junos         2.8.0
kubernetes.core               1.2.1
mellanox.onyx                 1.0.0
netapp.aws                    21.7.0
netapp.azure                  21.10.0
netapp.cloudmanager           21.12.1
netapp.elementsw              21.7.0
netapp.ontap                  21.14.1
netapp.um_info                21.8.0
netapp_eseries.santricity     1.2.13
netbox.netbox                 3.4.0
ngine_io.cloudstack           2.2.2
ngine_io.exoscale             1.0.0
ngine_io.vultr                1.1.0
openstack.cloud               1.5.3
openvswitch.openvswitch       2.1.0
ovirt.ovirt                   1.6.6
purestorage.flasharray        1.11.0
purestorage.flashblade        1.8.1
sensu.sensu_go                1.12.0
servicenow.servicenow         1.0.6
splunk.es                     1.0.2
t_systems_mms.icinga_director 1.26.0
theforeman.foreman            2.2.0
vyos.vyos                     2.6.0
wti.remote                    1.0.3

# /home/myuseraccount/.ansible/collections/ansible_collections
Collection       Version
---------------- -------
community.vmware 2.1.0
netapp.ontap     21.17.3

# /home/myuseraccount/venvs/vmware-netapp/lib/python3.6/site-packages/ansible_collections
Collection                    Version
----------------------------- -------
amazon.aws                    1.5.1
ansible.netcommon             2.5.0
ansible.posix                 1.3.0
ansible.utils                 2.4.3
ansible.windows               1.8.0
arista.eos                    2.2.0
awx.awx                       19.4.0
azure.azcollection            1.10.0
check_point.mgmt              2.2.0
chocolatey.chocolatey         1.1.0
cisco.aci                     2.1.0
cisco.asa                     2.1.0
cisco.intersight              1.0.18
cisco.ios                     2.6.0
cisco.iosxr                   2.6.0
cisco.meraki                  2.5.0
cisco.mso                     1.2.0
cisco.nso                     1.0.3
cisco.nxos                    2.8.2
cisco.ucs                     1.6.0
cloudscale_ch.cloud           2.2.0
community.aws                 1.5.0
community.azure               1.1.0
community.crypto              1.9.8
community.digitalocean        1.13.0
community.docker              1.10.2
community.fortios             1.0.0
community.general             3.8.3
community.google              1.0.0
community.grafana             1.3.0
community.hashi_vault         1.5.0
community.hrobot              1.2.1
community.kubernetes          1.2.1
community.kubevirt            1.0.0
community.libvirt             1.0.2
community.mongodb             1.3.2
community.mysql               2.3.2
community.network             3.0.0
community.okd                 1.1.2
community.postgresql          1.6.0
community.proxysql            1.3.0
community.rabbitmq            1.1.0
community.routeros            1.2.0
community.skydive             1.0.0
community.sops                1.2.0
community.vmware              1.17.0
community.windows             1.8.0
community.zabbix              1.5.1
containers.podman             1.9.0
cyberark.conjur               1.1.0
cyberark.pas                  1.0.13
dellemc.enterprise_sonic      1.1.0
dellemc.openmanage            3.6.0
dellemc.os10                  1.1.1
dellemc.os6                   1.0.7
dellemc.os9                   1.0.4
f5networks.f5_modules         1.13.0
fortinet.fortimanager         2.1.4
fortinet.fortios              2.1.3
frr.frr                       1.0.3
gluster.gluster               1.0.2
google.cloud                  1.0.2
hetzner.hcloud                1.6.0
hpe.nimble                    1.1.4
ibm.qradar                    1.0.3
infinidat.infinibox           1.3.0
inspur.sm                     1.3.0
junipernetworks.junos         2.8.0
kubernetes.core               1.2.1
mellanox.onyx                 1.0.0
netapp.aws                    21.7.0
netapp.azure                  21.10.0
netapp.cloudmanager           21.12.1
netapp.elementsw              21.7.0
netapp.ontap                  21.14.1
netapp.um_info                21.8.0
netapp_eseries.santricity     1.2.13
netbox.netbox                 3.4.0
ngine_io.cloudstack           2.2.2
ngine_io.exoscale             1.0.0
ngine_io.vultr                1.1.0
openstack.cloud               1.5.3
openvswitch.openvswitch       2.1.0
ovirt.ovirt                   1.6.6
purestorage.flasharray        1.11.0
purestorage.flashblade        1.8.1
sensu.sensu_go                1.12.0
servicenow.servicenow         1.0.6
splunk.es                     1.0.2
t_systems_mms.icinga_director 1.26.0
theforeman.foreman            2.2.0
vyos.vyos                     2.6.0
wti.remote                    1.0.3

ONTAP Version

cluster91::> version
NetApp Release 9.1P20: Mon Oct 28 14:37:28 UTC 2019

Playbook

- hosts: localhost
  gather_facts: false
  collections:
    - netapp.ontap
  vars:
    login: &login
      hostname: ""
      username: ""
      password: ""
      https: true
      validate_certs: false
  tasks:
    - name: Gather info about everything
      netapp.ontap.na_ontap_info:
#        gather_subset:
#          - "!job_schedule_cron_info"
# excluding job_schedule_cron_info the task succeeds
        <<: *login
      register: ontap_gather

Steps to Reproduce

Playbook has hardcoded host/username/password as it's very basic.

ansible-playbook play.yml -vvv

Expected Results

The module should run without exception and register the results in the named variable. Excluding a subset shouldn't be required to work.

Running against a cluster running 9.5 or 9.7 works without issue. I don't have a 9.3 cluster to test with to see if that works.

Actual Results

Traceback from task output run with -vvv

The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_netapp.ontap.na_ontap_info_payload_c6ufzq4j/ansible_netapp.ontap.na_ontap_info_payload.zip/ansible_collections/netapp/ontap/plugins/modules/na_ontap_info.py", line 1527, in gt_generic_get_iter
  File "/tmp/ansible_netapp.ontap.na_ontap_info_payload_c6ufzq4j/ansible_netapp.ontap.na_ontap_info_payload.zip/ansible_collections/netapp/ontap/plugins/modules/na_ontap_info.py", line 1527, in <istcomp>
  File "/tmp/ansible_netapp.ontap.na_ontap_info_payload_c6ufzq4j/ansible_netapp.ontap.na_ontap_info_payload.zip/ansible_collections/netapp/ontap/plugins/modules/na_ontap_info.py", line 1739, in _inditem
KeyError: 'job-schedule-cluster'
fatal: [cluster91]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "cert_filepath": null,
            "continue_on_error": [
                "never"
            ],
            "desired_attributes": null,
            "feature_flags": {},
            "gather_subset": [
                "all"
            ],
            "hostname": "cluster91",
            "http_port": null,
            "https": true,
            "key_filepath": null,
            "max_records": 1024,
            "ontapi": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "query": null,
            "state": null,
            "summary": false,
            "use_native_zapi_tags": false,
            "use_rest": "auto",
            "username": "admin",
            "validate_certs": false,
            "volume_move_target_aggr_info": null,
            "vserver": null
        }
    },
    "msg": "Error: key 'job-schedule-cluster' not found for job-schedule-cron-get-iter, got: {'job_schedule_cron_hour': {'cron_hour': ['0', '4', '8', '12', '16', '20']}, 'job_schedule_cron_minute: {'cron_minute': '13'}, 'job_schedule_description': '@0:13,4:13,8:13,12:13,16:13,20:13', 'job_schedule_name': '4hour'}"
}
carchi8py commented 2 years ago

I'll need to talk with the rest of the team, but I'm not sure we'll have a fix for this. It look like key 'job-schedule-cluster' was added to the zapi job-schedule-cron-get-iter sometime after 9.1

But @tardfree if you really need this to work, what you can do in your local copy is in this file, remove 'job-schedule-cluster' from the 'key_fields'. https://github.com/ansible-collections/netapp.ontap/blob/main/plugins/modules/na_ontap_info.py#L1053 that should fix the error above for you 'job-schedule-cluster'.

carchi8py commented 2 years ago

So were going to fix this for the next version as it an easy fix. We have an internal story DEVOPS-4804 to track this

tardfree commented 2 years ago

Thank you that's great. For my purposes I'm just excluding it with gather_subset "!job_schedule_cron_info" until I can upgrade all my remaining 9.1 systems (apart from any FAS2240 stuck on 9.1 of course).

carchi8py commented 2 years ago

@tardfree the fix for this has been merged in. It will be part of 21.18.0 release, which is expected on April 6th.

I'll leave this story open until then.

lonico commented 2 years ago

fixed in 21.18.0