[tutorial Ansible 1.5] variable is not mandatory

Proxy configuration
===================

The variable env_proxy.no_proxy is not mandatory

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

Modify the file: Ops/group_vars/all.yml

1/ VALID:

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

2/ VALID:

---
env_proxy:
  host: proxy.example.net
This commit is contained in:
egarette@silique.fr 2023-12-18 11:34:32 +01:00
parent 76232d8b6b
commit 6ff4392e2b
3 changed files with 4 additions and 9 deletions

View file

@ -14,8 +14,7 @@
- name: Test variable env_proxy.no_proxy
ansible.builtin.assert:
that:
- env_proxy.no_proxy is defined
- env_proxy.no_proxy | type_debug == 'list'
- env_proxy.no_proxy is not defined or 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:
@ -25,3 +24,4 @@
loop: "{{ env_proxy.no_proxy }}"
loop_control:
loop_var: no_proxy
when: env_proxy.no_proxy is defined

View file

@ -2,4 +2,4 @@
env_proxy_all:
host: "{{ env_proxy.host }}"
port: "{{ env_proxy.port | default(3128) }}"
no_proxy: "{{ env_proxy.no_proxy }}"
no_proxy: "{{ env_proxy.no_proxy | default([])}}"

7
doc.md
View file

@ -17,18 +17,13 @@ to make network connections to network services outside its own network.
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **host**<br/>`mandatory`<br/>**Type:** [`domainname`](https://forge.cloud.silique.fr/stove/rougail/src/branch/main/doc/variable/README.md#le-type-de-la-variable) | The proxy servers address.<br/>Specifies the hostname of proxy server to enable proxy server access to all of your HTTP(s) requests. .<br/>**Example:** proxy.silique.fr |
| **port**<br/>`mandatory`<br/>**Type:** [`port`](https://forge.cloud.silique.fr/stove/rougail/src/branch/main/doc/variable/README.md#le-type-de-la-variable) | The proxy server's port.<br/>**Default:** 3128 |
| **no_proxy**<br/>`mandatory`, `multiple`<br/>**Type:** [`domainname`](https://forge.cloud.silique.fr/stove/rougail/src/branch/main/doc/variable/README.md#le-type-de-la-variable) | Exclude proxy server.<br/>Network address(es), network address range(s) and domains to exclude from using the proxy when initiating connection(s). .<br/>**Examples:** 192.168.1.1, 192.168.10.0/24, www.silique.fr, .internal.silique.fr |
| **no_proxy**<br/>`multiple`<br/>**Type:** [`domainname`](https://forge.cloud.silique.fr/stove/rougail/src/branch/main/doc/variable/README.md#le-type-de-la-variable) | Exclude proxy server.<br/>Network address(es), network address range(s) and domains to exclude from using the proxy when initiating connection(s). .<br/>**Examples:** 192.168.1.1, 192.168.10.0/24, www.silique.fr, .internal.silique.fr |
# Example with mandatories variables
```
env_proxy:
host: proxy.silique.fr
no_proxy:
- 192.168.1.1
- 192.168.10.0/24
- www.silique.fr
- .internal.silique.fr
```
# Example with all variables