我曾經在我的所有機器上運行簡單的操作手冊(something like this)(RH &基於Debian)來更新它們,並且對於每臺已更新的機器運行腳本(通知處理程序)。Ansible在使用group_by時看不到處理程序
最近,我試圖測試一個名爲group_by
新的模塊,所以不是使用when
條件運行yum update
時ansible_distribution == "CentOS"
,我會第一時間收集的事實和組基於有ansible_pkg_mgr
爲重點,然後我一直在尋找運行主機百勝在所有主機上更新,其中的關鍵是PackageManager_yum,看的戲書例如:
---
- hosts: all
gather_facts: false
remote_user: root
tasks:
- name: Gathering facts
setup:
- name: Create a group of all hosts by operating system
group_by: key=PackageManager_{{ansible_pkg_mgr}}
- hosts: PackageManager_apt
gather_facts: false
tasks:
- name: Update DEB Family
apt:
upgrade=dist
autoremove=yes
install_recommends=no
update_cache=yes
when: ansible_os_family == "Debian"
register: update_status
notify: updateX
tags:
- deb
- apt_update
- update
- hosts: PackageManager_yum
gather_facts: false
tasks:
- name: Update RPM Family
yum: name=* state=latest
when: ansible_os_family == "RedHat"
register: update_status
notify: updateX
tags:
- rpm
- yum
- yum_update
handlers:
- name: updateX
command: /usr/local/bin/update
這是錯誤消息我得到的,
PLAY [all] ********************************************************************
TASK [Gathering facts] *********************************************************
Wednesday 21 December 2016 11:26:17 +0200 (0:00:00.031) 0:00:00.031 ****
....
TASK [Create a group of all hosts by operating system] *************************
Wednesday 21 December 2016 11:26:26 +0200 (0:00:01.443) 0:00:09.242 ****
TASK [Update DEB Family] *******************************************************
Wednesday 21 December 2016 11:26:26 +0200 (0:00:00.211) 0:00:09.454 ****
ERROR! The requested handler 'updateX' was not found in either the main handlers list nor in the listening handlers list
提前致謝。
感謝您的提示。 – Rabin