Created
May 6, 2020 09:49
-
-
Save AlexMikhalev/14bc5e08a0f1205236f419540ccd5704 to your computer and use it in GitHub Desktop.
Create multiple folders using ansible without changing permissions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: "Creating multiple by checking folders" | |
hosts: your_host_name | |
tasks: | |
- block: | |
- name: "Checking folders" | |
stat: | |
path: "{{item}}" | |
register: folder_stats | |
with_items: | |
- ["/var/www/f1","/var/www/f2","/var/www/f3","/var/www/f4"] | |
- name: "Creating multiple folders without disturbing previous permissions" | |
file: | |
path: "{{item.item}}" | |
state: directory | |
mode: 0755 | |
group: root | |
owner: root | |
when: item.stat.exists == false | |
with_items: | |
- "{{folder_stats.results}}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment