From e87d2d69b7eeb5061d3737cd0e8f1376d649caeb Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 18 Dec 2023 11:34:33 +0100 Subject: [PATCH] [tutorial Ansible 2.1] a choice option Apero configuration =================== Login is now mandatory Use an existant user login --- env_apero: access: - login: srep password: oIJuheu27__u2 - login: snom password: oIJuheu27__u2 env_srep: apero_user: srep Examples of Ops inventory file ============================== 1/ INVALID, use an unexisted user: --- env_apero: access: - login: srep password: oIJuheu27__u2 - login: snom password: oIJuheu27__u2 env_srep: apero_user: unknown --- Ansible/asserts/apero.yml | 24 ++++++++++++++++++++++-- doc.md | 16 +++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/Ansible/asserts/apero.yml b/Ansible/asserts/apero.yml index 41e08dc..4872c4c 100644 --- a/Ansible/asserts/apero.yml +++ b/Ansible/asserts/apero.yml @@ -2,10 +2,10 @@ - name: Test variable env_apero.access ansible.builtin.assert: that: + - env_apero is defined - env_apero.access is defined - env_apero.access | type_debug == 'list' fail_msg: "env_apero.access n'existe pas ou est de mauvais type !" - when: env_apero is defined - name: Test variable env_apero.access.login env_apero.access.password ansible.builtin.assert: that: @@ -16,4 +16,24 @@ loop: "{{ env_apero.access }}" loop_control: loop_var: access - when: env_apero is defined and env_apero.access is defined +- name: Test variable env_srep.apero_user + ansible.builtin.assert: + that: + - env_srep is defined + - env_srep.apero_user is defined + fail_msg: "La variable n'existe pas ou est de mauvais type !" +- name: Test variable env_srep.apero_user + ansible.builtin.set_fact: + found: false +- name: Test variable env_srep.apero_user + ansible.builtin.set_fact: + found: true + when: access.login == env_srep.apero_user + loop: "{{ env_apero.access }}" + loop_control: + loop_var: access +- name: Test variable env_srep.apero_user + ansible.builtin.assert: + that: + - found is true + fail_msg: "La variable n'existe pas ou est de mauvais type !" diff --git a/doc.md b/doc.md index 02bba88..a5628cf 100644 --- a/doc.md +++ b/doc.md @@ -31,14 +31,26 @@ This family is a leadership. | Parameter | Comment | |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| **login**
`multiple`
**Type:** [`unix_user`](https://forge.cloud.silique.fr/stove/rougail/src/branch/main/doc/variable/README.md#le-type-de-la-variable) | Login name.
The account name is typically the name of foreign services. .
**Example:** srep | +| **login**
`mandatory`, `multiple`
**Type:** [`unix_user`](https://forge.cloud.silique.fr/stove/rougail/src/branch/main/doc/variable/README.md#le-type-de-la-variable) | Login name.
The account name is typically the name of foreign services. .
**Example:** srep | | **password**
`mandatory`
**Type:** [`secret`](https://forge.cloud.silique.fr/stove/rougail/src/branch/main/doc/variable/README.md#le-type-de-la-variable) | Password. | +## SREP service (env_srep) + +| Parameter | Comment | +|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **apero_user**
`mandatory`
**Type:** [`choice`](https://forge.cloud.silique.fr/stove/rougail/src/branch/main/doc/variable/README.md#le-type-de-la-variable) | Account to access to Apero service.
**Choices:** see variable "env_apero.access.login"
**Example:** srep | + # Example with mandatories variables ``` env_proxy: host: proxy.silique.fr +env_apero: + access: + - login: srep + password: xxx +env_srep: + apero_user: srep ``` # Example with all variables @@ -56,4 +68,6 @@ env_apero: access: - login: srep password: xxx +env_srep: + apero_user: srep ```