What's the easy way to auto create non existing dir in ansible

前端 未结 7 661
悲哀的现实
悲哀的现实 2020-12-23 15:37

In my Ansible playbook many times i need to create file there

 - name: Copy file
   template:
     src: code.conf.j2
     dest: \"{{project_root}}/conf/code.         


        
7条回答
  •  一整个雨季
    2020-12-23 16:21

    you can create the folder using the following depending on your ansible version.

    Latest version 2<

    - name: Create Folder
      file: 
       path: "{{project_root}}/conf"
       recurse: yes
       state: directory
    

    Older version:

    - name: Create Folder
      file: 
          path="{{project_root}}/conf"
          recurse: yes
          state=directory
    

    Refer - http://docs.ansible.com/ansible/latest/file_module.html

提交回复
热议问题