相关疑难解决方法(0)

Ansible - 如果不存在,则创建多个文件夹

目标:

  • 如果它们不存在,则创建多个目录.
  • 不要更改现有文件夹的权限

目前的剧本:

- name: stat directories if they exist
  stat:
    path: "{{ item }}"
  with_items:
    - /data/directory
    - /data/another
  register: myvar

- debug: var=myvar.results

- name: create directory if they don't exist
  file:
    path: "{{ item.invocation.module_args.path }}"
    state: directory
    owner: root
    group: root
    mode: 0775
  with_items: "{{ stat.results }}"
  # when: myvar.results.stat.exists == false
Run Code Online (Sandbox Code Playgroud)

when说法是错误的.

我看了一下提供的例子; http://docs.ansible.com/ansible/stat_module.html.但这仅适用于单个文件夹.

ansible

19
推荐指数
3
解决办法
5万
查看次数

标签 统计

ansible ×1