If unreachable - stop giving Failed out and move to next host

149 views
Skip to first unread message

Work-Hard

unread,
May 7, 2020, 6:17:47 PM5/7/20
to Ansible Project
Hi,
Is it possible for the host that if it's unreachable - stop giving Failed output and move to the next task. As of now, it just shows the output fails. 


---
- hosts: amazonlinux2
  become: true
  serial: 1
  max_fail_percentage: 0
  ignore_errors: true
  gather_facts: false
  ignore_unreachable: true
  vars:
    ansible_user: ec2-user
  ignore_errors: yes


Output - 

fatal: [10.0.2.6]: FAILED! => {"changed": true, "changes": {"installed": [], "updated": [["kernel", "4.14.177-139.253.amzn2.x86_64 from amzn2-core"], ["libwayland-server", "1.17.0-1.amzn2.x86_64 from amzn2-core"], ["http-parser", "2.7.1-8.amzn2.2.x86_64 from amzn2-core"], ["libglvnd-glx", "1:1.0.1-0.1.git5baa1e5.amzn2.0.1.x86_64 from amzn2-core"], ["python2-rsa", "3.4.1-1.el7.noarch from epel"], ["librsvg2", "2.40.20-1.amzn2.x86_64 from amzn2-core"], ["cairo", "1.15.12-4.amzn2.x86_64 from amzn2-core"], ["libX11", "1.6.7-2.amzn2.x86_64 from amzn2-core"], ["harfbuzz", "1.7.5-2.amzn2.x86_64 from amzn2-core"], ["libXrandr", "1.5.1-2.amzn2.0.3.x86_64 from amzn2-core"], ["htop", "2.2.0-3.el7.x86_64 from epel"], ["gdisk", "0.8.10-3.amzn2.x86_64 from amzn2-core"], ["perl-Git", "2.23.3-1.amzn2.0.1.noarch from amzn2-core"], ["mesa-libgbm", "18.3.4-5.amzn2.0.1.x86_64 from amzn2-core"], ["libicu", "50.2-4.amzn2.x86_64 from amzn2-core"], ["git", "2.23.3-1.amzn2.0.1.x86_64 from amzn2-core"], ["nagios-common", "4.4.5-7.el7.x86_64 from epel"], ["libglvnd", "1:1.0.1-0.1.git5baa1e5.amzn2.0.1.x86_64 from amzn2-core"], ["python-colorama", "0.3.2-3.el7.noarch from epel"], ["fontconfig", "2.13.0-4.3.amzn2.x86_64 from amzn2-core"], ["microcode_ctl", "2:2.1-47.amzn2.0.6.x86_64 from amzn2-core"], ["pystache", "0.5.3-2.el7.noarch from epel"], ["python2-jsonschema", "2.5.1-4.el7.noarch from epel"], ["sscg", "2.6.1-1.el7.x86_64 from epel"], ["git-core", "2.23.3-1.amzn2.0.1.x86_64 from amzn2-core"], ["python-pillow", "2.0.0-20.gitd1c6db8.amzn2.0.1.x86_64 from amzn2-core"], ["gtk-update-icon-cache", "3.22.30-3.amzn2.x86_64 from amzn2-core"], ["freetype", "2.8-14.amzn2.x86_64 from amzn2-core"], ["avahi-libs", "0.6.31-19.amzn2.0.1.x86_64 from amzn2-core"], ["gdk-pixbuf2", "2.36.12-3.amzn2.x86_64 from amzn2-core"], ["python2-jmespath", "0.9.4-1.el7.noarch from epel"], ["nagios-plugins-nrpe", "4.0.2-1.el7.x86_64 from epel"], ["telnet", "1:0.17-65.amzn2.x86_64 from amzn2-core"], ["libglvnd-egl", "1:1.0.1-0.1.git5baa1e5.amzn2.0.1.x86_64 from amzn2-core"], ["libidn2", "2.3.0-1.el7.x86_64 from epel"], ["libdrm", "2.4.97-2.amzn2.x86_64 from amzn2-core"], ["mesa-libEGL", "18.3.4-5.amzn2.0.1.x86_64 from amzn2-core"], ["python2-futures", "3.0.5-1.el7.noarch from epel"], ["libwayland-client", "1.17.0-1.amzn2.x86_64 from amzn2-core"], ["mesa-libGL", "18.3.4-5.amzn2.0.1.x86_64 from amzn2-core"], ["libX11-common", "1.6.7-2.amzn2.noarch from amzn2-core"], ["pango", "1.42.4-4.amzn2.x86_64 from amzn2-core"], ["kernel-tools", "4.14.177-139.253.amzn2.x86_64 from amzn2-core"], ["kernel-headers", "4.14.177-139.253.amzn2.x86_64 from amzn2-core"], ["pgdg-redhat-repo", "42.0-6.noarch from pgdg94"], ["fribidi", "1.0.2-1.amzn2.1.x86_64 from amzn2-core"], ["nrpe", "4.0.2-1.el7.x86_64 from epel"], ["python-jinja2", "2.8-7.rhel7.noarch from pgdg94"], ["mesa-libglapi", "18.3.4-5.amzn2.0.1.x86_64 from amzn2-core"], ["python-repoze-lru", "0.4-3.el7.noarch from epel"], ["nagios-plugins", "2.3.3-2.el7.x86_64 from epel"], ["git-core-doc", "2.23.3-1.amzn2.0.1.noarch from amzn2-core"], ["python-lockfile", "1:0.9.1-4.el7.noarch from epel"], ["yum", "3.4.3-158.amzn2.0.4.noarch from amzn2-core"], ["python-daemon", "1.6-4.el7.noarch from epel"], ["glib2", "2.56.1-5.amzn2.0.1.x86_64 from amzn2-core"], ["php55-php-pear", "1:1.10.12-1.el7.remi.noarch from remi-safe"], ["awscli", "1.16.300-1.amzn2.0.2.noarch from amzn2-core"], ["libmetalink", "0.1.3-1.el7.x86_64 from epel"]]}, "msg": "Error: Package: pgdg-redhat-repo-42.0-6.noarch (pgdg94)\n           Requires: /etc/redhat-release\n", "obsoletes": {"pgdg-centos94": {"dist": "noarch", "repo": "installed", "version": "9.4-3"}}, "rc": 1, "results": ["Loaded plugins: langpacks, update-motd\nResolving Dependencies\n--> Running transaction check\n---> Package avahi-libs.x86_64 0:0.6.31-19.amzn2 will be updated\n---> Package avahi-libs.x86_64 0:0.6.31-19.amzn2.0.1 will be an update\n---> Package awscli.noarch 0:1.16.300-1.amzn2.0.1 will be updated\n---> Package awscli.noarch 0:1.16.300-1.amzn2.0.2 will be an update\n---> Package cairo.x86_64 0:1.14.8-2.amzn2.0.2 will be updated\n---> Package cairo.x86_64 0:1.15.12-4.amzn2 will be an update\n---> Package fontconfig.x86_64 0:2.10.95-11.amzn2.0.2 will be updated\n---> Package fontconfig.x86_64 0:2.13.0-4.3.amzn2 will be an update\n--> Processing Dependency: dejavu-sans-fonts for package: fontconfig-2.13.0-4.3.amzn2.x86_64\n---> Package freetype.x86_64 0:2.4.11-15.amzn2.0.2 will be updated\n---> Package freetype.x86_64 0:2.8-14.amzn2 will be an update\n---> Package fribidi.x86_64 0:1.0.2-0.el7.remi will be updated\n---> Package fribidi.x86_64 0:1.0.2-1.amzn2.1 will be an update\n---> Package gdisk.x86_64 0:0.8.6-5.amzn2.0.2 will be updated\n---> Package gdisk.x86_64 0:0.8.10-3.amzn2 will be an update\n---> Package gdk-pixbuf2.x86_64 0:2.36.5-1.amzn2.0.2 will be updated\n---> Package gdk-pixbuf2.x86_64 0:2.36.12-3.amzn2 will be an update\n---> Package git.x86_64 0:2.23.1-1.amzn2.0.1 will be updated\n---> Package git.x86_64 0:2.23.3-1.amzn2.0.1 will be an update\n---> Package git-core.x86_64 0:2.23.1-1.amzn2.0.1 will be updated\n---> Package git-core.x86_64 0:2.23.3-1.amzn2.0.1 will be an update\n---> Package git-core-doc.noarch 0:2.23.1-1.amzn2.0.1 will be updated\n---> Package git-core-doc.noarch 0:2.23.3-1.amzn2.0.1 will be an update\n---> Package glib2.x86_64 0:2.56.1-4.amzn2 will be updated\n---> Package glib2.x86_64 0:2.56.1-5.amzn2.0.1 will be an update\n---> Package gtk-update-icon-cache.x86_64 0:3.22.26-4.amzn2 will be updated\n---> Package gtk-update-icon-cache.x86_64 0:3.22.30-3.amzn2 will be an update\n---> Package harfbuzz.x86_64 0:1.3.2-1.amzn2.0.2 will be updated\n---> Package harfbuzz.x86_64 0:1.7.5-2.amzn2 will be an update\n---> Package htop.x86_64 0:2.0.2-1.amzn2.0.2 will be updated\n---> Package htop.x86_64 0:2.2.0-3.el7 will be an update\n---> Package http-parser.x86_64 0:2.7.1-8.amzn2 will be updated\n---> Package http-parser.x86_64 0:2.7.1-8.amzn2.2 will be an update\n---> Package kernel.x86_64 0:4.14.177-139.253.amzn2 will be installed\n---> Package kernel-headers.x86_64 0:4.14.173-137.228.amzn2 will be updated\n---> Package kernel-headers.x86_64 0:4.14.177-139.253.amzn2 will be an update\n---> Package kernel-tools.x86_64 0:4.14.173-137.228.amzn2 will be updated\n---> Package kernel-tools.x86_64 0:4.14.177-139.253.amzn2 will be an update\n---> Package libX11.x86_64 0:1.6.5-2.amzn2.0.2 will be updated\n---> Package libX11.x86_64 0:1.6.7-2.amzn2 will be an update\n---> Package libX11-common.noarch 0:1.6.5-2.amzn2.0.2 will be updated\n---> Package libX11-common.noarch 0:1.6.7-2.amzn2 will be an update\n---> Package libXrandr.x86_64 0:1.5.1-2.amzn2.0.2 will be updated\n---> Package libXrandr.x86_64 0:1.5.1-2.amzn2.0.3 will be an update\n---> Package libdrm.x86_64 0:2.4.83-2.amzn2.0.2 will be updated\n---> Package libdrm.x86_64 0:2.4.97-2.amzn2 will be an update\n---> Package libglvnd.x86_64 1:1.0.0-1.amzn2.0.2 will be updated\n---> Package libglvnd.x86_64 1:1.0.1-0.1.git5baa1e5.amzn2.0.1 will be an update\n---> Package libglvnd-egl.x86_64 1:1.0.0-1.amzn2.0.2 will be updated\n---> Package libglvnd-egl.x86_64 1:1.0.1-0.1.git5baa1e5.amzn2.0.1 will be an update\n---> Package libglvnd-glx.x86_64 1:1.0.0-1.amzn2.0.2 will be updated\n---> Package libglvnd-glx.x86_64 1:1.0.1-0.1.git5baa1e5.amzn2.0.1 will be an update\n---> Package libicu.x86_64 0:50.1.2-17.amzn2 will be updated\n---> Package libicu.x86_64 0:50.2-4.amzn2 will be an update\n---> Package libidn2.x86_64 0:2.3.0-1.amzn2 will be updated\n---> Package libidn2.x86_64 0:2.3.0-1.el7 will be an update\n---> Package libmetalink.x86_64 0:0.1.2-7.amzn2.0.2 will be updated\n---> Package libmetalink.x86_64 0:0.1.3-1.el7 will be an update\n---> Package librsvg2.x86_64 0:2.40.16-1.amzn2.0.2 will be updated\n---> Package librsvg2.x86_64 0:2.40.20-1.amzn2 will be an update\n---> Package libwayland-client.x86_64 0:1.14.0-2.amzn2.0.1 will be updated\n---> Package libwayland-client.x86_64 0:1.17.0-1.amzn2 will be an update\n---> Package libwayland-server.x86_64 0:1.14.0-2.amzn2.0.1 will be updated\n---> Package libwayland-server.x86_64 0:1.17.0-1.amzn2 will be an update\n---> Package mesa-libEGL.x86_64 0:17.2.3-8.20171019.amzn2.0.4 will be updated\n---> Package mesa-libEGL.x86_64 0:18.3.4-5.amzn2.0.1 will be an update\n---> Package mesa-libGL.x86_64 0:17.2.3-8.20171019.amzn2.0.4 will be updated\n---> Package mesa-libGL.x86_64 0:18.3.4-5.amzn2.0.1 will be an update\n---> Package mesa-libgbm.x86_64 0:17.2.3-8.20171019.amzn2.0.4 will be updated\n---> Package mesa-libgbm.x86_64 0:18.3.4-5.amzn2.0.1 will be an update\n---> Package mesa-libglapi.x86_64 0:17.2.3-8.20171019.amzn2.0.4 will be updated\n---> Package mesa-libglapi.x86_64 0:18.3.4-5.amzn2.0.1 will be an update\n---> Package microcode_ctl.x86_64 2:2.1-47.amzn2.0.5 will be updated\n---> Package microcode_ctl.x86_64 2:2.1-47.amzn2.0.6 will be an update\n---> Package nagios-common.x86_64 0:4.4.3-1.el7 will be updated\n---> Package nagios-common.x86_64 0:4.4.5-7.el7 will be an update\n---> Package nagios-plugins.x86_64 0:2.3.1-3.el7 will be updated\n---> Package nagios-plugins.x86_64 0:2.3.3-2.el7 will be an update\n---> Package nagios-plugins-nrpe.x86_64 0:3.2.1-8.el7 will be updated\n---> Package nagios-plugins-nrpe.x86_64 0:4.0.2-1.el7 will be an update\n---> Package nrpe.x86_64 0:3.2.1-8.el7 will be updated\n---> Package nrpe.x86_64 0:4.0.2-1.el7 will be an update\n---> Package pango.x86_64 0:1.40.4-1.amzn2.0.2 will be updated\n---> Package pango.x86_64 0:1.42.4-4.amzn2 will be an update\n---> Package perl-Git.noarch 0:2.23.1-1.amzn2.0.1 will be updated\n---> Package perl-Git.noarch 0:2.23.3-1.amzn2.0.1 will be an update\n---> Package pgdg-centos94.noarch 0:9.4-3 will be obsoleted\n---> Package pgdg-redhat-repo.noarch 0:42.0-6 will be obsoleting\n--> Processing Dependency: /etc/redhat-release for package: pgdg-redhat-repo-42.0-6.noarch\n---> Package php55-php-pear.noarch 1:1.10.10-4.el7.remi will be updated\n---> Package php55-php-pear.noarch 1:1.10.12-1.el7.remi will be an update\n---> Package pystache.noarch 0:0.5.3-2.amzn2 will be updated\n---> Package pystache.noarch 0:0.5.3-2.el7 will be an update\n---> Package python-colorama.noarch 0:0.3.2-3.amzn2 will be updated\n---> Package python-colorama.noarch 0:0.3.2-3.el7 will be an update\n---> Package python-daemon.noarch 0:1.6-4.amzn2 will be updated\n---> Package python-daemon.noarch 0:1.6-4.el7 will be an update\n---> Package python-jinja2.noarch 0:2.7.2-3.amzn2 will be updated\n---> Package python-jinja2.noarch 0:2.8-7.rhel7 will be an update\n---> Package python-lockfile.noarch 1:0.9.1-4.amzn2 will be updated\n---> Package python-lockfile.noarch 1:0.9.1-4.el7 will be an update\n---> Package python-pillow.x86_64 0:2.0.0-19.gitd1c6db8.amzn2.0.2 will be updated\n---> Package python-pillow.x86_64 0:2.0.0-20.gitd1c6db8.amzn2.0.1 will be an update\n---> Package python-repoze-lru.noarch 0:0.4-3.amzn2 will be updated\n---> Package python-repoze-lru.noarch 0:0.4-3.el7 will be an update\n---> Package python2-futures.noarch 0:3.0.5-1.amzn2 will be updated\n---> Package python2-futures.noarch 0:3.0.5-1.el7 will be an update\n---> Package python2-jmespath.noarch 0:0.9.3-1.amzn2.0.1 will be updated\n---> Package python2-jmespath.noarch 0:0.9.4-1.el7 will be an update\n--> Processing Dependency: /usr/bin/python3 for package: python2-jmespath-0.9.4-1.el7.noarch\n---> Package python2-jsonschema.noarch 0:2.5.1-3.amzn2.0.1 will be updated\n---> Package python2-jsonschema.noarch 0:2.5.1-4.el7 will be an update\n---> Package python2-rsa.noarch 0:3.4.1-1.amzn2 will be updated\n---> Package python2-rsa.noarch 0:3.4.1-1.el7 will be an update\n---> Package sscg.x86_64 0:2.3.3-2.amzn2.0.1 will be updated\n---> Package sscg.x86_64 0:2.6.1-1.el7 will be an update\n---> Package telnet.x86_64 1:0.17-64.amzn2.0.1 will be updated\n---> Package telnet.x86_64 1:0.17-65.amzn2 will be an update\n---> Package yum.noarch 0:3.4.3-158.amzn2.0.3 will be updated\n---> Package yum.noarch 0:3.4.3-158.amzn2.0.4 will be an update\n--> Running transaction check\n---> Package dejavu-sans-fonts.noarch 0:2.33-6.amzn2 will be installed\n--> Processing Dependency: dejavu-fonts-common = 2.33-6.amzn2 for package: dejavu-sans-fonts-2.33-6.amzn2.noarch\n---> Package pgdg-redhat-repo.noarch 0:42.0-6 will be obsoleting\n--> Processing Dependency: /etc/redhat-release for package: pgdg-redhat-repo-42.0-6.noarch\n---> Package python3.x86_64 0:3.7.6-1.amzn2.0.1 will be installed\n--> Processing Dependency: python3-libs(x86-64) = 3.7.6-1.amzn2.0.1 for package: python3-3.7.6-1.amzn2.0.1.x86_64\n--> Processing Dependency: python3-setuptools for package: python3-3.7.6-1.amzn2.0.1.x86_64\n--> Processing Dependency: python3-pip for package: python3-3.7.6-1.amzn2.0.1.x86_64\n--> Processing Dependency: libpython3.7m.so.1.0()(64bit) for package: python3-3.7.6-1.amzn2.0.1.x86_64\n--> Running transaction check\n---> Package dejavu-fonts-common.noarch 0:2.33-6.amzn2 will be installed\n---> Package pgdg-redhat-repo.noarch 0:42.0-6 will be obsoleting\n--> Processing Dependency: /etc/redhat-release for package: pgdg-redhat-repo-42.0-6.noarch\n---> Package python3-libs.x86_64 0:3.7.6-1.amzn2.0.1 will be installed\n---> Package python3-pip.noarch 0:9.0.3-1.amzn2.0.2 will be installed\n---> Package python3-setuptools.noarch 0:38.4.0-3.amzn2.0.6 will be installed\n--> Processing Dependency: /etc/redhat-release for package: pgdg-redhat-repo-42.0-6.noarch\n--> Finished Dependency Resolution\n--> Running transaction check\n---> Package kernel.x86_64 0:4.14.33-59.34.amzn2 will be erased\n---> Package pgdg-redhat-repo.noarch 0:42.0-6 will be obsoleting\n--> Processing Dependency: /etc/redhat-release for package: pgdg-redhat-repo-42.0-6.noarch\n--> Processing Dependency: /etc/redhat-release for package: pgdg-redhat-repo-42.0-6.noarch\n--> Processing Dependency: /etc/redhat-release for package: pgdg-redhat-repo-42.0-6.noarch\n--> Finished Dependency Resolution\n You could try using --skip-broken to work around the problem\n You could try running: rpm -Va --nofiles --nodigest\n"]}
...ignoring


