update cli

This commit is contained in:
gwen 2026-02-12 11:12:22 +01:00
parent 887f5794af
commit 4585d1aa66
3 changed files with 235 additions and 6 deletions

View file

@ -3,6 +3,14 @@
The Rougail Command Line Interface
========================================
Les help
------------
::
rougail -u yaml -h
Standard usage
-----------------
@ -37,6 +45,35 @@ Standard usage
"port": "8888"
}
CLI root
-------------
::
(.venv) ubuntu@monessai:~/workplace/rougail-tutorials$ env ROUGAIL_MANUAL.USE_FOR_HTTPS=true rougail -m firefox/ --cli.root manual.https_proxy -u yaml environment -yf ^Cnfig/01/config.yml --cli.read_write
(.venv) ubuntu@monessai:~/workplace/rougail-tutorials$ cat config/01/config.yml
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: http.proxy.net
port: 3128
use_for_https: false
https_proxy:
address: https.proxy.net
(.venv) ubuntu@monessai:~/workplace/rougail-tutorials$ rougail -m firefox/ --cli.root manual.https_proxy -u yaml -yf config/01/config.yml
[WARNING]: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.
[DEPRECATION WARNING]: Importing 'to_bytes' from 'ansible.module_utils._text' is deprecated. This feature will be removed from ansible-core version 2.24. Use ansible.module_utils.common.text.converters instead.
╭────────────── Caption ───────────────╮
│ Variable Default value │
│ Modified value │
│ (⏳ Original default value) │
╰──────────────────────────────────────╯
Variables:
┣━━ 📓 HTTPS address: https.proxy.net ◀ loaded from the YAML file "config/01/config.yml" (⏳ https.proxy.net ◀ loaded from the YAML file "config/01/config.yml" ⏳ http.proxy.net)
┗━━ 📓 HTTPS port: 3128
Invalid user data error
-----------------------------
@ -55,4 +92,51 @@ https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_050/READM
when an unknown (or disabled or hidden) variable is declared in the :term:`user data file <user data>`
then it appears in the output as an error instead of a warning.
Le output doc
----------------
::
rougail -m structure.yml -o doc --doc.output_format github > README.md
Le formatter
----------------
::
<gnunux> on va maintenant vérifier le formatage du fichier
<gnunux> rougail -o formatter -m structure.yml > a.yml; mv a.yml structure.yml
Les namespaces
-----------------
::
rougail -m structure.yml -u yaml -yf userdata.yml -s intranet -xn hosts -xd 0 hosts.yml
::
rougail -m structure.yml -u yaml -yf userdata.yml -s intranet -xn hosts orem srem prom -xd 0 hosts.yml -xd 1 packages/OREM -xd 2 packages/SREM -xd 3 packages/SREP
L'export ansible
-------------------
rougail -m structure.yml -u yaml -yf userdata.yml -s intranet -xn hosts -xd 0 hosts.yml -o ansible > ansible.json
::
ansible-inventory -i $(which rougail) --list
<gnunux> voir si ansible liste bien ton inventaire :)
::
ansible-inventory -i $(which rougail) --host tutu.fr
::
ansible-playbook -i $(which rougail) install.yml

View file

@ -1,16 +1,17 @@
rougail==1.2.0a59
rougail==1.2.0a63
rougail-cli==0.2.0a42
rougail-output-ansible==0.2.0a24
rougail-output-display==0.2.0a29
rougail-output-doc==0.2.0a45
rougail-output-display==0.2.0a30
rougail-output-doc==0.2.0a46
rougail-output-formatter==0.1.0a24
rougail-output-json==0.2.0a18
rougail-output-table==0.1.0a2
rougail-structural-bitwarden==0.1.0a6
rougail-user-data-ansible==0.1.0a5
rougail-user-data-bitwarden==0.1.0a30
rougail-user-data-commandline==0.1.0a5
rougail-user-data-environment==0.1.0a18
rougail-user-data-questionary==0.1.0a4
rougail-user-data-yaml==0.2.0a19
tiramisu==5.2.0a25
tiramisu==5.2.0a26
tiramisu-cmdline-parser==0.7.0a5

View file

