summaryrefslogtreecommitdiff
path: root/test/integration/targets/incidental_inventory_foreman/inspect_cache.yml
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/incidental_inventory_foreman/inspect_cache.yml')
-rw-r--r--test/integration/targets/incidental_inventory_foreman/inspect_cache.yml31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/integration/targets/incidental_inventory_foreman/inspect_cache.yml b/test/integration/targets/incidental_inventory_foreman/inspect_cache.yml
new file mode 100644
index 0000000000..c91f4c3868
--- /dev/null
+++ b/test/integration/targets/incidental_inventory_foreman/inspect_cache.yml
@@ -0,0 +1,31 @@
+---
+- hosts: localhost
+ vars:
+ foreman_stub_host: "{{ lookup('env', 'FOREMAN_HOST') }}"
+ foreman_stub_port: "{{ lookup('env', 'FOREMAN_PORT') }}"
+ foreman_stub_api_path: /api/v2
+ cached_hosts_key: "http://{{ foreman_stub_host }}:{{ foreman_stub_port }}{{ foreman_stub_api_path }}/hosts"
+ tasks:
+ - name: verify a cache file was created
+ find:
+ path:
+ - ./foreman_cache
+ register: matching_files
+
+ - assert:
+ that:
+ - matching_files.matched == 1
+ - name: read the cached inventory
+ set_fact:
+ contents: "{{ lookup('file', matching_files.files.0.path) }}"
+
+ - name: extract all the host names
+ set_fact:
+ cached_hosts: "{{ contents[cached_hosts_key] | json_query('[*].name') }}"
+
+ - assert:
+ that:
+ "'{{ item }}' in cached_hosts"
+ loop:
+ - "v6.example-780.com"
+ - "c4.j1.y5.example-487.com"