Cheers

Dick Visser

unread,
May 7, 2020, 6:28:33 PM5/7/20
to ansible...@googlegroups.com
Out of interest - what is the reason they are unreachable?
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/e2833655-5a4c-4292-883c-652ad62f61e7%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Brian Coca

unread,
May 8, 2020, 10:47:19 AM5/8/20
to Ansible Project
if you want to stop that ... dont use ignore_unreachable=true, the
'default' behaviour is to remove the host from play and not try
executing subsequent tasks (that of course fail again).


--
----------
Brian Coca

Work-Hard

unread,
May 8, 2020, 11:42:54 AM5/8/20
to Ansible Project
They are either off or unreachable over VPN. This is from production.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.

Work-Hard

unread,
May 8, 2020, 11:45:36 AM5/8/20
to Ansible Project
Brian if I remove ignore_unreachable=true. The playbook halts to continue the playbook.

Dick Visser

unread,
May 8, 2020, 2:16:31 PM5/8/20
to ansible...@googlegroups.com
You could use the ec2.py dynamic inventory to at least target the instances that are powered on. It's more elegant than ignoring errors etc 

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Work-Hard

unread,
May 8, 2020, 5:09:39 PM5/8/20
to Ansible Project
Hi Dick,
I just to make sure on your suggestion that I have over 100 hosts that brought up and down dynamically. My goal is that the tasks should stop reporting HUGE errors in the output and we save them to be reviewed by external companies. Is it possible ?


