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

前端 未结 7 668
悲哀的现实
悲哀的现实 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:10

    copy module creates the directory if it's not there. In this case it created the resolved.conf.d directory

    - name: put fallback_dns.conf in place                                                                 
      copy:                                                                                                
        src: fallback_dns.conf                                                                             
        dest: /etc/systemd/resolved.conf.d/                                                                
        mode: '0644'                                                                                       
        owner: root                                                                                        
        group: root                                                                                        
      become: true                                                                                         
      tags: testing
    

提交回复
热议问题