可创建本地目录(主目录)

问题描述 投票:0回答:1

我忘记了如何在localhost(ansible svr)目录中创建。我正在使用ansible服务器作为缓存来下载文件,然后将其复制到远程主机。

这里有任务和剧本的示例

任务

- name:  Create temp folder
  file:
    path: "{{ item }}"
    state: directory
    mode: 0755
  with_items:
    - /tmp/foo/

剧本

- hosts: foo

  roles:
   - foo

尝试过此操作但不起作用:

- name:  Create temp folder
  file:
    path: "{{ item }}"
    state: directory
    mode: 0755
    remote_src: no
  with_items:
    - /tmp/foo/

谢谢

ansible ansible-2.x ansible-inventory
1个回答
0
投票

我找到了解决方案delegate_to: localhost

- name:  Create temp folder
  file:
    path: "{{ item }}"
    state: directory
    mode: 0755
  delegate_to: localhost
  with_items:
    - /tmp/foo/
© www.soinside.com 2019 - 2024. All rights reserved.