Bo's Oracle Station

查看: 2391|回复: 0

ansible9(分支判断)

[复制链接]

75

主题

115

帖子

2772

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2772
发表于 2020-12-12 21:54:08 | 显示全部楼层 |阅读模式


  1. ---
  2. - name: Simple Task Demo
  3.   hosts: srvgroup
  4.   vars:
  5.     v_os:
  6.       - RedHat
  7.       - Fedora
  8.   tasks:
  9.   - name: install mariadb
  10.     yum:
  11.       name: mariadb-server
  12.       state: latest
  13.     when: ansible_distribution == "RedHat" or  ansible_distribution == "Fedora"
复制代码

  1. ---
  2. - name: Simple Task Demo
  3.   hosts: dbgroup
  4.   vars:
  5.     v_os:
  6.       - RedHat
  7.       - Fedora
  8.   tasks:
  9.   - name: install mariadb
  10.     yum:
  11.       name: mariadb-server
  12.       state: latest
  13.     when: ansible_distribution in v_os
复制代码

  1. ---
  2. - name: Simple Task Demo
  3.   hosts: othergroup
  4.   vars:
  5.     v_os:
  6.       - RedHat
  7.       - Fedora
  8.   tasks:
  9.   - name: install mariadb
  10.     yum:
  11.       name: mariadb-server
  12.       state: latest
  13.     when: ansible_distribution in v_os and  ansible_kernel == "4.18.0-80.el8.x86_64" and ansible_hostname != "classroom"
复制代码

  1. ---
  2. - name: Simple Task Demo
  3.   hosts: othergroup
  4.   vars:
  5.     v_os:
  6.       - RedHat
  7.       - Fedora
  8.   tasks:
  9.   - name: install mariadb
  10.     yum:
  11.       name: mariadb-server
  12.       state: latest
  13.     when:
  14.       - ansible_distribution in v_os
  15.       - ansible_kernel == "4.18.0-80.el8.x86_64"
  16.       - ansible_hostname != "classroom"




复制代码





回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-11-21 14:57 , Processed in 0.162214 second(s), 24 queries .

快速回复 返回顶部 返回列表