如何比较主机组中的多个主机

问题描述

如何创建一个 play 来比较彼此内的多个主机,以检查组内所有主机的包版本是否相同,并在发现版本不匹配时打印 msg,或者获取特定主机并与其他主机进行比较。

示例: 库存

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

示例:剧本

---
- 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: 

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)