rougail-tutorials/Ansible/asserts/proxy.yml
Emmanuel Garette f1a276f3d5 [tutorial Ansible 1.4] a variable with multiple values
Proxy configuration
===================

Add env_proxy.no_proxy for proxy exception

---
env_proxy:
  host: proxy.example.net
  no_proxy:
    - localhost
    - 192.168.1.1
    - .ac-dijon.fr

Examples of Ops inventory file
==============================

1/ INVALID, must be a list:

---
env_proxy:
  host: proxy.example.net
  no_proxy: localhost

2/ INVALID, an integer:

---
env_proxy:
  host: proxy.example.net
  no_proxy:
    - 1

3/ INVALID, without value:

---
env_proxy:
  host: proxy.example.net
2023-12-18 11:34:32 +01:00

27 lines
968 B
YAML

---
- name: Test variable env_proxy.host
ansible.builtin.assert:
that:
- env_proxy is defined
- env_proxy.host is defined
- env_proxy.host is string
fail_msg: "La variable n'existe pas ou est de mauvais type !"
- name: Test variable env_proxy.port
ansible.builtin.assert:
that:
- env_proxy.port is not defined or env_proxy.port is string or env_proxy.port is integer
fail_msg: "La variable n'existe pas ou est de mauvais type !"
- name: Test variable env_proxy.no_proxy
ansible.builtin.assert:
that:
- env_proxy.no_proxy is defined
- env_proxy.no_proxy | type_debug == 'list'
fail_msg: "La variable n'existe pas ou est de mauvais type !"
- name: Test variable env_proxy.no_proxy is a list of string
ansible.builtin.assert:
that:
- no_proxy is string
fail_msg: "La variable n'existe pas ou est de mauvais type !"
loop: "{{ env_proxy.no_proxy }}"
loop_control:
loop_var: no_proxy