Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

ansible - How can I compare multiple hosts in the group of host

How can create a play to compare multiple hosts within each other to check the version of the package it is same of all hosts within the group and print msg when they found mismatch version, or take the specific host and compared with others.

Example: Inventory

[cluster]
host-1
host-2
host-3
host-4

Example: Playbook

---
- hosts: cluster-01
  user: ansible
  become: False
  gather_facts: yes
  vars:
    ansible_python_interpreter: /d2/local/bin/python
  tasks:
    - shell:
        cmd: "show system version | tr -s ' '"
      register: svcli_version
    - name: fsvcli_version
      debug:
        var: svcli_version.stdout_lines
    - fail:
        msg: "This host package version is not match with existed other one on the system"
      failed_when: svcli_output.rc > 1
      ignore_errors: yes
      when: 
question from:https://stackoverflow.com/questions/65882287/how-can-i-compare-multiple-hosts-in-the-group-of-host

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...