Compare commits
No commits in common. "1.1" and "1.0" have entirely different histories.
25 changed files with 921 additions and 99 deletions
39
Ansible/asserts/apero.yml
Normal file
39
Ansible/asserts/apero.yml
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
---
|
||||||
|
- 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 !"
|
||||||
|
- name: Test variable env_apero.access.login env_apero.access.password
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- access is mapping
|
||||||
|
- access.login is defined
|
||||||
|
- access.password is defined
|
||||||
|
fail_msg: "La variable n'existe pas ou est de mauvais type !"
|
||||||
|
loop: "{{ env_apero.access }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: access
|
||||||
|
- 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 !"
|
21
Ansible/asserts/display.yml
Normal file
21
Ansible/asserts/display.yml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
- 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
|
||||||
|
- name: Display variable env_proxy_all.no_proxy
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: env_proxy_all.no_proxy
|
||||||
|
- name: Display variable env_srep_all.apero_user
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: env_srep_all.apero_user
|
||||||
|
- name: Display variable env_srep_all.apero_password
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: env_srep_all.apero_password
|
||||||
|
- name: Display variable env_nfs_all.configure
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: env_nfs_all.configure
|
||||||
|
- name: Display variable env_nfs_all.server
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: env_nfs_all.server
|
10
Ansible/asserts/nfs.yml
Normal file
10
Ansible/asserts/nfs.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
- name: NFS | Assert variables | test env_nfs_all
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- env_nfs_all is defined
|
||||||
|
- env_nfs_all.configure is defined
|
||||||
|
- env_nfs_all.configure is boolean
|
||||||
|
- not env_nfs_all.configure or env_nfs.server is defined
|
||||||
|
- not env_nfs_all.configure or env_nfs.server is string
|
||||||
|
fail_msg:
|
||||||
|
- Please configure your NFS manually
|
9
Ansible/asserts/omogen.yml
Normal file
9
Ansible/asserts/omogen.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
- name: Test variable env_omogen
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- env_omogen is defined
|
||||||
|
- env_omogen.keystore is defined
|
||||||
|
- env_omogen.keystore is string
|
||||||
|
- env_omogen.keystore.endswith('.jks')
|
||||||
|
fail_msg: "env_omogen.keystore n'existe pas ou est de mauvais type !"
|
27
Ansible/asserts/proxy.yml
Normal file
27
Ansible/asserts/proxy.yml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
---
|
||||||
|
- 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 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:
|
||||||
|
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
|
||||||
|
when: env_proxy.no_proxy is defined
|
5
Ansible/inventory/group_vars/all/apero.yml
Normal file
5
Ansible/inventory/group_vars/all/apero.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
env_srep_all:
|
||||||
|
apero_user: "{{ env_srep.apero_user }}"
|
||||||
|
apero_password: "{{ (env_apero.access | selectattr('login', 'equalto', env_srep.apero_user))[0].password }}"
|
||||||
|
|
5
Ansible/inventory/group_vars/all/nfs.yml
Normal file
5
Ansible/inventory/group_vars/all/nfs.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
env_nfs_all:
|
||||||
|
configure: "{{ env_nfs.configure | default(false) }}"
|
||||||
|
server: "{{ env_nfs.server | default('') }}"
|
||||||
|
device: "{{ env_nfs.server | default('') }}:/nfs"
|
5
Ansible/inventory/group_vars/all/proxy.yml
Normal file
5
Ansible/inventory/group_vars/all/proxy.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
env_proxy_all:
|
||||||
|
host: "{{ env_proxy.host }}"
|
||||||
|
port: "{{ env_proxy.port | default(3128) }}"
|
||||||
|
no_proxy: "{{ env_proxy.no_proxy | default([])}}"
|
1
Ansible/inventory/host.yml
Normal file
1
Ansible/inventory/host.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
localhost
|
0
Ops/group_vars/.gitkeep
Normal file
0
Ops/group_vars/.gitkeep
Normal file
1
Ops/host.yml
Normal file
1
Ops/host.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
localhost
|
130
README.md
130
README.md
|
@ -1,108 +1,40 @@
|
||||||
# Description
|
A repository with comparisons between a Rougail catalog and Ansible inventories.
|
||||||
|
|
||||||
This tutorial shows to you an example of Rougail use on how to set a proxy in the Mozilla Firefox browser.
|
Each commit presents a step of the tutorial.
|
||||||
|
|
||||||
More precisely, this tutorial aims at reproducing this [Mozilla Firefox](https://www.mozilla.org/firefox/new/) settings page:
|
You need a working version of rougail:
|
||||||
|
|
||||||
![Firefox Proxy setting](firefox.png)
|
|
||||||
|
|
||||||
And the integration of part of the [Firefox FoxyProxy plugin](https://addons.mozilla.org/firefox/addon/foxyproxy-standard/).
|
|
||||||
|
|
||||||
The idea is to have a namespace specific to FoxyProxy and to find in it part of the settings that we will have made in the main namespace.
|
|
||||||
|
|
||||||
This is what the page looks like:
|
|
||||||
|
|
||||||
![Foxyproxy Proxy setting](foxyproxy.png)
|
|
||||||
|
|
||||||
# Installation
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# python -m venv rougail
|
python -m venv venv
|
||||||
# . rougail/bin/activate
|
. venv/bin/activate
|
||||||
# pip install rougail-cli rougail-output-exporter rougail-output-doc rougail-user-data-file
|
pip install rougail
|
||||||
|
git clone https://forge.cloud.silique.fr/stove/rougail-tutorials.git
|
||||||
|
cd rougail-tutorials
|
||||||
```
|
```
|
||||||
|
|
||||||
# Summary
|
|
||||||
|
|
||||||
Each step is a separerate commit. You can navigate to history to discover different aspect to the Rougail format.
|
|
||||||
|
|
||||||
- Getting started
|
Proxy configuration
|
||||||
- Structural file
|
|
||||||
- [[tutorial 000] A structured file with format version](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_000/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_000~1..v1.1_000))
|
|
||||||
- [[tutorial 001] The format version in commandline](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_001/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_001~1..v1.1_001))
|
|
||||||
- Variable: choice the proxy mode
|
|
||||||
- [[tutorial 010] A first variable with only a name](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_010/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_010~1..v1.1_010))
|
|
||||||
- [[tutorial 011] The variable description](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_011/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_011~1..v1.1_011))
|
|
||||||
- [[tutorial 012] A default value](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_012/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_012~1..v1.1_012))
|
|
||||||
- [[tutorial 013] A variable with type "choice"](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_013/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_013~1..v1.1_013))
|
|
||||||
- [[tutorial 014] Choice type is optional](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_014/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_014~1..v1.1_014))
|
|
||||||
- Family: proxy manual
|
|
||||||
- [[tutorial 020] A family](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_020/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_020~1..v1.1_020))
|
|
||||||
- [[tutorial 021] A sub family](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_021/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_021~1..v1.1_021))
|
|
||||||
- [[tutorial 022] A variable inside sub family](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_022/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_022~1..v1.1_022))
|
|
||||||
- [[tutorial 023] Family type is optional](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_023/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_023~1..v1.1_023))
|
|
||||||
- HTTP Manual mode
|
|
||||||
- Variable: type and type parameters
|
|
||||||
- [[tutorial 024] A variable with type "domainname"](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_024/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_024~1..v1.1_024))
|
|
||||||
- [[tutorial 025] A variable with type's parameters](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_025/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_025~1..v1.1_025))
|
|
||||||
- [[tutorial 026] A variable with type "port"](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_026/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_026~1..v1.1_026))
|
|
||||||
- Property: disabled
|
|
||||||
- [[tutorial 027] A disabled family](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_027/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_027~1..v1.1_027))
|
|
||||||
- [[tutorial 028] A conditional disabled family with a variable](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_028/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_028~1..v1.1_028))
|
|
||||||
- [[tutorial 029] Type variable is optional](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_029/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_029~1..v1.1_029))
|
|
||||||
- HTTP proxy provides HTTPS proxy
|
|
||||||
- [[tutorial 030] A variable with type "boolean"](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_030/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_030~1..v1.1_030))
|
|
||||||
- [[tutorial 031] Bases type is optional if default value](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_031/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_031~1..v1.1_031))
|
|
||||||
- HTTPS Manual mode
|
|
||||||
- Property: hidden
|
|
||||||
- [[tutorial 032] Copy HTTP manual proxy to HTTPS manual proxy](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_032/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_032~1..v1.1_032))
|
|
||||||
- [[tutorial 033] An hidden family](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_033/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_033~1..v1.1_033))
|
|
||||||
- [[tutorial 034] A conditional hidden family with a variable](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_034/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_034~1..v1.1_034))
|
|
||||||
- Variable: calculated default value
|
|
||||||
- [[tutorial 035] A calculated default value](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_035/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_035~1..v1.1_035))
|
|
||||||
- [[tutorial 036] Variable type and parameters type are copied with default value](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_036/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_036~1..v1.1_036))
|
|
||||||
- SOCKS Manual mode
|
|
||||||
- Family: dynamic
|
|
||||||
- [[tutorial 040] Family: a dynamic family](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_040/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_040~1..v1.1_040))
|
|
||||||
- Property: Jinja and identifier condition
|
|
||||||
- [[tutorial 041] A conditional hidden family with Jinja](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_041/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_041~1..v1.1_041))
|
|
||||||
- [[tutorial 042] Jinja with a parameter](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_042/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_042~1..v1.1_042))
|
|
||||||
- [[tutorial 043] Jinja with a description](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_043/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_043~1..v1.1_043))
|
|
||||||
- [[tutorial 044] A conditional disabled variable with identifier](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_044/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_044~1..v1.1_044))
|
|
||||||
- Shorthand mode
|
|
||||||
- [[tutorial 050] Family: "shorthand" mode](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_050/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_050~1..v1.1_050))
|
|
||||||
- [[tutorial 051] Variable: "shorthand" mode](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_051/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_051~1..v1.1_051))
|
|
||||||
- Automatic proxy
|
|
||||||
- [[tutorial 060] A variable with type "web_address"](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_060/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_060~1..v1.1_060))
|
|
||||||
- [[tutorial 061] A conditional disabled variable](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_061/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_061~1..v1.1_061))
|
|
||||||
- Address for which proxy will be desactivated
|
|
||||||
- Variable: multi and non mandatory
|
|
||||||
- [[tutorial 070] A variable with type "domainname", parameters type and disabled](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_070/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_070~1..v1.1_070))
|
|
||||||
- [[tutorial 071] A variable with multiple value](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_071/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_071~1..v1.1_071))
|
|
||||||
- [[tutorial 072] A non mandatory variable](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_072/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_072~1..v1.1_072))
|
|
||||||
- Variable: extra description
|
|
||||||
- [[tutorial 073] Examples](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_073/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_073~1..v1.1_073))
|
|
||||||
- [[tutorial 074] Help](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_074/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_074~1..v1.1_074))
|
|
||||||
- Prompt for authentication if password is saved
|
|
||||||
- [[tutorial 075] A variable](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_075/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_075~1..v1.1_075))
|
|
||||||
- Use proxy DNS when using SOCKS v5
|
|
||||||
- [[tutorial 076] A variable](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_076/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_076~1..v1.1_076))
|
|
||||||
- [[tutorial 077] Jinja calculation for an hidden variable with a potential inaccessible varible](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_077/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_077~1..v1.1_077))
|
|
||||||
- [[tutorial 078] A variable in avanced mode](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_078/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_078~1..v1.1_078))
|
|
||||||
- DNS over HTTPS
|
|
||||||
- [[tutorial 080] A boolean variable](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_080/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_080~1..v1.1_080))
|
|
||||||
- [[tutorial 081] A choice variable](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_081/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_081~1..v1.1_081))
|
|
||||||
- [[tutorial 082] A web_address variable ](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_082/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_082~1..v1.1_082))
|
|
||||||
- [[tutorial 083] A variable with custom validation](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_083/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_083~1..v1.1_083))
|
|
||||||
- Namespace
|
|
||||||
- Relative path
|
|
||||||
- [[tutorial 090] Variable in same family](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_090/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_090~1..v1.1_090))
|
|
||||||
- [[tutorial 091] Variable in parent family](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_091/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_091~1..v1.1_091))
|
|
||||||
- [[tutorial 092] Namespace](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_092/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_092~1..v1.1_092))
|
|
||||||
- [[tutorial 100] xxx](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_100/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_100~1..v1.1_100))
|
|
||||||
- [[tutorial 101] xxx](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_101/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_101~1..v1.1_101))
|
|
||||||
- [[tutorial 102] xxx](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_102/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_102~1..v1.1_102))
|
|
||||||
- [[tutorial 103] xxx](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_103/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_103~1..v1.1_103))
|
|
||||||
- [[tutorial 104] xxx](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_104/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_104~1..v1.1_104))
|
|
||||||
- [[tutorial 110] xxx](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_110/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_110~1..v1.1_110))
|
|
||||||
|
|
||||||
|
- [tutorial 1.0] a single string variable
|
||||||
|
- [tutorial 1.1] advanced hostname variable
|
||||||
|
- [tutorial 1.2] a port variable
|
||||||
|
- [tutorial 1.3] default variable
|
||||||
|
- [tutorial 1.4] a variable with multiple values
|
||||||
|
- [tutorial 1.5] variable is not mandatory
|
||||||
|
|
||||||
|
Apero
|
||||||
|
|
||||||
|
- [tutorial 2.0] a leadership family
|
||||||
|
- [tutorial 2.1] a choice option
|
||||||
|
- [tutorial 2.2] calculed variable
|
||||||
|
|
||||||
|
OMOGEN
|
||||||
|
|
||||||
|
- [tutorial 3.0] a validator
|
||||||
|
|
||||||
|
NFS configuration
|
||||||
|
|
||||||
|
- [tutorial 4.0] a boolean variable
|
||||||
|
- [tutorial 4.1] conditional disabled variable
|
||||||
|
- [tutorial 4.2] conditional disabled + hidden
|
||||||
|
|
469
Rougail/inventory.py
Executable file
469
Rougail/inventory.py
Executable file
|
@ -0,0 +1,469 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
from rougail import Rougail, RougailConfig
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
from pathlib import Path
|
||||||
|
#from pprint import pprint
|
||||||
|
from yaml import safe_load, dump
|
||||||
|
from json import dumps
|
||||||
|
from tiramisu.error import ValueOptionError, PropertiesOptionError
|
||||||
|
from traceback import print_exc
|
||||||
|
import tabulate as tabulate_module
|
||||||
|
from tabulate import tabulate
|
||||||
|
|
||||||
|
|
||||||
|
INV_DIR = 'inventory'
|
||||||
|
OPS_INV_DIR = 'Ops/group_vars'
|
||||||
|
ROUGAIL_VARIABLE_TYPE = 'https://forge.cloud.silique.fr/stove/rougail/src/branch/main/doc/variable/README.md#le-type-de-la-variable'
|
||||||
|
|
||||||
|
|
||||||
|
class Inventory:
|
||||||
|
|
||||||
|
###############################################
|
||||||
|
# Create TIRAMISU object
|
||||||
|
###############################################
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
tabulate_module.PRESERVE_WHITESPACE = True
|
||||||
|
RougailConfig['dictionaries_dir'] = ['Rougail/socle']
|
||||||
|
RougailConfig['variable_namespace'] = 'socle'
|
||||||
|
RougailConfig['tiramisu_cache'] = 'socle.py'
|
||||||
|
catalog_dir = Path('Rougail')
|
||||||
|
for extra in catalog_dir.iterdir():
|
||||||
|
if not extra.is_dir() or \
|
||||||
|
extra.name in ['socle', 'host', 'jinja_cache', INV_DIR]:
|
||||||
|
continue
|
||||||
|
RougailConfig['extra_dictionaries'][extra.name] = [extra.name]
|
||||||
|
RougailConfig['functions_file'] = 'Rougail/functions.py'
|
||||||
|
self.errors = []
|
||||||
|
self.warnings = []
|
||||||
|
|
||||||
|
def load(self):
|
||||||
|
rougail = Rougail()
|
||||||
|
self.conf = rougail.get_config()
|
||||||
|
self.conf.property.read_write()
|
||||||
|
self.objectspace = rougail.converted
|
||||||
|
# self.objectspace.annotate()
|
||||||
|
|
||||||
|
###############################################
|
||||||
|
# Read Ops file
|
||||||
|
###############################################
|
||||||
|
|
||||||
|
def load_inventory(self):
|
||||||
|
inventory_dir = Path(OPS_INV_DIR)
|
||||||
|
if not inventory_dir.is_dir():
|
||||||
|
return
|
||||||
|
with open('Ops/host.yml') as fh:
|
||||||
|
hostnames = fh.read().strip().split('\n')
|
||||||
|
self.conf.option('socle.hostnames').value.set(hostnames)
|
||||||
|
for file in inventory_dir.iterdir():
|
||||||
|
if file.suffix not in ['.yml', '.yaml']:
|
||||||
|
continue
|
||||||
|
with open(file) as fh:
|
||||||
|
values = safe_load(fh)
|
||||||
|
if not isinstance(values, dict):
|
||||||
|
continue
|
||||||
|
for key, value in values.items():
|
||||||
|
self.read_inventory(self.conf.option('socle'),
|
||||||
|
key,
|
||||||
|
value,
|
||||||
|
file,
|
||||||
|
)
|
||||||
|
|
||||||
|
def read_inventory(self,
|
||||||
|
conf,
|
||||||
|
key,
|
||||||
|
value,
|
||||||
|
file,
|
||||||
|
*,
|
||||||
|
index=None,
|
||||||
|
):
|
||||||
|
sub_conf = conf.option(key, index)
|
||||||
|
try:
|
||||||
|
isoptiondescription = sub_conf.isoptiondescription()
|
||||||
|
except AttributeError as err:
|
||||||
|
self.warnings.append(f'"{key}" est inconnu dans "{conf.path()}" mais est défini dans "{file}"')
|
||||||
|
return
|
||||||
|
if isoptiondescription:
|
||||||
|
if not sub_conf.isleadership():
|
||||||
|
if not isinstance(value, dict):
|
||||||
|
print('pffff')
|
||||||
|
return
|
||||||
|
for sub_key, sub_value in value.items():
|
||||||
|
self.read_inventory(sub_conf,
|
||||||
|
sub_key,
|
||||||
|
sub_value,
|
||||||
|
file,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
if not isinstance(value, list):
|
||||||
|
return
|
||||||
|
leader_option = sub_conf.leader().name()
|
||||||
|
leader_value = []
|
||||||
|
for leader in value:
|
||||||
|
if leader_option not in leader:
|
||||||
|
print('pffff')
|
||||||
|
return
|
||||||
|
leader_value.append(leader[leader_option])
|
||||||
|
self.read_inventory(sub_conf,
|
||||||
|
leader_option,
|
||||||
|
leader_value,
|
||||||
|
file,
|
||||||
|
)
|
||||||
|
for idx, sub_value in enumerate(value):
|
||||||
|
for sub_key, sub_value in sub_value.items():
|
||||||
|
if sub_key == leader_option:
|
||||||
|
continue
|
||||||
|
self.read_inventory(sub_conf,
|
||||||
|
sub_key,
|
||||||
|
sub_value,
|
||||||
|
file,
|
||||||
|
index=idx,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
sub_conf.value.set(value)
|
||||||
|
except ValueOptionError as err:
|
||||||
|
self.errors.append(str(err).replace('"', "'"))
|
||||||
|
except PropertiesOptionError as err:
|
||||||
|
self.warnings.append(f'"{err}" mais est défini dans "{file}"')
|
||||||
|
|
||||||
|
###############################################
|
||||||
|
# Host
|
||||||
|
###############################################
|
||||||
|
|
||||||
|
def get_hosts(self):
|
||||||
|
return self.conf.option('socle.hostnames').value.get()
|
||||||
|
|
||||||
|
###############################################
|
||||||
|
# Search unspecified mandatories variables
|
||||||
|
###############################################
|
||||||
|
|
||||||
|
def mandatory(self):
|
||||||
|
if self.errors:
|
||||||
|
return
|
||||||
|
for idx, option in enumerate(self.conf.value.mandatory()):
|
||||||
|
if not idx:
|
||||||
|
self.errors.append("Les variables suivantes sont obligatoires mais n'ont pas de valeur :")
|
||||||
|
self.errors.append(f' - {option.doc()}')
|
||||||
|
|
||||||
|
###############################################
|
||||||
|
# Tiramisu to inventory
|
||||||
|
###############################################
|
||||||
|
|
||||||
|
def display(self):
|
||||||
|
ret = {}
|
||||||
|
if self.errors:
|
||||||
|
ret['_errors'] = self.errors
|
||||||
|
else:
|
||||||
|
self.conf.property.read_only()
|
||||||
|
for line, value in self.conf.value.get().items():
|
||||||
|
self.parse_line(line,
|
||||||
|
line,
|
||||||
|
value,
|
||||||
|
ret,
|
||||||
|
False,
|
||||||
|
)
|
||||||
|
if len(ret) == 1:
|
||||||
|
ret = ret[list(ret)[0]]
|
||||||
|
if self.warnings:
|
||||||
|
ret['_warnings'] = self.warnings
|
||||||
|
print(dumps(ret))
|
||||||
|
|
||||||
|
def parse_line(self,
|
||||||
|
full_path,
|
||||||
|
line,
|
||||||
|
value,
|
||||||
|
dico,
|
||||||
|
leadership,
|
||||||
|
):
|
||||||
|
if '.' in line:
|
||||||
|
# it's a dict
|
||||||
|
family, variable = line.split('.', 1)
|
||||||
|
if '.' not in variable and self.conf.option(full_path.rsplit('.', 1)[0]).isleadership():
|
||||||
|
dico.setdefault(family, [])
|
||||||
|
leadership = True
|
||||||
|
else:
|
||||||
|
dico.setdefault(family, {})
|
||||||
|
leadership = False
|
||||||
|
self.parse_line(full_path,
|
||||||
|
variable,
|
||||||
|
value,
|
||||||
|
dico[family],
|
||||||
|
leadership,
|
||||||
|
)
|
||||||
|
elif leadership:
|
||||||
|
# it's a leadership
|
||||||
|
for val in value:
|
||||||
|
dico.append({k.rsplit('.', 1)[-1]: v for k, v in val.items()})
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
dico[line] = value
|
||||||
|
except ValueOptionError as err:
|
||||||
|
self.errors.append(str(err).replace('"', "'"))
|
||||||
|
|
||||||
|
###############################################
|
||||||
|
# DOC
|
||||||
|
###############################################
|
||||||
|
|
||||||
|
def display_doc(self):
|
||||||
|
examples_mini = {}
|
||||||
|
examples_all = {}
|
||||||
|
print(f'---\ngitea: none\ninclude_toc: true\n---\n')
|
||||||
|
print(f'# Variables')
|
||||||
|
for family_path in self.objectspace.parents['.']:
|
||||||
|
self.display_families(family_path,
|
||||||
|
family_path,
|
||||||
|
2,
|
||||||
|
False,
|
||||||
|
examples_mini,
|
||||||
|
examples_all,
|
||||||
|
)
|
||||||
|
if examples_mini:
|
||||||
|
print(f'# Example with mandatories variables')
|
||||||
|
print()
|
||||||
|
print('```')
|
||||||
|
print(dump(examples_mini, default_flow_style=False, sort_keys=False), end='')
|
||||||
|
print('```')
|
||||||
|
print()
|
||||||
|
print(f'# Example with all variables')
|
||||||
|
print()
|
||||||
|
print('```')
|
||||||
|
print(dump(examples_all, default_flow_style=False, sort_keys=False), end='')
|
||||||
|
print('```')
|
||||||
|
|
||||||
|
def display_families(self,
|
||||||
|
family_path,
|
||||||
|
true_family_path,
|
||||||
|
level,
|
||||||
|
family_type,
|
||||||
|
examples_mini,
|
||||||
|
examples_all,
|
||||||
|
):
|
||||||
|
variables = []
|
||||||
|
for idx, child_name in enumerate(self.objectspace.parents[true_family_path]):
|
||||||
|
if child_name in self.objectspace.variables:
|
||||||
|
properties = self.objectspace.properties[child_name]
|
||||||
|
if ('hidden' in properties and properties['hidden'] is True) or \
|
||||||
|
('disabled' in properties and properties['disabled'] is True):
|
||||||
|
continue
|
||||||
|
variable = self.objectspace.paths[child_name]
|
||||||
|
variables.append(self.display_variable(variable,
|
||||||
|
level,
|
||||||
|
family_type,
|
||||||
|
family_path,
|
||||||
|
idx,
|
||||||
|
examples_mini,
|
||||||
|
examples_all,
|
||||||
|
))
|
||||||
|
else:
|
||||||
|
if variables:
|
||||||
|
print(tabulate(variables, headers=['Parameter', 'Comment'], tablefmt="github"))
|
||||||
|
print()
|
||||||
|
variables = []
|
||||||
|
|
||||||
|
family = self.objectspace.paths[child_name]
|
||||||
|
if family.type == 'dynamic':
|
||||||
|
for value in family.variable.default:
|
||||||
|
sub_family_path = f'{family_path}.{family.name.replace("{{ suffix }}", value)}'
|
||||||
|
family_name = sub_family_path.rsplit('.', 1)[-1]
|
||||||
|
examples_mini[family_name] = {}
|
||||||
|
examples_all[family_name] = {}
|
||||||
|
self.display_family(family,
|
||||||
|
sub_family_path,
|
||||||
|
level,
|
||||||
|
)
|
||||||
|
self.display_families(sub_family_path,
|
||||||
|
child_name,
|
||||||
|
level + 1,
|
||||||
|
family.type,
|
||||||
|
examples_mini[family_name],
|
||||||
|
examples_all[family_name],
|
||||||
|
)
|
||||||
|
if not examples_mini[family_name]:
|
||||||
|
del examples_mini[family_name]
|
||||||
|
else:
|
||||||
|
if family.type == 'leadership':
|
||||||
|
examples_mini[family.name] = []
|
||||||
|
examples_all[family.name] = []
|
||||||
|
else:
|
||||||
|
examples_mini[family.name] = {}
|
||||||
|
examples_all[family.name] = {}
|
||||||
|
self.display_family(family,
|
||||||
|
child_name,
|
||||||
|
level,
|
||||||
|
)
|
||||||
|
sub_family_path = f'{family_path}.{family.name}'
|
||||||
|
self.display_families(sub_family_path,
|
||||||
|
child_name,
|
||||||
|
level + 1,
|
||||||
|
family.type,
|
||||||
|
examples_mini[family.name],
|
||||||
|
examples_all[family.name],
|
||||||
|
)
|
||||||
|
if not examples_mini[family.name]:
|
||||||
|
del examples_mini[family.name]
|
||||||
|
if variables:
|
||||||
|
print(tabulate(variables, headers=['Parameter', 'Comment'], tablefmt="github"))
|
||||||
|
print()
|
||||||
|
|
||||||
|
def display_family(self,
|
||||||
|
family,
|
||||||
|
family_path,
|
||||||
|
level,
|
||||||
|
):
|
||||||
|
display_path = family_path.split(".", 1)[-1]
|
||||||
|
if family.name != family.description:
|
||||||
|
title = f'{family.description} ({display_path})'
|
||||||
|
else:
|
||||||
|
title = f'{display_path}'
|
||||||
|
print('#' * level, title)
|
||||||
|
print()
|
||||||
|
informations = self.objectspace.informations.get(family.path)
|
||||||
|
if 'help' in informations:
|
||||||
|
print(informations['help'])
|
||||||
|
print()
|
||||||
|
if family.type == 'leadership':
|
||||||
|
print('This family is a leadership.')
|
||||||
|
print()
|
||||||
|
|
||||||
|
def display_variable(self,
|
||||||
|
variable,
|
||||||
|
level,
|
||||||
|
family_type,
|
||||||
|
family_path,
|
||||||
|
index,
|
||||||
|
examples_mini,
|
||||||
|
examples_all,
|
||||||
|
):
|
||||||
|
parameter = f'**{variable.name}**'
|
||||||
|
subparameter = []
|
||||||
|
if 'mandatory' in self.objectspace.properties[variable.path]:
|
||||||
|
subparameter.append('mandatory')
|
||||||
|
mandatory = True
|
||||||
|
else:
|
||||||
|
mandatory = False
|
||||||
|
if variable.path in self.objectspace.multis:
|
||||||
|
if family_type == 'leadership' and index:
|
||||||
|
multi = self.objectspace.multis[variable.path] == 'submulti'
|
||||||
|
else:
|
||||||
|
multi = True
|
||||||
|
else:
|
||||||
|
multi = False
|
||||||
|
if multi:
|
||||||
|
subparameter.append('multiple')
|
||||||
|
if subparameter:
|
||||||
|
parameter += "<br/>`" + "`, `".join(subparameter) + '`'
|
||||||
|
parameter += f'<br/>**Type:** [`{variable.type}`]({ROUGAIL_VARIABLE_TYPE})'
|
||||||
|
comment = []
|
||||||
|
if variable.name != variable.description:
|
||||||
|
comment.append(variable.description + '.')
|
||||||
|
informations = self.objectspace.informations.get(variable.path)
|
||||||
|
if 'help' in informations:
|
||||||
|
help_ = ' '.join([h.strip() for h in informations['help'].split('\n')])
|
||||||
|
if not help_.endswith('.'):
|
||||||
|
help_ += '.'
|
||||||
|
comment.append(help_)
|
||||||
|
if variable.default is not None:
|
||||||
|
default = variable.default
|
||||||
|
comment.append(f'**Default:** {default}')
|
||||||
|
if variable.type == 'choice':
|
||||||
|
if isinstance(variable.choices, list):
|
||||||
|
comment.append(f'**Choices:** {", ".join(variable.choices)}')
|
||||||
|
else:
|
||||||
|
comment.append(f'**Choices:** see variable "{variable.choices.variable.split(".", 1)[-1]}"')
|
||||||
|
#choice
|
||||||
|
example_mini = None
|
||||||
|
example_all = None
|
||||||
|
properties = self.conf.option(f'{family_path}.{variable.name}').property.get()
|
||||||
|
if 'hidden' in properties or 'disabled' in properties:
|
||||||
|
pass
|
||||||
|
elif variable.test:
|
||||||
|
example = variable.test
|
||||||
|
if not multi:
|
||||||
|
example = example[0]
|
||||||
|
title = 'Example'
|
||||||
|
if mandatory:
|
||||||
|
example_mini = example
|
||||||
|
example_all = example
|
||||||
|
else:
|
||||||
|
if mandatory:
|
||||||
|
example_mini = example
|
||||||
|
example_all = example
|
||||||
|
example = ', '.join(example)
|
||||||
|
if len(variable.test) > 1:
|
||||||
|
title = 'Examples'
|
||||||
|
else:
|
||||||
|
title = 'Example'
|
||||||
|
comment.append(f'**{title}:** {example}')
|
||||||
|
elif variable.default is not None:
|
||||||
|
example = variable.default
|
||||||
|
example_all = example
|
||||||
|
else:
|
||||||
|
example = 'xxx'
|
||||||
|
if mandatory:
|
||||||
|
example_mini = example
|
||||||
|
example_all = example
|
||||||
|
if family_type == 'leadership':
|
||||||
|
if not index:
|
||||||
|
if example_mini is not None:
|
||||||
|
for mini in example_mini:
|
||||||
|
examples_mini.append({variable.name: mini})
|
||||||
|
if example_all is not None:
|
||||||
|
for mall in example_all:
|
||||||
|
examples_all.append({variable.name: mall})
|
||||||
|
else:
|
||||||
|
if example_mini is not None:
|
||||||
|
for idx in range(0, len(examples_mini)):
|
||||||
|
examples_mini[idx][variable.name] = example_mini
|
||||||
|
if example_all is not None:
|
||||||
|
for idx in range(0, len(examples_all)):
|
||||||
|
examples_all[idx][variable.name] = example_all
|
||||||
|
else:
|
||||||
|
if example_mini is not None:
|
||||||
|
examples_mini[variable.name] = example_mini
|
||||||
|
if example_all is not None:
|
||||||
|
examples_all[variable.name] = example_all
|
||||||
|
parameter += ' ' * (250 - len(parameter))
|
||||||
|
comment = '<br/>'.join(comment)
|
||||||
|
comment += ' ' * (250 - len(comment))
|
||||||
|
return parameter, comment
|
||||||
|
|
||||||
|
###############################################
|
||||||
|
# MAIN
|
||||||
|
###############################################
|
||||||
|
|
||||||
|
def main(args):
|
||||||
|
inventory = Inventory()
|
||||||
|
inventory.load()
|
||||||
|
if args.list:
|
||||||
|
inventory.load_inventory()
|
||||||
|
print(dumps({'group': {
|
||||||
|
'hosts': inventory.get_hosts(),
|
||||||
|
'vars': {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
elif args.doc:
|
||||||
|
inventory.display_doc()
|
||||||
|
else:
|
||||||
|
inventory.load_inventory()
|
||||||
|
inventory.mandatory()
|
||||||
|
inventory.display()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = ArgumentParser()
|
||||||
|
parser.add_argument('--list', action='store_true')
|
||||||
|
parser.add_argument('--host', action='store')
|
||||||
|
parser.add_argument('--debug', action='store_true')
|
||||||
|
parser.add_argument('--doc', action='store_true')
|
||||||
|
args = parser.parse_args()
|
||||||
|
try:
|
||||||
|
main(args)
|
||||||
|
except Exception as err:
|
||||||
|
if args.debug:
|
||||||
|
print_exc()
|
||||||
|
if args.doc:
|
||||||
|
exit(f'ERROR: {err}')
|
||||||
|
|
||||||
|
print(dumps({'_errors': str(err)}))
|
7
Rougail/socle/00_hosts.yml
Normal file
7
Rougail/socle/00_hosts.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
version: '1.0'
|
||||||
|
hostnames:
|
||||||
|
multi: true
|
||||||
|
type: hostname
|
||||||
|
params:
|
||||||
|
allow_without_dot: true
|
40
Rougail/socle/03-proxy.yml
Normal file
40
Rougail/socle/03-proxy.yml
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
version: '1.0'
|
||||||
|
env_proxy:
|
||||||
|
description: HTTP(s) proxy server overview and configuration
|
||||||
|
help: |
|
||||||
|
A proxy server acts as an intermediary gateway between a client and another
|
||||||
|
HTTP(s) server, such as the Internet.
|
||||||
|
|
||||||
|
It makes service requests on behalf of a local client and allows the client
|
||||||
|
to make network connections to network services outside its own network.
|
||||||
|
host:
|
||||||
|
description: The proxy server’s address
|
||||||
|
help: |
|
||||||
|
Specifies the hostname of proxy server to enable proxy server access to
|
||||||
|
all of your HTTP(s) requests.
|
||||||
|
type: domainname
|
||||||
|
test:
|
||||||
|
- proxy.silique.fr
|
||||||
|
port:
|
||||||
|
description: The proxy server's port
|
||||||
|
type: port
|
||||||
|
default: "3128"
|
||||||
|
no_proxy:
|
||||||
|
description: Exclude proxy server
|
||||||
|
help: |
|
||||||
|
Network address(es), network address range(s) and domains to exclude from
|
||||||
|
using the proxy when initiating connection(s).
|
||||||
|
type: "domainname"
|
||||||
|
params:
|
||||||
|
allow_ip: true
|
||||||
|
allow_cidr_network: true
|
||||||
|
allow_without_dot: true
|
||||||
|
allow_startswith_dot: true
|
||||||
|
multi: true
|
||||||
|
test:
|
||||||
|
- 192.168.1.1
|
||||||
|
- 192.168.10.0/24
|
||||||
|
- www.silique.fr
|
||||||
|
- .internal.silique.fr
|
||||||
|
mandatory: false
|
43
Rougail/socle/04-apero.yml
Normal file
43
Rougail/socle/04-apero.yml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
---
|
||||||
|
version: '1.0'
|
||||||
|
env_apero:
|
||||||
|
description: Apero service
|
||||||
|
access:
|
||||||
|
description: Add access informations to Apero service
|
||||||
|
help: |
|
||||||
|
To access to Apero service, other services need an account and
|
||||||
|
a password.
|
||||||
|
type: leadership
|
||||||
|
login:
|
||||||
|
description: Login name
|
||||||
|
help: |
|
||||||
|
The account name is typically the name of foreign services.
|
||||||
|
type: unix_user
|
||||||
|
multi: true
|
||||||
|
test:
|
||||||
|
- srep
|
||||||
|
password:
|
||||||
|
description: Password
|
||||||
|
type: secret
|
||||||
|
|
||||||
|
env_srep:
|
||||||
|
description: SREP service
|
||||||
|
apero_user:
|
||||||
|
description: Account to access to Apero service
|
||||||
|
type: choice
|
||||||
|
choices:
|
||||||
|
type: variable
|
||||||
|
variable: socle.env_apero.access.login
|
||||||
|
test:
|
||||||
|
- srep
|
||||||
|
apero_password:
|
||||||
|
type: secret
|
||||||
|
hidden: true
|
||||||
|
default:
|
||||||
|
type: jinja
|
||||||
|
jinja: |
|
||||||
|
{% for value in socle.env_apero.access.login %}
|
||||||
|
{% if value == socle.env_srep.apero_user %}
|
||||||
|
{{ socle.env_apero.access.password[loop.index0] }}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
15
Rougail/socle/05-omogen.yml
Normal file
15
Rougail/socle/05-omogen.yml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
version: '1.0'
|
||||||
|
env_omogen:
|
||||||
|
description: Configure OMOGEN
|
||||||
|
keystore:
|
||||||
|
description: Keystore filename to access to OMOGEN
|
||||||
|
help: This filename must ends with "kjs" extension
|
||||||
|
test:
|
||||||
|
- java.jks
|
||||||
|
validators:
|
||||||
|
- type: jinja
|
||||||
|
jinja: |
|
||||||
|
{% if not socle.env_omogen.keystore.endswith('.jks') %}
|
||||||
|
the extension must be "jks"
|
||||||
|
{% endif %}
|
33
Rougail/socle/06-nfs.yml
Normal file
33
Rougail/socle/06-nfs.yml
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
---
|
||||||
|
version: "1.0"
|
||||||
|
env_nfs:
|
||||||
|
description: NFS configuration
|
||||||
|
configure:
|
||||||
|
description: Configure NFS mount
|
||||||
|
help: |
|
||||||
|
To share documents between differents services, you need to configure
|
||||||
|
a NFS server
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
server:
|
||||||
|
description: NFS server name
|
||||||
|
help: Configure NFS server only if env_nfs.configure is true
|
||||||
|
type: domainname
|
||||||
|
default: nfs.silique.fr
|
||||||
|
disabled:
|
||||||
|
type: jinja
|
||||||
|
jinja: |
|
||||||
|
{% if not socle.env_nfs.configure %}
|
||||||
|
NFS is disabled
|
||||||
|
{% endif %}
|
||||||
|
device:
|
||||||
|
default:
|
||||||
|
type: jinja
|
||||||
|
jinja: "{{ socle.env_nfs.server }}:/nfs"
|
||||||
|
hidden: true
|
||||||
|
disabled:
|
||||||
|
type: jinja
|
||||||
|
jinja: |
|
||||||
|
{% if not socle.env_nfs.configure %}
|
||||||
|
NFS is disabled
|
||||||
|
{% endif %}
|
92
doc.md
Normal file
92
doc.md
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
---
|
||||||
|
gitea: none
|
||||||
|
include_toc: true
|
||||||
|
---
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
## HTTP(s) proxy server overview and configuration (env_proxy)
|
||||||
|
|
||||||
|
A proxy server acts as an intermediary gateway between a client and another
|
||||||
|
HTTP(s) server, such as the Internet.
|
||||||
|
|
||||||
|
It makes service requests on behalf of a local client and allows the client
|
||||||
|
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/>**Default:** 3128 |
|
||||||
|
| **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 |
|
||||||
|
|
||||||
|
## Apero service (env_apero)
|
||||||
|
|
||||||
|
### Add access informations to Apero service (env_apero.access)
|
||||||
|
|
||||||
|
To access to Apero service, other services need an account and
|
||||||
|
a password.
|
||||||
|
|
||||||
|
|
||||||
|
This family is a leadership.
|
||||||
|
|
||||||
|
| Parameter | Comment |
|
||||||
|
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
| **login**<br/>`mandatory`, `multiple`<br/>**Type:** [`unix_user`](https://forge.cloud.silique.fr/stove/rougail/src/branch/main/doc/variable/README.md#le-type-de-la-variable) | Login name.<br/>The account name is typically the name of foreign services. .<br/>**Example:** srep |
|
||||||
|
| **password**<br/>`mandatory`<br/>**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**<br/>`mandatory`<br/>**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.<br/>**Choices:** see variable "env_apero.access.login"<br/>**Example:** srep |
|
||||||
|
|
||||||
|
## Configure OMOGEN (env_omogen)
|
||||||
|
|
||||||
|
| Parameter | Comment |
|
||||||
|
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
| **keystore**<br/>`mandatory`<br/>**Type:** [`string`](https://forge.cloud.silique.fr/stove/rougail/src/branch/main/doc/variable/README.md#le-type-de-la-variable) | Keystore filename to access to OMOGEN.<br/>This filename must ends with "kjs" extension.<br/>**Example:** java.jks |
|
||||||
|
|
||||||
|
## NFS configuration (env_nfs)
|
||||||
|
|
||||||
|
| Parameter | Comment |
|
||||||
|
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
| **configure**<br/>`mandatory`<br/>**Type:** [`boolean`](https://forge.cloud.silique.fr/stove/rougail/src/branch/main/doc/variable/README.md#le-type-de-la-variable) | Configure NFS mount.<br/>To share documents between differents services, you need to configure a NFS server .<br/>**Default:** False |
|
||||||
|
| **server**<br/>`mandatory`<br/>**Type:** [`domainname`](https://forge.cloud.silique.fr/stove/rougail/src/branch/main/doc/variable/README.md#le-type-de-la-variable) | NFS server name.<br/>Configure NFS server only if env_nfs.configure is true.<br/>**Default:** nfs.silique.fr |
|
||||||
|
|
||||||
|
# Example with mandatories variables
|
||||||
|
|
||||||
|
```
|
||||||
|
env_proxy:
|
||||||
|
host: proxy.silique.fr
|
||||||
|
env_apero:
|
||||||
|
access:
|
||||||
|
- login: srep
|
||||||
|
password: xxx
|
||||||
|
env_srep:
|
||||||
|
apero_user: srep
|
||||||
|
env_omogen:
|
||||||
|
keystore: java.jks
|
||||||
|
```
|
||||||
|
|
||||||
|
# Example with all variables
|
||||||
|
|
||||||
|
```
|
||||||
|
env_proxy:
|
||||||
|
host: proxy.silique.fr
|
||||||
|
port: '3128'
|
||||||
|
no_proxy:
|
||||||
|
- 192.168.1.1
|
||||||
|
- 192.168.10.0/24
|
||||||
|
- www.silique.fr
|
||||||
|
- .internal.silique.fr
|
||||||
|
env_apero:
|
||||||
|
access:
|
||||||
|
- login: srep
|
||||||
|
password: xxx
|
||||||
|
env_srep:
|
||||||
|
apero_user: srep
|
||||||
|
env_omogen:
|
||||||
|
keystore: java.jks
|
||||||
|
env_nfs:
|
||||||
|
configure: false
|
||||||
|
```
|
10
filter_plugins/warn_me.py
Normal file
10
filter_plugins/warn_me.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
from ansible.utils.display import Display
|
||||||
|
|
||||||
|
class FilterModule(object):
|
||||||
|
def filters(self): return {'warn_me': self.warn_filter}
|
||||||
|
|
||||||
|
def warn_filter(self, messages, **kwargs):
|
||||||
|
for message in messages:
|
||||||
|
Display().warning(message)
|
||||||
|
return ''
|
BIN
firefox.png
BIN
firefox.png
Binary file not shown.
Before Width: | Height: | Size: 123 KiB |
BIN
foxyproxy.png
BIN
foxyproxy.png
Binary file not shown.
Before Width: | Height: | Size: 154 KiB |
4
inventory
Executable file
4
inventory
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
export ANSIBLE_DISPLAY_SKIPPED_HOSTS=0
|
||||||
|
ansible-playbook -i ./Rougail/inventory.py playbook.yml -e "_type=rougail"
|
||||||
|
ansible-playbook -i ./Ansible/inventory -i Ops playbook.yml -e "_type=ansible"
|
13
next.sh
Executable file
13
next.sh
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
BRANCH=1.0
|
||||||
|
CURRENT_LOG=$(git log --oneline|wc -l)
|
||||||
|
MAIN_LOG=$(git log --oneline $BRANCH|wc -l)
|
||||||
|
if [ $CURRENT_LOG = $MAIN_LOG ]; then
|
||||||
|
PAGE=$CURRENT_LOG
|
||||||
|
PAGE=$((PAGE-3))
|
||||||
|
else
|
||||||
|
PAGE=$((MAIN_LOG-CURRENT_LOG-2))
|
||||||
|
fi
|
||||||
|
git checkout $BRANCH 2> /dev/null
|
||||||
|
git checkout HEAD~$PAGE
|
||||||
|
git log --oneline -n1
|
41
playbook.yml
Normal file
41
playbook.yml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
---
|
||||||
|
- name: " ++++ {{ _type | upper }} ++++ "
|
||||||
|
hosts: localhost
|
||||||
|
connection: local
|
||||||
|
tasks:
|
||||||
|
# Verify if Tiramisu makes some error
|
||||||
|
- name: Validation Rougail
|
||||||
|
ansible.builtin.debug:
|
||||||
|
when: "_type == 'rougail' and '_warnings' in vars and vars['_warnings'] | warn_me"
|
||||||
|
- name: Validation Rougail
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- "'_errors' not in vars"
|
||||||
|
fail_msg: "{%if '_errors' in vars %}{{ vars._errors }}{%endif%}"
|
||||||
|
when: "_type == 'rougail'"
|
||||||
|
|
||||||
|
# Verify ansible variables
|
||||||
|
- name: Validation Ansible
|
||||||
|
include_tasks: "Ansible/asserts/{{ item }}.yml"
|
||||||
|
when: "_type == 'ansible' and ('Ansible/asserts/' + item + '.yml') is file"
|
||||||
|
loop:
|
||||||
|
- apero
|
||||||
|
- database
|
||||||
|
- nfs
|
||||||
|
- omogen
|
||||||
|
- proxy
|
||||||
|
- name: Validation Ansible
|
||||||
|
include_tasks: "Ansible/asserts/proxy.yml"
|
||||||
|
when: "_type == 'ansible'"
|
||||||
|
|
||||||
|
# Display inventory that startswith env_
|
||||||
|
- name: Display inventory
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ item }}"
|
||||||
|
when: item.key.startswith('env_')
|
||||||
|
loop: "{{ vars | dict2items }}"
|
||||||
|
|
||||||
|
# Display some ansible variables
|
||||||
|
- name: "Display"
|
||||||
|
include_tasks: "Ansible/asserts/display.yml"
|
||||||
|
when: "_type == 'ansible' and 'Ansible/asserts/display.yml' is file"
|
Loading…
Reference in a new issue