Pure-Storage-Ansible / FlashBlade-Collection

Ansible Collection for Pure Storage FlashBlade
GNU General Public License v3.0
3 stars 8 forks source link

purefb_policy module always report change without timezone parameter #98

Closed mahendra-maplelabs closed 4 years ago

mahendra-maplelabs commented 4 years ago

Describe the bug purefb_policy module always report change when timezone parameter not set and also It is not setting system timezone.

To Reproduce Steps to reproduce the behavior:

  1. Run sample playbook
  2. See the policy created on FlashBlade, timezone is not set.
  3. Run again and it will report changed without any change in policy on FB.

Sample Playbook

- name: Pure Storage Policy example
  hosts: localhost
  gather_facts: no
  collections:
  - purestorage.flashblade
  tasks:
    - name: Create daily policy with rules
      purefb_policy:
        name: daily
        at: 11AM
        keep_for: 86400
        every: 86400
        # timezone: America/Los_Angeles
        fb_url: 10.xx.xxx.151
        api_token: T-0b8ad89c-xxx-xxxx-xxxx-286607dc2cd2

Output

TASK [Create daily policy with rules] ********************************************************************************************
task path: /home/mahendra/Projects/Purestorage/pure-ansible/cleanitup/sample.yml:7
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: mahendra
<127.0.0.1> EXEC /bin/sh -c 'echo ~mahendra && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/mahendra/.ansible/tmp `"&& mkdir "` echo /home/mahendra/.ansible/tmp/ansible-tmp-1602133735.2303548-22036-145411506843059 `" && echo ansible-tmp-1602133735.2303548-22036-145411506843059="` echo /home/mahendra/.ansible/tmp/ansible-tmp-1602133735.2303548-22036-145411506843059 `" ) && sleep 0'
Including module_utils file ansible/__init__.py
Including module_utils file ansible/module_utils/__init__.py
Including module_utils file ansible/module_utils/basic.py
Including module_utils file ansible/module_utils/_text.py
Including module_utils file ansible/module_utils/common/_collections_compat.py
Including module_utils file ansible/module_utils/common/__init__.py
Including module_utils file ansible/module_utils/common/_json_compat.py
Including module_utils file ansible/module_utils/common/_utils.py
Including module_utils file ansible/module_utils/common/file.py
Including module_utils file ansible/module_utils/common/parameters.py
Including module_utils file ansible/module_utils/common/collections.py
Including module_utils file ansible/module_utils/common/process.py
Including module_utils file ansible/module_utils/common/sys_info.py
Including module_utils file ansible/module_utils/common/text/converters.py
Including module_utils file ansible/module_utils/common/text/__init__.py
Including module_utils file ansible/module_utils/common/text/formatters.py
Including module_utils file ansible/module_utils/common/validation.py
Including module_utils file ansible/module_utils/common/warnings.py
Including module_utils file ansible/module_utils/compat/selectors.py
Including module_utils file ansible/module_utils/compat/__init__.py
Including module_utils file ansible/module_utils/compat/_selectors2.py
Including module_utils file ansible/module_utils/distro/__init__.py
Including module_utils file ansible/module_utils/distro/_distro.py
Including module_utils file ansible/module_utils/facts/utils.py
Including module_utils file ansible/module_utils/facts/__init__.py
Including module_utils file ansible/module_utils/facts/compat.py
Including module_utils file ansible/module_utils/facts/ansible_collector.py
Including module_utils file ansible/module_utils/facts/collector.py
Including module_utils file ansible/module_utils/facts/default_collectors.py
Including module_utils file ansible/module_utils/facts/hardware/aix.py
Including module_utils file ansible/module_utils/facts/hardware/__init__.py
Including module_utils file ansible/module_utils/facts/hardware/base.py
Including module_utils file ansible/module_utils/facts/hardware/darwin.py
Including module_utils file ansible/module_utils/facts/hardware/dragonfly.py
Including module_utils file ansible/module_utils/facts/hardware/freebsd.py
Including module_utils file ansible/module_utils/facts/hardware/hpux.py
Including module_utils file ansible/module_utils/facts/hardware/hurd.py
Including module_utils file ansible/module_utils/facts/hardware/linux.py
Including module_utils file ansible/module_utils/facts/hardware/netbsd.py
Including module_utils file ansible/module_utils/facts/hardware/openbsd.py
Including module_utils file ansible/module_utils/facts/hardware/sunos.py
Including module_utils file ansible/module_utils/facts/namespace.py
Including module_utils file ansible/module_utils/facts/network/aix.py
Including module_utils file ansible/module_utils/facts/network/__init__.py
Including module_utils file ansible/module_utils/facts/network/base.py
Including module_utils file ansible/module_utils/facts/network/darwin.py
Including module_utils file ansible/module_utils/facts/network/dragonfly.py
Including module_utils file ansible/module_utils/facts/network/fc_wwn.py
Including module_utils file ansible/module_utils/facts/network/freebsd.py
Including module_utils file ansible/module_utils/facts/network/generic_bsd.py
Including module_utils file ansible/module_utils/facts/network/hpux.py
Including module_utils file ansible/module_utils/facts/network/hurd.py
Including module_utils file ansible/module_utils/facts/network/iscsi.py
Including module_utils file ansible/module_utils/facts/network/linux.py
Including module_utils file ansible/module_utils/facts/network/netbsd.py
Including module_utils file ansible/module_utils/facts/network/nvme.py
Including module_utils file ansible/module_utils/facts/network/openbsd.py
Including module_utils file ansible/module_utils/facts/network/sunos.py
Including module_utils file ansible/module_utils/facts/other/facter.py
Including module_utils file ansible/module_utils/facts/other/__init__.py
Including module_utils file ansible/module_utils/facts/other/ohai.py
Including module_utils file ansible/module_utils/facts/sysctl.py
Including module_utils file ansible/module_utils/facts/system/apparmor.py
Including module_utils file ansible/module_utils/facts/system/__init__.py
Including module_utils file ansible/module_utils/facts/system/caps.py
Including module_utils file ansible/module_utils/facts/system/chroot.py
Including module_utils file ansible/module_utils/facts/system/cmdline.py
Including module_utils file ansible/module_utils/facts/system/date_time.py
Including module_utils file ansible/module_utils/facts/system/distribution.py
Including module_utils file ansible/module_utils/facts/system/dns.py
Including module_utils file ansible/module_utils/facts/system/env.py
Including module_utils file ansible/module_utils/facts/system/fips.py
Including module_utils file ansible/module_utils/facts/system/local.py
Including module_utils file ansible/module_utils/facts/system/lsb.py
Including module_utils file ansible/module_utils/facts/system/pkg_mgr.py
Including module_utils file ansible/module_utils/facts/system/platform.py
Including module_utils file ansible/module_utils/facts/system/python.py
Including module_utils file ansible/module_utils/facts/system/selinux.py
Including module_utils file ansible/module_utils/facts/system/service_mgr.py
Including module_utils file ansible/module_utils/facts/system/ssh_pub_keys.py
Including module_utils file ansible/module_utils/facts/system/user.py
Including module_utils file ansible/module_utils/facts/timeout.py
Including module_utils file ansible/module_utils/facts/virtual/base.py
Including module_utils file ansible/module_utils/facts/virtual/__init__.py
Including module_utils file ansible/module_utils/facts/virtual/dragonfly.py
Including module_utils file ansible/module_utils/facts/virtual/freebsd.py
Including module_utils file ansible/module_utils/facts/virtual/hpux.py
Including module_utils file ansible/module_utils/facts/virtual/linux.py
Including module_utils file ansible/module_utils/facts/virtual/netbsd.py
Including module_utils file ansible/module_utils/facts/virtual/openbsd.py
Including module_utils file ansible/module_utils/facts/virtual/sunos.py
Including module_utils file ansible/module_utils/facts/virtual/sysctl.py
Including module_utils file ansible/module_utils/parsing/convert_bool.py
Including module_utils file ansible/module_utils/parsing/__init__.py
Including module_utils file ansible/module_utils/pycompat24.py
Including module_utils file ansible/module_utils/six/__init__.py
Including module_utils file ansible_collections/purestorage/flashblade/plugins/module_utils/purefb.py
Including module_utils file ansible_collections/__init__.py
Including module_utils file ansible_collections/purestorage/__init__.py
Including module_utils file ansible_collections/purestorage/flashblade/__init__.py
Including module_utils file ansible_collections/purestorage/flashblade/plugins/__init__.py
Including module_utils file ansible_collections/purestorage/flashblade/plugins/module_utils/__init__.py
Using module file /home/mahendra/.ansible/collections/ansible_collections/purestorage/flashblade/plugins/modules/purefb_policy.py
<127.0.0.1> PUT /home/mahendra/.ansible/tmp/ansible-local-21986e5bq8ta_/tmpjdb__2k4 TO /home/mahendra/.ansible/tmp/ansible-tmp-1602133735.2303548-22036-145411506843059/AnsiballZ_purefb_policy.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/mahendra/.ansible/tmp/ansible-tmp-1602133735.2303548-22036-145411506843059/ /home/mahendra/.ansible/tmp/ansible-tmp-1602133735.2303548-22036-145411506843059/AnsiballZ_purefb_policy.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/mahendra/.pyenv/versions/3.6.9/bin/python3.6 /home/mahendra/.ansible/tmp/ansible-tmp-1602133735.2303548-22036-145411506843059/AnsiballZ_purefb_policy.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/mahendra/.ansible/tmp/ansible-tmp-1602133735.2303548-22036-145411506843059/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "changed": true,
    "invocation": {
        "module_args": {
            "api_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "at": "11AM",
            "enabled": true,
            "every": 86400,
            "fb_url": "10.21.xxx.151",
            "filesystem": null,
            "keep_for": 86400,
            "name": "daily",
            "replica_link": null,
            "state": "present",
            "timezone": "Asia/Kolkata"
        }
    }
}
META: ran handlers
META: ran handlers

PLAY RECAP ***********************************************************************************************************************
localhost                  : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Expected behavior Re-running playbook with same state should not report status change.

Platform versions: purity-fb version v1.9.2 collection - latest code Ansible version 2.10

sdodsley commented 4 years ago

Can you confirm the operating system you are using and version as well as if this is on VMware, Hyper-V, bare-metal, etc?

sdodsley commented 4 years ago

By design if you do not specify a timezone it will force your local timezone, therefore if you had a policy with a non-local timezone and run the task again without a timezone it will see this as a change and change the timezone to the local timezone. You can see that in your output where it has set timezone to be Asia/Kolkata. Becuae this is set I don't need the answer to the first comment about your operating system.

This means that the first section of your report is a feature, not a bug.

For the second portion, ie not setting the timezone, I will investigate.

sdodsley commented 4 years ago

Addressed by #101

mahendra-maplelabs commented 4 years ago

Thanks @sdodsley , #101 resolved the issue.