ansible中的循环模块有很多,不过with_items最为常用,且较为简单,循环模块最多的功能就是将重复性的任务简单化,如下例子所示:

- hosts: all
  remote_user: root
  vars:
    working_dir: "/home/root/deploy/rap"
tasks:
- name: create working_dir directory file: path: "{{ item }}" state: directory with_items: - "{{ working_dir }}"

with_items可以用于迭代一个列表或字典,通过{{ item }}获取每次迭代的值。

相关文章:

  • 2021-08-15
  • 2021-09-08
  • 2021-11-20
猜你喜欢
  • 2021-04-08
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2021-10-18
  • 2019-12-18
相关资源
相似解决方案