你如何创建一个目录www在/srv上基于debian的系统使用Ansible剧本?
当前回答
您可以创建目录。使用
# create a directory if it doesn't exist
- file: path=/src/www state=directory mode=0755
你也可以咨询 http://docs.ansible.com/ansible/file_module.html 有关目录和文件系统的进一步详细信息。
其他回答
这里有一个更简单的方法。
—name:创建dir mkdir -p dir dir/a dir/b
您可以创建目录。使用
# create a directory if it doesn't exist
- file: path=/src/www state=directory mode=0755
你也可以咨询 http://docs.ansible.com/ansible/file_module.html 有关目录和文件系统的进一步详细信息。
如果你想在windows中创建一个目录:
- name: create folder in Windows
win_file:
path: C:\Temp\folder\subfolder
state: directory
有关更多信息,请参阅win_file模块。
enter code here
- name: creating directory in ansible
file:
path: /src/www
state: directory
owner: foo
你可以参考可靠的文档
只需要为特定的分配设置执行任务的条件
- name: Creates directory
file: path=/src/www state=directory
when: ansible_distribution == 'Debian'