你如何创建一个目录www在/srv上基于debian的系统使用Ansible剧本?
当前回答
我们有模块可以在ansible中创建目录,文件
例子
- name: Creates directory
file:
path: /src/www
state: directory
其他回答
您可以创建目录。使用
# create a directory if it doesn't exist
- file: path=/src/www state=directory mode=0755
你也可以咨询 http://docs.ansible.com/ansible/file_module.html 有关目录和文件系统的进一步详细信息。
enter code here
- name: creating directory in ansible
file:
path: /src/www
state: directory
owner: foo
你可以参考可靠的文档
您可以使用以下方法创建:
最新版本2<
- name: Create Folder
file:
path: /srv/www/
owner: user
group: user
mode: 0755
state: directory
旧版本
- name: Create Folder
file:
path=/srv/www/
owner=user
group=user
mode=0755
state=directory
参考- http://docs.ansible.com/ansible/file_module.html
这里有一个更简单的方法。
—name:创建dir mkdir -p dir dir/a dir/b
我们有模块可以在ansible中创建目录,文件
例子
- name: Creates directory
file:
path: /src/www
state: directory