--- # Copyright 2019 Red Hat, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - name: Verify hosts: all become: true gather_facts: false tasks: - name: Check if hosts lines were written to hosts file lineinfile: path: /tmp/hosts line: "{{ item }}" register: hosts_result check_mode: true loop: - 192.168.24.2 centos7.localdomain centos7 - 192.168.24.2 centos7.ctlplane.localdomain centos7.ctlplane - 172.17.0.2 centos7.internalapi.localdomain centos7.internalapi - 192.168.24.1 centos8.localdomain centos8 - 192.168.24.1 centos8.ctlplane.localdomain centos8.ctlplane - 172.17.0.1 centos8.internalapi.localdomain centos8.internalapi - name: slurp /tmp/hosts slurp: path: /tmp/hosts register: slurp_hosts - name: Show /tmp/hosts debug: var: slurp_hosts['content'] | b64decode - name: Fail if hosts was changed debug: msg: "hosts was changed" failed_when: hosts_result is changed