Playbook to create multiple user directories based on user input passed in from playbook execution

12 views
Skip to first unread message

Gerry Maddock

unread,
Nov 1, 2022, 11:26:26 AM11/1/22
to ansible...@googlegroups.com
Hello all,

I have a playbook which creates sftp user accounts based on information passed during playbook execution. I would like to create multiple directories based on what the user running the playbook enters. 

- name: Create subdirectories
      file:
        path: /storage/{{ prod_or_test }}/sftp/{{ obfusicatedusername }}/{{ dirs }}
        state: directory
        recurse: yes
        owner: '{{ obfusicatedusername }}'
        group: sftp_admins

I pass the information via: --extra-vars: obfusicatedusername=testy123 password=mypassword prod_or_test=TEST_SFTP dirs=Inbound

The issue is some sftp users want more than 1 directory, while others want 2 or more....

I know I could do something like:
with_items:
  - /srv/www
  - /dir/foo
  - /dir/bar



 Just not sure how to handle that if sometimes it could be one, other times 2 or more. Any help or guidance would be appreciated.
Reply all
Reply to author
Forward
0 new messages