We use ansible to configure some hosts, including IP configuration. We do not want to use a DHCP server. Sometimes we add new hosts to the network.
Those new hosts are in one ip address range and the existing production hosts are in another. We just put new hosts in the first network and then let ansible configure them, test them and change the IP to the production range.
Ansible is run regularly via cron.
However, when there a no new hosts, ansible will report an unreachable error. No new hosts is the usual situation. How can I suppress that or make it less prominent?
Basically our playbook looks like this:
---
# configure existing hosts
- hosts: production
tasks:
- name: do regular maintenance
# ...
- hosts: new
# Does not seem to do anything
ignore_errors: True
tasks:
- name: configure freshly discovered host
# ...
- name: test freshly discovered host
# ...
- name: change ip config to production network
# ...
The /etc/ansible/hosts looks like this:
[production]
192.168.2.[11:255]
[new]
# those are firewalled
192.168.2.[1:10]
When I run this I see a big red
PLAY RECAP ****************************************************
192.168.2.1 : ok=0 changed=0 unreachable=1 failed=0
[...]
at the end, which is confusing for my colleagues.
I have seen this question, and I figured that if I use ignore_errors but don't set a flag it should silently skip the unreachable hosts, but it does not seem to have any effect.
Best Answer
Going to add this answer: a fix was added in Ansible 2.7: https://github.com/ansible/ansible/blob/stable-2.7/changelogs/CHANGELOG-v2.7.rst#major-changes
EDIT: From personal experience, I need to add
ignore_errors
along with it for the playbook to actually continue.