Ansible - Create multiple folders if don't exist

后端 未结 3 893
无人共我
无人共我 2021-02-03 23:44

Goal:

  • Create multiple directories if they don\'t exist.
  • Don\'t change permissions of existing folder

Current playbook:

- name:         


        
3条回答
  •  感情败类
    2021-02-04 00:16

    Using Ansible modules, you don't need to check if something exist or not, you just describe the desired state, so:

    - name: create directory if they don't exist
      file:
        path: "{{ item }}"
        state: directory
        owner: root
        group: root
        mode: 0775
      loop:
        - /data/directory
        - /data/another
    

提交回复
热议问题