美文网首页ansible
ansible之with_items

ansible之with_items

作者: 燃燃的爸爸 | 来源:发表于2019-05-05 11:11 被阅读82次

with_items个人理解就像是shell里面的循环,可以循环操作

简单案例一:

多个变量

- name: installpakger
  yum: name={{ item }} state=latest    ##安装依赖包
  with_items:
    - openssl-devel
    - pcre-devel
    - gcc

简单案例二:

k/v类型

  - hosts: CentOS-7-4
    gather_facts: false
    tasks:
      - name: copy files
        copy:
          src: "{{ item.src }}"
          dest: "{{ item.dest }}"
        with_items:
          - { src: "/home/ansible/copy.yml", dest: "/home/copy.yml" }

相关文章

网友评论

    本文标题:ansible之with_items

    本文链接:https://www.haomeiwen.com/subject/icjcoqtx.html