我忘记了如何在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/
谢谢
我找到了解决方案delegate_to: localhost
- name: Create temp folder
file:
path: "{{ item }}"
state: directory
mode: 0755
delegate_to: localhost
with_items:
- /tmp/foo/