Ansible Ignore_Unreachable 不起作用 [英] Ansible Ignore_Unreachable is not working

查看:29
本文介绍了Ansible Ignore_Unreachable 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

祝大家假期愉快,

我正在尝试创建一个在环境中的所有服务器上运行 yum 命令的作业.这部分已经完成,但是即使遇到 UNREACHABLE 错误,我也希望让工作继续运行.

I am trying to create a job that runs a yum command on all of my servers in an environment. That part is complete however I am looking to make the job continue running even if I run into UNREACHABLE errors.

这是我的任务:

- name: "remove {{ service_to_uninstall_name }} packages"
  yum:
    name: "{{ service_to_uninstall_name }}"
    state: absent
  ignore_unreachable: true
  ignore_errors: true

推荐答案

它对我有用.

我的 ansible 版本是 ansible 2.9.18,下面是我的剧本,用于忽略无法访问的服务器.

My ansible version is ansible 2.9.18 and below is my playbook worked for ignoring the unreachable servers.

---

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

and Below is the sample 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}

这篇关于Ansible Ignore_Unreachable 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