Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gluster_volume does not accept list for cluster #17

Open
mihudec opened this issue Oct 30, 2020 · 0 comments
Open

gluster_volume does not accept list for cluster #17

mihudec opened this issue Oct 30, 2020 · 0 comments

Comments

@mihudec
Copy link

mihudec commented Oct 30, 2020

Hi, I've hit this when trying to setup volume for the first time. Defining cluster nodes as list seems to raise TypeError: sequence item 6: expected str instance, list found. When running the same task with cluster parametr set to string of comma separated entries, it works as expected. The docs say that the expected value for cluster param is list.

Setup:

Ansible Version:

$ ansible --version
ansible 2.10.2
  config file = None
  configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]

OS: Ubuntu 20.04

Task:

- name: Create GlusterFS Volume
  gluster_volume:
    name: "{{ item.name }}"
    host: "{{ inventory_hostname }}.{{ domain_name }}"
    bricks: "{{ item.bricks }}"
    replicas: "{{ item.gluster_nodes | length }}"
    options: 
      {
        server.ssl: 'on',
        client.ssl: 'on',
        auth.ssl-allow: "{{ item.gluster_nodes }}",
        ssl.cipher-list: 'HIGH:!SSLv2'
      }
    #rebalance: yes
    cluster: "{{ item.gluster_nodes }}"
    state: "{{ item.state }}"
  loop: "{{ gluster_volumes }}"
  run_once: true
  when:
    - gluster_server_initiator is defined
    - gluster_server_initiator | bool

Vars:

gluster_volumes:
  - name: test-vol1
    bricks: "/mnt/cluster/brick-01/test-vol1"
    gluster_nodes: "{{ groups['testing_cluster'] | product([domain_name]) | map('join', '.') | list }}"
    state: present

Result with list (-vvv)

