summaryrefslogtreecommitdiff
path: root/test/integration/targets/lookup_config/tasks/main.yml
blob: 356d2f80578e1587ab7c7d3c95d934165516c02b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
- name: Verify lookup_config errors with no on_missing (failure expected)
  set_fact:
    foo: '{{lookup("config", "THIS_DOES_NOT_EXIST")}}'
  ignore_errors: yes
  register: lookup_config_1

- name: Verify lookup_config errors with on_missing=error (failure expected)
  set_fact:
    foo: '{{lookup("config", "THIS_DOES_NOT_EXIST", on_missing="error")}}'
  ignore_errors: yes
  register: lookup_config_2

- name: Verify lookup_config does not error with on_missing=skip
  set_fact:
    lookup3: '{{lookup("config", "THIS_DOES_NOT_EXIST", on_missing="skip")}}'
  register: lookup_config_3

# TODO: Is there a decent way to check that the warning is actually triggered?
- name: Verify lookup_config does not error with on_missing=warn (warning expected)
  set_fact:
    lookup4: '{{lookup("config", "THIS_DOES_NOT_EXIST", on_missing="warn")}}'
  register: lookup_config_4

- name: Verify lookup_config errors with invalid on_missing (failure expected)
  set_fact:
    foo: '{{lookup("config", "THIS_DOES_NOT_EXIST", on_missing="boo")}}'
  ignore_errors: yes
  register: lookup_config_5

- name: Verify lookup_config errors with invalid param type (failure expected)
  set_fact:
    foo: '{{lookup("config", 1337)}}'
  ignore_errors: yes
  register: lookup_config_6

- name: Verify lookup_config errors with callable arg (failure expected)
  set_fact:
    foo: '{{lookup("config", "ConfigManager")}}'
  ignore_errors: yes
  register: lookup_config_7

- name: remote user and port for ssh connection
  set_fact:
    ssh_user_and_port: '{{q("config", "remote_user", "port", plugin_type="connection", plugin_name="ssh")}}'
  vars:
    ansible_ssh_user: lola
    ansible_ssh_port: 2022

- name: remote_tmp for sh shell plugin
  set_fact:
    yolo_remote: '{{q("config", "remote_tmp", plugin_type="shell", plugin_name="sh")}}'
  vars:
    ansible_remote_tmp: yolo

- name: Verify lookup_config
  assert:
    that:
      - '"meow" in lookup("config", "ANSIBLE_COW_ACCEPTLIST")'
      - lookup_config_1 is failed
      - '"Unable to find setting" in lookup_config_1.msg'
      - lookup_config_2 is failed
      - '"Unable to find setting" in lookup_config_2.msg'
      - lookup_config_3 is success
      - 'lookup3|length == 0'
      - lookup_config_4 is success
      - 'lookup4|length == 0'
      - lookup_config_5 is failed
      - '"valid values are" in lookup_config_5.msg'
      - lookup_config_6 is failed
      - '"Invalid setting identifier" in lookup_config_6.msg'
      - lookup_config_7 is failed
      - '"Invalid setting" in lookup_config_7.msg'
      - ssh_user_and_port == ['lola', 2022]
      - yolo_remote == ["yolo"]