Multiple choice variable to specify folder rights in Ansible Tower


I have a playbook that creates a directory in Ansible Tower.
I have a survey with a multiple choice options to choose the permission for this folder.

The playbook is:

- name: Create a directory
  hosts: localhost
  become_user: root
    - name: Create directory
        path: /test
        state: directory
        mode: u={{ user_perm }},g={{ group_perm }},o={{ other_perm }}
        owner: 'root'
        group: 'root'

When I execute the template in Ansible Tower I have to specify in the survey, via a multiple choice, the parameters: r, w, x. My intention is that I could combine this variables: rw, r, rx.

After specifying the parameters in multiple choice the summary that Tower shows:

  - r
  - r
  - w
  - x

And the error message:

bad symbolic permission for mode: u=[‘r’], "gid": 0, "group": "root", "mode": "0750", "msg": "mode must be in octal or symbolic form""

Should I change the way the playbook handle variables?


Since a valid set of permission matching your example would be

mode: u=r,g=rw,o=x

You can simply join your lists:

mode: >-
  u={{ user_perm | join -}}
  ,g={{ group_perm | join -}}
  ,o={{ other_perm | join }}

Answered By – β.εηοιτ.βε

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published