On Friday, May 8, 2020 at 11:16:31 AM UTC-7, Dick Visser wrote:
You could use the ec2.py dynamic inventory to at least target the instances that are powered on. It's more elegant than ignoring errors etc 
On Fri, 8 May 2020 at 17:45, Work-Hard <workema...@gmail.com> wrote:
Brian if I remove ignore_unreachable=true. The playbook halts to continue the playbook.




On Friday, May 8, 2020 at 7:47:19 AM UTC-7, Brian Coca wrote:
if you want to stop that ... dont use ignore_unreachable=true, the
'default' behaviour is to remove the host from play and not try
executing subsequent tasks (that of course fail again).


--
----------
Brian Coca

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.

Dick Visser

unread,
May 8, 2020, 11:50:03 PM5/8/20
to ansible...@googlegroups.com
This is exactly what the dynamic inventory is meant for. Basically if queries the aws api to fetch a list of the instances that are up, and provides that as the inventory. 



To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/89732f66-d11f-4dab-86b4-c560e035c52a%40googlegroups.com.

Work-Hard

unread,
May 11, 2020, 3:53:41 PM5/11/20
to Ansible Project
Hi Dick, 
The script from the article reports a 404 error for Ec2 external inventory script. Do you have it handy ?

Reply all
Reply to author
Forward
0 new messages