How to create a directory using Ansible

后端 未结 22 1604
暗喜
暗喜 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:24

    Additional for all answers here, there is lot of situations when you need to create more then one directory so it is a good idea to use loops instead creating separate task for each directory.

    - name: Creates directory
      file:
        path: "{{ item }}"
        state: directory
      with_items:
      - /srv/www
      - /dir/foo
      - /dir/bar
    

提交回复
热议问题