I'm writing a role where I need to iterate over a list using the loop
option. I'm using the ZFS module aisbergg.zfs.
The role:
- hosts: localhost
vars:
zfs_pool_name: tank
zfs_first_fs: subtank
zfs_clients:
- mom
clients_fs_size: 1T
tasks:
- name: Create the clusters's filesystem
zfs:
name: "{{ zfs_pool_name }}/{{ zfs_first_fs }}/{{ zfs_clients }}"
state: present
extra_zfs_properties:
volsize: "{{ clients_fs_size }}"
loop: "{{ zfs_clients }}"
loop_control:
pause: 5
When I run the playbook I got the following error:
TASK [Create the clusters's filesystem] ********************************************************************************************************************** failed: [localhost] (item=mom) => {"ansible_loop_var": "item", "changed": false, "item": "mom", "msg": "cannot create 'tank/subtank/[mom]': invalid character '[' in name\n"}
Meaning that somehow the square brackets sneak into my variable, which I got from a list.
Any idea on how can I get my variable without the square brackets?