9f856a4964
* config lookup can query plugin settings
74 lines
2.6 KiB
YAML
74 lines
2.6 KiB
YAML
- 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"]
|