节日快乐,
我正在尝试创建一个在环境中的所有服务器上运行yum命令的作业。该部分已经完成,但是即使遇到了UNREACHABLE错误,我仍希望该作业继续运行。
这是我的任务:
- name: "remove {{ service_to_uninstall_name }} packages"
yum:
name: "{{ service_to_uninstall_name }}"
state: absent
ignore_unreachable: true
ignore_errors: true
答案 0 :(得分:0)
它对我有用。
我的 ansible 版本是 ansible 2.9.18
,下面是我的剧本,用于忽略无法访问的服务器。
---
- name: Install the package
serial: 1
hosts: dev
become: yes
gather_facts: false
become_user: root
tasks:
- name: Install amazon efs package
yum:
name: ['packagename']
state: latest
ignore_unreachable: true
以下是 o/p 示例:
PLAY [Install the package] ******************************************************************************************************************************************************************
TASK [Install amazon efs package] ***********************************************************************************************************************************************************
fatal: [x.x.x.x]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host x.x.x.x port 22: Connection timed out", "skip_reason": "Host x.x.x.x is unreachable", "unreachable": true}
PLAY [Install the package] ******************************************************************************************************************************************************************
TASK [Install amazon efs package] ***********************************************************************************************************************************************************
fatal: [x.x.x.x]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host x.x.x.x port 22: Connection timed out", "skip_reason": "Host x.x.x.x is unreachable", "unreachable": true}