From 0351a7af27aad8b30ff8a70870a462aa4824ef7d Mon Sep 17 00:00:00 2001 From: David Moreau-Simard Date: Wed, 20 Sep 2017 16:00:13 -0400 Subject: [PATCH] Add integration tests for multi-node-hosts-file Change-Id: I633889011d25f120a936a145bdf6e12c3b89133f --- tests/multi-node-hosts-file.yaml | 25 +++++++++++++++++++++++++ tests/multinode.yaml | 1 + 2 files changed, 26 insertions(+) create mode 100644 tests/multi-node-hosts-file.yaml diff --git a/tests/multi-node-hosts-file.yaml b/tests/multi-node-hosts-file.yaml new file mode 100644 index 00000000..4334e534 --- /dev/null +++ b/tests/multi-node-hosts-file.yaml @@ -0,0 +1,25 @@ +- name: Test the multi-node-hosts-file role + hosts: all + roles: + - multi-node-hosts-file + post_tasks: + - name: lookup hosts file + command: cat /etc/hosts + register: hosts_file + + - name: Set up the list of hosts and addresses + set_fact: + host_addresses: > + {% set hosts = [] -%} + {% for host, vars in hostvars.items() -%} + {% set _ = hosts.append({'host': host, 'address': vars['nodepool']['private_ipv4']}) -%} + {% endfor -%} + {{- hosts -}} + + - name: assert that hosts are in the hosts file + vars: + line: "{{ item.address }} {{ item.host }}" + assert: + that: + - "line in hosts_file.stdout" + with_list: "{{ host_addresses }}" diff --git a/tests/multinode.yaml b/tests/multinode.yaml index 052954b9..48ead35f 100644 --- a/tests/multinode.yaml +++ b/tests/multinode.yaml @@ -3,3 +3,4 @@ # Roles that are part of the 'multinode' job - include: multi-node-known-hosts.yaml +- include: multi-node-hosts-file.yaml