你如何创建一个目录www在/srv上基于debian的系统使用Ansible剧本?


当前回答

enter code here 
- name: creating directory in ansible
  file:
   path: /src/www
   state: directory
   owner: foo

你可以参考可靠的文档

其他回答

—name:创建目录 ansible.builtin.file: 路径:/etc/some_directory 状态:目录 模式:“0755”

创建目录

ansible host_name -m file -a "dest=/home/ansible/vndir state=directory"

如果你想在windows中创建一个目录:

- name: create folder in Windows
  win_file:
    path: C:\Temp\folder\subfolder
    state: directory

有关更多信息,请参阅win_file模块。

目录只能使用文件模块创建,因为目录只是一个文件。

# create a directory if it doesn't exist
- file:
    path: /etc/some_directory
    state: directory
    mode: 0755
    owner: foo
    group: foo

你可以使用陈述句

- name: webfolder - Creates web folder
  file: path=/srv/www state=directory owner=www-data group=www-data mode=0775`