create_dirs.yml 615 B

123456789101112131415161718192021222324252627
  1. ---
  2. - name: Check if {{ item }} already exists
  3. stat:
  4. path: "{{ item }}"
  5. register: container_dir
  6. - block:
  7. - name: Create {{ item }}
  8. file:
  9. path: "{{ item }}"
  10. state: directory
  11. owner: "{{ container_user }}"
  12. group: "{{ container_group }}"
  13. mode: '0770'
  14. - name: Modify SELinux contexts for {{ item }}
  15. sefcontext:
  16. target: "{{ item }}(/.*)?"
  17. setype: container_file_t
  18. state: present
  19. - name: Apply SELinux contexts to {{ item }}
  20. shell:
  21. cmd: restorecon -r "{{ item }}"
  22. when:
  23. - not container_dir.stat.exists