Debian Codegraph @

test/integration/targets/facts_d/tasks/main.yml

raw
1 # (c) 2014, James Tanner <[email protected]>
2 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
3
4 - name: prep for local facts tests
5 block:
6 - name: set factdir var
7 set_fact: fact_dir={{remote_tmp_dir}}/facts.d
8
9 - name: create fact dir
10 file: path={{ fact_dir }} state=directory
11
12 - name: copy local facts test files
13 copy: src={{ item['name'] }}.fact dest={{ fact_dir }}/ mode={{ item['mode']|default(omit) }}
14 loop:
15 - name: preferences
16 - name: basdscript
17 mode: '0775'
18 - name: goodscript
19 mode: '0775'
20 - name: unreadable
21 mode: '0000'
22 - name: bad
23
24 - name: Create dangling symlink
25 file:
26 path: "{{ fact_dir }}/dead_symlink.fact"
27 src: /tmp/dead_symlink
28 force: yes
29 state: link
30
31 - name: force fact gather to get ansible_local
32 setup:
33 fact_path: "{{ fact_dir | expanduser }}"
34 filter: "*local*"
35 register: setup_result
36
37 - name: show gathering results if rerun with -vvv
38 debug: var=setup_result verbosity=3
39
40 - name: check for expected results from local facts
41 assert:
42 that:
43 - "'ansible_facts' in setup_result"
44 - "'ansible_local' in setup_result.ansible_facts"
45 - "'ansible_env' not in setup_result.ansible_facts"
46 - "'ansible_user_id' not in setup_result.ansible_facts"
47 - "'preferences' in setup_result.ansible_facts['ansible_local']"
48 - "'general' in setup_result.ansible_facts['ansible_local']['preferences']"
49 - "'bar' in setup_result.ansible_facts['ansible_local']['preferences']['general']"
50 - "setup_result.ansible_facts['ansible_local']['preferences']['general']['bar'] == 'loaded'"
51 - setup_result['ansible_facts']['ansible_local']['goodscript']['script_ran']|bool
52 - setup_result['ansible_facts']['ansible_local']['basdscript'].startswith("Failure executing fact script")
53 - setup_result['ansible_facts']['ansible_local']['unreadable'].startswith('error loading facts')
54 - setup_result['ansible_facts']['ansible_local']['dead_symlink'].startswith('Could not stat fact')
55 - setup_result['ansible_facts']['ansible_local']['bad'].startswith('error loading facts as ini')