tripleo-ansible/tripleo_ansible/roles/tripleo-hosts-entries/molecule/default/verify.yml

49 lines
1.5 KiB
YAML

---
# 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.internal_api.localdomain centos7.internal_api
- 192.168.24.1 fedora28.localdomain fedora28
- 192.168.24.1 fedora28.ctlplane.localdomain fedora28.ctlplane
- 172.17.0.1 fedora28.internal_api.localdomain fedora28.internal_api
- 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