TASK [glusterfs : Create GlusterFS Volume] *********************************************************************************************************************************************************************************************
task path: /home/ansible/Develop/ansible-linux/roles/glusterfs/tasks/main.yml:43
<testing-01.lab.demo> ESTABLISH SSH CONNECTION FOR USER: ansible
<testing-01.lab.demo> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="ansible"' -o ConnectTimeout=10 -o ControlPath=/home/ansible/.ansible/cp/b2a5e7221e testing-01.lab.demo '/bin/sh -c '"'"'echo ~ansible && sleep 0'"'"''
<testing-01.lab.demo> (0, b'/home/ansible\n', b'')
<testing-01.lab.demo> ESTABLISH SSH CONNECTION FOR USER: ansible
<testing-01.lab.demo> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="ansible"' -o ConnectTimeout=10 -o ControlPath=/home/ansible/.ansible/cp/b2a5e7221e testing-01.lab.demo '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /home/ansible/.ansible/tmp `"&& mkdir "` echo /home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500 `" && echo ansible-tmp-1604072353.5431116-373556-91835152736500="` echo /home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500 `" ) && sleep 0'"'"''
<testing-01.lab.demo> (0, b'ansible-tmp-1604072353.5431116-373556-91835152736500=/home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500\n', b'')
redirecting (type: modules) ansible.builtin.gluster_volume to gluster.gluster.gluster_volume
Using module file /usr/local/lib/python3.8/dist-packages/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py
<testing-01.lab.demo> PUT /home/ansible/.ansible/tmp/ansible-local-3735132heab9gh/tmpyknma2uo TO /home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500/AnsiballZ_gluster_volume.py
<testing-01.lab.demo> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="ansible"' -o ConnectTimeout=10 -o ControlPath=/home/ansible/.ansible/cp/b2a5e7221e '[testing-01.lab.demo]'
<testing-01.lab.demo> (0, b'sftp> put /home/ansible/.ansible/tmp/ansible-local-3735132heab9gh/tmpyknma2uo /home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500/AnsiballZ_gluster_volume.py\n', b'')
<testing-01.lab.demo> ESTABLISH SSH CONNECTION FOR USER: ansible
<testing-01.lab.demo> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="ansible"' -o ConnectTimeout=10 -o ControlPath=/home/ansible/.ansible/cp/b2a5e7221e testing-01.lab.demo '/bin/sh -c '"'"'chmod u+x /home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500/ /home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500/AnsiballZ_gluster_volume.py && sleep 0'"'"''
<testing-01.lab.demo> (0, b'', b'')
<testing-01.lab.demo> ESTABLISH SSH CONNECTION FOR USER: ansible
<testing-01.lab.demo> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="ansible"' -o ConnectTimeout=10 -o ControlPath=/home/ansible/.ansible/cp/b2a5e7221e -tt testing-01.lab.demo '/bin/sh -c '"'"'sudo -H -S -n  -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-rygxsdbkepwiazdnneqqfqdkxptfamzd ; /usr/bin/env python3 /home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500/AnsiballZ_gluster_volume.py'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
<testing-01.lab.demo> (1, b'Traceback (most recent call last):\r\n  File "/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py", line 206, in run_gluster\r\n  File "/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible/module_utils/basic.py", line 2624, in run_command\r\n  File "/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible/module_utils/basic.py", line 2624, in <listcomp>\r\n  File "/usr/lib/python3.8/posixpath.py", line 284, in expandvars\r\n    path = os.fspath(path)\r\nTypeError: expected str, bytes or os.PathLike object, not list\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File "/home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500/AnsiballZ_gluster_volume.py", line 102, in <module>\r\n    _ansiballz_main()\r\n  File "/home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500/AnsiballZ_gluster_volume.py", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File "/home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500/AnsiballZ_gluster_volume.py", line 40, in invoke_module\r\n    runpy.run_module(mod_name=\'ansible_collections.gluster.gluster.plugins.modules.gluster_volume\', init_globals=None, run_name=\'__main__\', alter_sys=True)\r\n  File "/usr/lib/python3.8/runpy.py", line 207, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code\r\n    _run_code(code, mod_globals, init_globals,\r\n  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code\r\n    exec(code, run_globals)\r\n  File "/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py", line 621, in <module>\r\n  File "/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py", line 590, in main\r\n  File "/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py", line 373, in set_volume_option\r\n  File "/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py", line 211, in run_gluster\r\nTypeError: sequence item 6: expected str instance, list found\r\n', b'Shared connection to testing-01.lab.demo closed.\r\n')
<testing-01.lab.demo> Failed to connect to the host via ssh: Shared connection to testing-01.lab.demo closed.
<testing-01.lab.demo> ESTABLISH SSH CONNECTION FOR USER: ansible
<testing-01.lab.demo> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="ansible"' -o ConnectTimeout=10 -o ControlPath=/home/ansible/.ansible/cp/b2a5e7221e testing-01.lab.demo '/bin/sh -c '"'"'rm -f -r /home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500/ > /dev/null 2>&1 && sleep 0'"'"''
<testing-01.lab.demo> (0, b'', b'')
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py", line 206, in run_gluster
  File "/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible/module_utils/basic.py", line 2624, in run_command
  File "/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible/module_utils/basic.py", line 2624, in <listcomp>
  File "/usr/lib/python3.8/posixpath.py", line 284, in expandvars
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not list

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500/AnsiballZ_gluster_volume.py", line 102, in <module>
    _ansiballz_main()
  File "/home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500/AnsiballZ_gluster_volume.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500/AnsiballZ_gluster_volume.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.gluster.gluster.plugins.modules.gluster_volume', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py", line 621, in <module>
  File "/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py", line 590, in main
  File "/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py", line 373, in set_volume_option
  File "/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py", line 211, in run_gluster
TypeError: sequence item 6: expected str instance, list found
failed: [testing-01] (item={'name': 'test-vol1', 'bricks': '/mnt/cluster/brick-01/test-vol1', 'gluster_nodes': ['testing-01.lab.demo', 'testing-02.lab.demo', 'testing-03.lab.demo'], 'state': 'present'}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": {
        "bricks": "/mnt/cluster/brick-01/test-vol1",
        "gluster_nodes": [
            "testing-01.lab.demo",
            "testing-02.lab.demo",
            "testing-03.lab.demo"
        ],
        "name": "test-vol1",
        "state": "present"
    },
    "module_stderr": "Shared connection to testing-01.lab.demo closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py\", line 206, in run_gluster\r\n  File \"/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible/module_utils/basic.py\", line 2624, in run_command\r\n  File \"/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible/module_utils/basic.py\", line 2624, in <listcomp>\r\n  File \"/usr/lib/python3.8/posixpath.py\", line 284, in expandvars\r\n    path = os.fspath(path)\r\nTypeError: expected str, bytes or os.PathLike object, not list\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"/home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500/AnsiballZ_gluster_volume.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500/AnsiballZ_gluster_volume.py\", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/ansible/.ansible/tmp/ansible-tmp-1604072353.5431116-373556-91835152736500/AnsiballZ_gluster_volume.py\", line 40, in invoke_module\r\n    runpy.run_module(mod_name='ansible_collections.gluster.gluster.plugins.modules.gluster_volume', init_globals=None, run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\r\n    _run_code(code, mod_globals, init_globals,\r\n  File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py\", line 621, in <module>\r\n  File \"/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py\", line 590, in main\r\n  File \"/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py\", line 373, in set_volume_option\r\n  File \"/tmp/ansible_gluster_volume_payload_fb2mfkeq/ansible_gluster_volume_payload.zip/ansible_collections/gluster/gluster/plugins/modules/gluster_volume.py\", line 211, in run_gluster\r\nTypeError: sequence item 6: expected str instance, list found\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Changing to coma-separated string, as:

gluster_volumes:
  - name: test-vol1
    bricks: "/mnt/cluster/brick-01/test-vol1"
    gluster_nodes: "{{ groups['testing_cluster'] | product([domain_name]) | map('join', '.') | list | join(',') }}"
    state: present

Works fine.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant