Pure-Storage-Ansible / FlashBlade-Collection

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

purefb_s3user module failing with error #100

Closed mahendra-maplelabs closed 4 years ago

mahendra-maplelabs commented 4 years ago

Describe the bug purefb_s3user module failing with error purity_fb sdk is required for this module though "purity-fb" v1.9.2 SDK is available in system. As purity-fb 1.9.2 do not have object ObjectStoreAccessKeyPost, Module is failing while trying to import this object.

HAS_PURITY_FB = True
try:
    from purity_fb import ObjectStoreAccessKey, ObjectStoreAccessKeyPost
except ImportError:
    HAS_PURITY_FB = False

To Reproduce Steps to reproduce the behavior:

  1. Run sample playbook
  2. See error

sample playbook

- name: Pure Storage Object Store user example
  hosts: localhost
  gather_facts: no
  collections:
  - purestorage.flashblade
  tasks:
    - name: Create object store user (with access ID and key) foo in account bar
      purefb_s3user:
        name: foo
        account: bar
        access_key: true
        fb_url: 10.21.xxx.151
        api_token: T-0b8ad89c-xxxx-xxxx-85ed-286607dc2cd2
      register: result

Error

TASK [Create object store user (with access ID and key) foo in account bar] ******************************************************
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-1602239585.776675-20884-30356698548837 `" && echo ansible-tmp-1602239585.776675-20884-30356698548837="` echo /home/mahendra/.ansible/tmp/ansible-tmp-1602239585.776675-20884-30356698548837 `" ) && 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/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_s3user.py
<127.0.0.1> PUT /home/mahendra/.ansible/tmp/ansible-local-20834f9lwbb8o/tmpys5eg6wj TO /home/mahendra/.ansible/tmp/ansible-tmp-1602239585.776675-20884-30356698548837/AnsiballZ_purefb_s3user.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/mahendra/.ansible/tmp/ansible-tmp-1602239585.776675-20884-30356698548837/ /home/mahendra/.ansible/tmp/ansible-tmp-1602239585.776675-20884-30356698548837/AnsiballZ_purefb_s3user.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-1602239585.776675-20884-30356698548837/AnsiballZ_purefb_s3user.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/mahendra/.ansible/tmp/ansible-tmp-1602239585.776675-20884-30356698548837/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "access_key": true,
            "account": "bar",
            "api_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "fb_url": "10.21.xxx.151",
            "imported_key": null,
            "imported_secret": null,
            "name": "foo",
            "state": "present"
        }
    },
    "msg": "purity_fb sdk is required for this module"
}

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

Expected behavior purefb_s3user module should create user with access key.

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

sdodsley commented 4 years ago

You are using a version of the playbook not yet officially released in a collection. The missing import is only available in SDK 1.10 - not yet released. When 1.10 is released this updated module will be included in a new version of the flashblade collection