Ansible Ignore_Unreachable无法正常工作 [英] Ansible Ignore_Unreachable is not working

查看:114
本文介绍了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:

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天全站免登陆