@ -8,6 +8,12 @@ Playing with Jinja
Up to now, our only way of dynamically (that is, during the runtime) calculating
a value is to point on another variable's value. But this is not the only way.
We will learn how to insert `Jinja templating language <https://jinja.palletsprojects.com/en/stable/>`_ into our structure files.
Please note that we do not intend to template our YAML files.
That is a completely different activity.
We will simply insert YAML code to calculate variable, property, or parameter values.
.. prerequisites:: Prerequisites
- We assume that Rougail's library is :ref:`installed <installation>` on your computer.
@ -29,7 +35,145 @@ Playing with Jinja
A conditional hidden family with Jinja
---------------------------------------
GWEN
Let's show add some jinja code in our structure file:
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_070/firefox/20-manual.yml
:language: yaml
:caption: The :file:`firefox/20-manual.yml` structure file with some `jinja` code in the `hidden` property
..
%YAML 1.2
---
version: 1.1
manual:
use_for_https: true # Also use this proxy for HTTPS
'{{ identifier }}_proxy':
description: '{{ identifier }} Proxy'
hidden:
jinja: |-
{% if _.use_for_https %}
HTTPS is same has HTTP
{% endif %}
dynamic:
- HTTPS
- SOCKS
address:
description: '{{ identifier }} address'
default:
variable: __.http_proxy.address
port:
description: '{{ identifier }} port'
default:
variable: __.http_proxy.port
version:
description: SOCKS host version used by proxy
choices:
- v4
- v5
default: v5
disabled:
type: identifier
when: HTTPS
...
If we set the `use_for_https` to `false`:
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_070/config/01/config.yml
:language: yaml
:caption: FIXME
..
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: http.proxy.net
port: 3128
use_for_https: false
https_proxy:
address: https.proxy.net
Nothing special appears when we launch the Rougail CLI:
.. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_070/config/01/cmd_ro.txt
:class: terminal
..
rougail -m firefox/ -u yaml -yf config/01/config.The
---
..
env ROUGAIL_MANUAL.USE_FOR_HTTPS=true
::
rougail -m firefox/ -u yaml -yf config/01/config.yml --cli.root manual.https_proxy
we have a warning:
::
🔔 Warning
┗━━ Manual proxy configuration
┗━━ HTTPS Proxy
┗━━ HTTPS address: 🔔 family "HTTPS Proxy" has property hidden, so
cannot access to "HTTPS address", it will be ignored when loading
from the YAML file "config/01/config.yml"
╭────────────── Caption ──────────────╮
│ Unmodifiable variable Default value │
╰─────────────────────────────────────╯
Variables:
┣━━ 📓 HTTPS address: http.proxy.net
┗━━ 📓 HTTPS port: 3128
It is interesting here to launch the Rougail CLI in the :term:`read write mode`:
..
env ROUGAIL_MANUAL.USE_FOR_HTTPS=true
::
rougail -m firefox/ --cli.root manual.https_proxy -u yaml environment -yf config/01/config.yml --cli.read_write
.. code-block:: bash
ERROR: cannot access to optiondescription "HTTPS Proxy"
because has property "hidden"
(HTTPS is same has HTTP)
yml standard output:
.. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_070/config/01/output_ro.html
:class: output
..
Variables:
┣━━ 📓 Configure Proxy Access to the Internet: Manual proxy configuration ◀ loaded from the YAML file "config/01/config.yml" (⏳ No proxy)
┗━━ 📂 Manual proxy configuration
┣━━ 📂 HTTP Proxy
┃ ┣━━ 📓 HTTP address: http.proxy.net ◀ loaded from the YAML file "config/01/config.yml"
┃ ┗━━ 📓 HTTP Port: 3128 ◀ loaded from the YAML file "config/01/config.yml" (⏳ 8080)
┣━━ 📓 Also use this proxy for HTTPS: false ◀ loaded from the YAML file "config/01/config.yml" (⏳ true)
┣━━ 📂 HTTPS Proxy
┃ ┣━━ 📓 HTTPS address: https.proxy.net ◀ loaded from the YAML file "config/01/config.yml" (⏳ http.proxy.net)
┃ ┗━━ 📓 HTTPS port: 3128
┗━━ 📂 SOCKS Proxy
┣━━ 📓 SOCKS address: http.proxy.net
┣━━ 📓 SOCKS port: 3128
┗━━ 📓 SOCKS host version used by proxy: v5
We can hide or disable some variables or families with other techniques than
pointing on a variable's value.
@ -175,7 +319,7 @@ The default values can be calculated too.
Using jinja in a dynamic family declaration
-----------------------------------------------
Let's come back to the previous section's :ref:`dynamic family example <conditional_hidden_family>`\ .
Let's come back to the previous section's FIXME `dynamic family example <conditional_hidden_family>`
In a dynamic family, as seen before, you have the possibility to name your identifier. In the classic declaration,
the identifier's variable is named "identifier" by default. Sounds logical: