[tutorial Ansible 1.3] default variable
Proxy configuration =================== env_proxy.port has a default value with ansible we needs to define a new mapping variable: env_proxy_all Examples of Ops inventory file ============================== 1/ VALID: --- env_proxy: host: proxy.example.net 2/ VALID: --- env_proxy: host: proxy.example.net port: "3129"
This commit is contained in:
parent
1599acfeb5
commit
d1a9c3321c
4 changed files with 12 additions and 4 deletions
6
Ansible/asserts/display.yml
Normal file
6
Ansible/asserts/display.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
- name: Display variable env_proxy_all.host
|
||||
ansible.builtin.debug:
|
||||
var: env_proxy_all.host
|
||||
- name: Display variable env_proxy_all.port
|
||||
ansible.builtin.debug:
|
||||
var: env_proxy_all.port
|
|
@ -9,6 +9,5 @@
|
|||
- name: Test variable env_proxy.port
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- env_proxy.port is defined
|
||||
- env_proxy.port is string or env_proxy.port is integer
|
||||
- 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 !"
|
||||
|
|
4
Ansible/inventory/group_vars/all/proxy.yml
Normal file
4
Ansible/inventory/group_vars/all/proxy.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
env_proxy_all:
|
||||
host: "{{ env_proxy.host }}"
|
||||
port: "{{ env_proxy.port | default(3128) }}"
|
3
doc.md
3
doc.md
|
@ -16,14 +16,13 @@ to make network connections to network services outside its own network.
|
|||
| Parameter | Comment |
|
||||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| **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 server’s 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/>**Example:** 3128 |
|
||||
| **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 |
|
||||
|
||||
# Example with mandatories variables
|
||||
|
||||
```
|
||||
env_proxy:
|
||||
host: proxy.silique.fr
|
||||
port: '3128'
|
||||
```
|
||||
|
||||
# Example with all variables
|
||||
|
|
Loading…
Reference in a new issue