Compare commits
23 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eb0f5901ab | |||
| a4fefee09d | |||
| e71289280c | |||
| bacec45946 | |||
| 3149ba1103 | |||
| 66206f05cf | |||
| 2f683f2122 | |||
| ec728cca1d | |||
| dc191cebee | |||
| 28cbae1b08 | |||
| b13abd615f | |||
| 13528fb4af | |||
| 6d2bc9592b | |||
| 03af28c835 | |||
| 732355b996 | |||
| dd6d7caf97 | |||
| 851eca83b7 | |||
| 88736c5c9f | |||
| 2bd04cd72d | |||
| 4241cd25a7 | |||
| 71e0fcd8cf | |||
| e7157de7b5 | |||
| b19b397ebf |
11 changed files with 435 additions and 1 deletions
65
CHANGELOG.md
Normal file
65
CHANGELOG.md
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
## 0.1.0a5 (2025-11-21)
|
||||
|
||||
### Fix
|
||||
|
||||
- ExtentionError => ExtensionError
|
||||
|
||||
## 0.1.0a4 (2025-11-06)
|
||||
|
||||
### Fix
|
||||
|
||||
- disable config if ansible is not selected
|
||||
|
||||
## 0.1.0a3 (2025-05-02)
|
||||
|
||||
### Fix
|
||||
|
||||
- do not force use_data usage
|
||||
|
||||
## 0.1.0a2 (2025-04-09)
|
||||
|
||||
### Fix
|
||||
|
||||
- version
|
||||
|
||||
## 0.1.0a1 (2025-03-30)
|
||||
|
||||
### Fix
|
||||
|
||||
- i18n
|
||||
|
||||
## 0.1.0a0 (2025-02-10)
|
||||
|
||||
### Feat
|
||||
|
||||
- add new parameter ansible.file_with_secrets
|
||||
|
||||
## 0.0.1a4 (2025-01-02)
|
||||
|
||||
### Fix
|
||||
|
||||
- output ansible is loaded after
|
||||
|
||||
## 0.0.1a3 (2024-12-11)
|
||||
|
||||
### Fix
|
||||
|
||||
- user-data file is now user-data yaml
|
||||
|
||||
## 0.0.1a2 (2024-12-11)
|
||||
|
||||
### Fix
|
||||
|
||||
- specialize error
|
||||
|
||||
## 0.0.1a1 (2024-11-27)
|
||||
|
||||
### Fix
|
||||
|
||||
- support user data ansible with output ansible
|
||||
|
||||
## 0.0.1a0 (2024-11-25)
|
||||
|
||||
### Fix
|
||||
|
||||
- new ansible plugin loader
|
||||
23
README.fr.md
Normal file
23
README.fr.md
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
gitea: none
|
||||
include_toc: true
|
||||
---
|
||||
[🇬🇧 (EN)](README.md) - [🇫🇷 (FR)](README.fr.md)
|
||||
|
||||
===============
|
||||
{}
|
||||
## Charge les données utilisateur depuis un fichier compatible avec Ansible
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> **Chemin** : ansible\
|
||||
> *`désactivé`*\
|
||||
> **Désactivé** : si ansible n'est pas définit dans "[Sélection pour données utilisateur](#step.user_data)"
|
||||
|
||||
| Variable | Description | Valeur par défaut | Type | Contrôle des accès | Validateur |
|
||||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------|---------------------|--------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| **<a id="ansible.filename" name="ansible.filename">ansible.filename</a>**<br/>**Ligne de commande** : <br/>--ansible.filename<br/>**Variable d'environnement** : ANSIBLE.FILENAME | Nom du fichier d'inventaire Ansible. | | [`UNIX filename`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` `obligatoire` | *`désactivé`*<br/>**Désactivé** : si ansible n'est pas définit dans "[Sélection pour données utilisateur](#step.user_data)" | `unique`<br/>• le nom de fichier peut être une chemin relatif<br/>• le fichier doit exister<br/>• type de fichier autorisé: "file". |
|
||||
| **<a id="ansible.secret" name="ansible.secret">ansible.secret</a>**<br/>**Ligne de commande** : <br/>--ansible.secret<br/>**Variable d'environnement** : ANSIBLE.SECRET | Secret pour déchiffrer le fichier. | | [`secret`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | *`désactivé`*<br/>**Désactivé** : si ansible n'est pas définit dans "[Sélection pour données utilisateur](#step.user_data)" | |
|
||||
| **<a id="ansible.file_with_secrets" name="ansible.file_with_secrets">ansible.file_with_secrets</a>**<br/>**Ligne de commande** : <br/>--ansible.file_with_secrets<br/>**Variable d'environnement** : ANSIBLE.FILE_WITH_SECRETS | Les fichiers Ansible qui peuvent contenir des secrets. | all | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | *`désactivé`*<br/>**Désactivé** : si ansible n'est pas définit dans "[Sélection pour données utilisateur](#step.user_data)" | **Choix** : <br/>• all<br/>• first<br/>• last<br/>• none |
|
||||
|
||||
|
||||
23
README.md
23
README.md
|
|
@ -1,2 +1,23 @@
|
|||
# rougail-user-data-ansible
|
||||
---
|
||||
gitea: none
|
||||
include_toc: true
|
||||
---
|
||||
[🇬🇧 (EN)](README.md) - [🇫🇷 (FR)](README.fr.md)
|
||||
|
||||
===============
|
||||
{}
|
||||
## Load user data from Ansible compatible file
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> **Path**: ansible\
|
||||
> *`disabled`*\
|
||||
> **Disabled**: if ansible is not set in "[Select for user datas](#step.user_data)"
|
||||
|
||||
| Variable | Description | Default value | Type | Access control | Validator |
|
||||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------|-----------------|------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
|
||||
| **<a id="ansible.filename" name="ansible.filename">ansible.filename</a>**<br/>**Command line**: <br/>--ansible.filename<br/>**Environment variable**: ANSIBLE.FILENAME | Ansible filename inventory. | | [`UNIX filename`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` `mandatory` | *`disabled`*<br/>**Disabled**: if ansible is not set in "[Select for user datas](#step.user_data)" | `unique`<br/>• this filename could be a relative path<br/>• this file must exist<br/>• file type allowed: "file". |
|
||||
| **<a id="ansible.secret" name="ansible.secret">ansible.secret</a>**<br/>**Command line**: <br/>--ansible.secret<br/>**Environment variable**: ANSIBLE.SECRET | Secret to decrypt file. | | [`secret`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | *`disabled`*<br/>**Disabled**: if ansible is not set in "[Select for user datas](#step.user_data)" | |
|
||||
| **<a id="ansible.file_with_secrets" name="ansible.file_with_secrets">ansible.file_with_secrets</a>**<br/>**Command line**: <br/>--ansible.file_with_secrets<br/>**Environment variable**: ANSIBLE.FILE_WITH_SECRETS | Ansible files that may contain secrets. | all | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | *`disabled`*<br/>**Disabled**: if ansible is not set in "[Select for user datas](#step.user_data)" | **Choices**: <br/>• all<br/>• first<br/>• last<br/>• none |
|
||||
|
||||
|
||||
|
|
|
|||
51
locale/fr/LC_MESSAGES/rougail_user_data_ansible.po
Normal file
51
locale/fr/LC_MESSAGES/rougail_user_data_ansible.po
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2026-02-11 21:30+0100\n"
|
||||
"PO-Revision-Date: 2026-02-11 21:31+0100\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: pygettext.py 1.5\n"
|
||||
"X-Generator: Poedit 3.8\n"
|
||||
|
||||
#: src/rougail/user_data_ansible/__init__.py:48
|
||||
msgid "ansible is not set in step.user_data"
|
||||
msgstr "ansible n'est pas définit dans step.user_data"
|
||||
|
||||
#: src/rougail/user_data_ansible/__init__.py:56
|
||||
msgid "the Ansible file \"{0}\""
|
||||
msgstr "le ficher Ansible \"{0}\""
|
||||
|
||||
#: src/rougail/user_data_ansible/config.py:30
|
||||
msgid "Load user data from Ansible compatible file"
|
||||
msgstr "Charge les données utilisateur depuis un fichier compatible avec Ansible"
|
||||
|
||||
#: src/rougail/user_data_ansible/config.py:35
|
||||
#: src/rougail/user_data_ansible/config.py:50
|
||||
#: src/rougail/user_data_ansible/config.py:59
|
||||
#: src/rougail/user_data_ansible/config.py:73
|
||||
msgid "if ansible is not set in \"step.user_data\""
|
||||
msgstr "si ansible n'est pas définit dans \"step.user_data\""
|
||||
|
||||
#: src/rougail/user_data_ansible/config.py:38
|
||||
msgid "Ansible filename inventory"
|
||||
msgstr "Nom du fichier d'inventaire Ansible"
|
||||
|
||||
#: src/rougail/user_data_ansible/config.py:53
|
||||
msgid "Secret to decrypt file"
|
||||
msgstr "Secret pour déchiffrer le fichier"
|
||||
|
||||
#: src/rougail/user_data_ansible/config.py:62
|
||||
msgid "Ansible files that may contain secrets"
|
||||
msgstr "Les fichiers Ansible qui peuvent contenir des secrets"
|
||||
|
||||
#~ msgid "Configuration of user data Ansible"
|
||||
#~ msgstr "Configuration des données utilisateurs Ansible"
|
||||
48
locale/rougail_user_data_ansible.pot
Normal file
48
locale/rougail_user_data_ansible.pot
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2026-02-11 21:31+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: pygettext.py 1.5\n"
|
||||
|
||||
|
||||
#: src/rougail/user_data_ansible/__init__.py:48
|
||||
msgid "ansible is not set in step.user_data"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_data_ansible/__init__.py:56
|
||||
msgid "the Ansible file \"{0}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_data_ansible/config.py:30
|
||||
msgid "Load user data from Ansible compatible file"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_data_ansible/config.py:35
|
||||
#: src/rougail/user_data_ansible/config.py:50
|
||||
#: src/rougail/user_data_ansible/config.py:59
|
||||
#: src/rougail/user_data_ansible/config.py:73
|
||||
msgid "if ansible is not set in \"step.user_data\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_data_ansible/config.py:38
|
||||
msgid "Ansible filename inventory"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_data_ansible/config.py:53
|
||||
msgid "Secret to decrypt file"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_data_ansible/config.py:62
|
||||
msgid "Ansible files that may contain secrets"
|
||||
msgstr ""
|
||||
|
||||
44
pyproject.toml
Normal file
44
pyproject.toml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
[build-system]
|
||||
build-backend = "flit_core.buildapi"
|
||||
requires = ["flit_core >=3.8.0,<4"]
|
||||
|
||||
[project]
|
||||
name = "rougail.user_data_ansible"
|
||||
version = "0.1.0a5"
|
||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||
readme = "README.md"
|
||||
description = "Rougail user_data ansible"
|
||||
requires-python = ">=3.8"
|
||||
license = {file = "LICENSE"}
|
||||
classifiers = [
|
||||
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
"Programming Language :: Python :: 3.14",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Operating System :: OS Independent",
|
||||
"Natural Language :: English",
|
||||
"Natural Language :: French",
|
||||
|
||||
]
|
||||
dependencies = [
|
||||
"rougail-user-data-yaml >= 0.1,<2",
|
||||
"ansible",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Home = "https://forge.cloud.silique.fr/stove/rougail-user-data-file"
|
||||
|
||||
[tool.commitizen]
|
||||
name = "cz_conventional_commits"
|
||||
tag_format = "$version"
|
||||
version_scheme = "pep440"
|
||||
version_provider = "pep621"
|
||||
version_files = [
|
||||
"src/rougail/user_data_ansible/__version__.py",
|
||||
"pyproject.toml:version"
|
||||
]
|
||||
update_changelog_on_bump = true
|
||||
changelog_merge_prerelease = true
|
||||
72
src/rougail/user_data_ansible/__init__.py
Normal file
72
src/rougail/user_data_ansible/__init__.py
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
"""
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024-2026
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
from ansible.parsing.vault import VaultLib, PromptVaultSecret
|
||||
from ansible.module_utils._text import to_bytes
|
||||
|
||||
from rougail.user_data_yaml import RougailUserDataYaml
|
||||
from rougail.error import ExtensionError
|
||||
|
||||
from .i18n import _
|
||||
from .__version__ import __version__
|
||||
|
||||
|
||||
class RougailUserDataAnsible(RougailUserDataYaml):
|
||||
"""Load Ansible data from encrypted file
|
||||
"""
|
||||
def __init__(
|
||||
self,
|
||||
config,
|
||||
*,
|
||||
rougailconfig=None,
|
||||
) -> None:
|
||||
if rougailconfig is None:
|
||||
from rougail import RougailConfig
|
||||
rougailconfig = RougailConfig
|
||||
user_data = rougailconfig["step.user_data"]
|
||||
if "ansible" not in user_data:
|
||||
user_data.append("ansible")
|
||||
rougailconfig["step.user_data"] = user_data
|
||||
user_data = rougailconfig["step.user_data"]
|
||||
if "ansible" not in user_data:
|
||||
raise ExtensionError(_("ansible is not set in step.user_data"))
|
||||
self.rougailconfig = rougailconfig
|
||||
self.filenames = self.rougailconfig["ansible.filename"]
|
||||
self.secret = self.rougailconfig["ansible.secret"]
|
||||
self.file_with_secrets = self.rougailconfig["ansible.file_with_secrets"]
|
||||
self.config = config
|
||||
self.errors = []
|
||||
self.warnings = []
|
||||
self.source = _('the Ansible file "{0}"')
|
||||
|
||||
def open(self, filename: str) -> dict:
|
||||
"""Open file
|
||||
"""
|
||||
prompt = PromptVaultSecret(
|
||||
to_bytes(self.secret), "default", ["Vault password: "]
|
||||
)
|
||||
vault = VaultLib([("default", prompt)])
|
||||
with Path(filename).open("rb") as fh:
|
||||
return self.yaml.load(vault.decrypt(fh.read()))
|
||||
|
||||
|
||||
RougailUserData = RougailUserDataAnsible
|
||||
|
||||
|
||||
__all__ = ("RougailUserDataAnsible",)
|
||||
1
src/rougail/user_data_ansible/__version__.py
Normal file
1
src/rougail/user_data_ansible/__version__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
__version__ = "0.1.0a5"
|
||||
83
src/rougail/user_data_ansible/config.py
Normal file
83
src/rougail/user_data_ansible/config.py
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
"""
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024-2026
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from .i18n import _
|
||||
|
||||
|
||||
def get_rougail_config(
|
||||
*,
|
||||
backward_compatibility: bool = True, # pylint: disable=unused-argument
|
||||
) -> dict:
|
||||
"""get rougail config for ansible"""
|
||||
# redefine ansible family if already exists (for output)
|
||||
# or create a new only only for user data
|
||||
options = f"""
|
||||
ansible:
|
||||
description: {_("Load user data from Ansible compatible file")}
|
||||
disabled:
|
||||
jinja: |
|
||||
{{{{ _.step.user_data is propertyerror or 'ansible' not in _.step.user_data }}}}
|
||||
return_type: boolean
|
||||
description: {_('if ansible is not set in "step.user_data"')}
|
||||
|
||||
filename:
|
||||
description: {_("Ansible filename inventory")}
|
||||
type: unix_filename
|
||||
multi: true
|
||||
params:
|
||||
allow_relative: True
|
||||
test_existence: True
|
||||
types:
|
||||
- file
|
||||
disabled:
|
||||
jinja: |
|
||||
{{{{ _.step.user_data is propertyerror or 'ansible' not in _.step.user_data }}}}
|
||||
return_type: boolean
|
||||
description: {_('if ansible is not set in "step.user_data"')}
|
||||
|
||||
secret:
|
||||
description: {_("Secret to decrypt file")}
|
||||
type: secret
|
||||
disabled:
|
||||
jinja: |
|
||||
{{{{ _.step.user_data is propertyerror or 'ansible' not in _.step.user_data }}}}
|
||||
return_type: boolean
|
||||
description: {_('if ansible is not set in "step.user_data"')}
|
||||
|
||||
file_with_secrets:
|
||||
description: {_("Ansible files that may contain secrets")}
|
||||
default: all
|
||||
choices:
|
||||
- all
|
||||
- first
|
||||
- last
|
||||
- none
|
||||
disabled:
|
||||
jinja: |
|
||||
{{{{ _.step.user_data is propertyerror or 'ansible' not in _.step.user_data }}}}
|
||||
return_type: boolean
|
||||
description: {_('if ansible is not set in "step.user_data"')}
|
||||
"""
|
||||
return {
|
||||
"name": "ansible",
|
||||
"process": "user data",
|
||||
"options": options,
|
||||
"level": 60,
|
||||
}
|
||||
|
||||
|
||||
__all__ = ("get_rougail_config",)
|
||||
26
src/rougail/user_data_ansible/i18n.py
Normal file
26
src/rougail/user_data_ansible/i18n.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
"""Internationalisation utilities
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024-2026
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
from gettext import translation
|
||||
from pathlib import Path
|
||||
|
||||
t = translation(
|
||||
"rougail_user_data_ansible", str(Path(__file__).parent / "locale"), fallback=True
|
||||
)
|
||||
|
||||
_ = t.gettext
|
||||
Binary file not shown.
Loading…
Reference in a new issue