How to create a directory using Ansible

后端 未结 22 1631
暗喜
暗喜 2020-12-22 16:44

How do you create a directory www at /srv on a Debian-based system using an Ansible playbook?

22条回答
  •  孤城傲影
    2020-12-22 17:10

    Hello good afternoon team.

    I share the following with you.

       - name: Validar Directorio
         stat:
           path: /tmp/Sabana
         register: sabana_directorio
       
       - debug:
           msg: "Existe"
         when: sabana_directorio.stat.isdir == sabana_directorio.stat.isdir
    
       - name: Crear el directorio si no existe.
         file:
           path: /tmp/Sabana
           state: directory
         when: sabana_directorio.stat.exists == false
    

    With which you can validate if the directory exists before creating it

提交回复
热议问题