Our integration gateways push files to partners over SFTP through site to site VPNs, and several of those partner hosts have no public DNS. A role called partner_vpn writes their names and addresses into /etc/hosts with blockinfile. It had done that, unchanged, for two years.
In October the monitoring team added a role to the same playbook that writes the names of our metrics collectors into /etc/hosts, also with blockinfile. It ran after partner_vpn. The play was green. That night the push to our largest supplier failed with Could not resolve hostname, and so did two others.
blockinfile finds its block by the marker lines around it, and the default marker is the same for every task that does not set one: # BEGIN ANSIBLE MANAGED BLOCK and # END ANSIBLE MANAGED BLOCK. Neither role set one. When the monitoring task ran, it found the partner block, recognised the markers as its own and replaced the contents with its collector entries.…