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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…