Ansible系列剧本>;1并运行一次

Ansible系列剧本>;1并运行一次,ansible,Ansible,我正在编写简单的双任务ansible playbook,从internet下载更新文件并将其推送到托管服务器,类似于: - hosts: all serial: 10 tasks: - name: Download update file get_url: url=http://f.q.d.n/path/to/file dest=/tmp/ connection: local run_once: true - name: Copy update fil

我正在编写简单的双任务ansible playbook,从internet下载更新文件并将其推送到托管服务器,类似于:

- hosts: all
  serial: 10

  tasks:
  - name: Download update file
    get_url: url=http://f.q.d.n/path/to/file dest=/tmp/
    connection: local
    run_once: true

  - name: Copy update file to all servers
    copy: src=/tmp/file dest=/path/to/file mode="..."
第一个任务应该只在本地主机上运行一次,其余任务分10个连续批运行。
然而,根据ansible文档,标记为“run_once”的任务将在每个串行批处理中的一台主机上运行。

我不能使用文档中提到的解决方法,在条件中使用inventory_主机名,因为实际的目标主机可能不同,例如,受限于--limit等
设计此剧本的正确方法是什么?pre_任务在这里有用吗?

谢谢!这正如预期的那样工作,我不知道ansible即使在playbook使用--limit执行时仍然会匹配本地主机任务
- hosts: localhost

  tasks:
  - name: Download update file
    get_url: url=http://f.q.d.n/path/to/file dest=/tmp/


- hosts: all
  serial: 10

  tasks:
  - name: Copy update file to all servers
    copy: src=/tmp/file dest=/path/to/file mode="..."