fix: new ansible plugin loader
This commit is contained in:
parent
b77314233a
commit
b19b397ebf
7 changed files with 224 additions and 0 deletions
21
locale/fr/LC_MESSAGES/user_data_ansible.po
Normal file
21
locale/fr/LC_MESSAGES/user_data_ansible.po
Normal file
|
@ -0,0 +1,21 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2024-11-25 10:49+0100\n"
|
||||
"PO-Revision-Date: 2024-11-25 10:51+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.5\n"
|
||||
|
||||
#: src/rougail/user_data_ansible/__init__.py:43
|
||||
msgid "ansible is not set in step.user_data"
|
||||
msgstr "ansible n'est pas définit dans step.user_data"
|
21
locale/user_data_ansible.pot
Normal file
21
locale/user_data_ansible.pot
Normal file
|
@ -0,0 +1,21 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2024-11-25 10:53+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:43
|
||||
msgid "ansible is not set in step.user_data"
|
||||
msgstr ""
|
||||
|
41
pyproject.toml
Normal file
41
pyproject.toml
Normal file
|
@ -0,0 +1,41 @@
|
|||
[build-system]
|
||||
build-backend = "flit_core.buildapi"
|
||||
requires = ["flit_core >=3.8.0,<4"]
|
||||
|
||||
[project]
|
||||
name = "rougail.user_data_ansible"
|
||||
version = "0.0.0"
|
||||
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.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Operating System :: OS Independent",
|
||||
"Natural Language :: English",
|
||||
"Natural Language :: French",
|
||||
|
||||
]
|
||||
dependencies = [
|
||||
"rougail-user-data-file >= 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"
|
||||
update_changelog_on_bump = true
|
||||
changelog_merge_prerelease = true
|
BIN
src/rougail/locale/fr/LC_MESSAGES/user_data_ansible.mo
Normal file
BIN
src/rougail/locale/fr/LC_MESSAGES/user_data_ansible.mo
Normal file
Binary file not shown.
61
src/rougail/user_data_ansible/__init__.py
Normal file
61
src/rougail/user_data_ansible/__init__.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
"""
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024
|
||||
|
||||
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 rougail import RougailConfig
|
||||
from rougail.user_data_file import RougailUserDataFile
|
||||
from ansible.parsing.vault import VaultLib, PromptVaultSecret
|
||||
from ansible.module_utils._text import to_bytes
|
||||
from pathlib import Path
|
||||
|
||||
from .i18n import _
|
||||
|
||||
|
||||
class RougailUserDataAnsible(RougailUserDataFile):
|
||||
def __init__(
|
||||
self,
|
||||
config,
|
||||
*,
|
||||
rougailconfig=None,
|
||||
) -> None:
|
||||
if rougailconfig is None:
|
||||
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 Exception(_("ansible is not set in step.user_data"))
|
||||
self.rougailconfig = rougailconfig
|
||||
self.filenames = self.rougailconfig["ansible.filename"]
|
||||
self.secret = self.rougailconfig["ansible.secret"]
|
||||
self.config = config
|
||||
self.errors = []
|
||||
self.warnings = []
|
||||
|
||||
def open(self, filename: str) -> dict:
|
||||
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",)
|
54
src/rougail/user_data_ansible/config.py
Normal file
54
src/rougail/user_data_ansible/config.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
"""
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024
|
||||
|
||||
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/>.
|
||||
"""
|
||||
|
||||
|
||||
def get_rougail_config(
|
||||
*,
|
||||
backward_compatibility=True,
|
||||
) -> dict:
|
||||
options = """
|
||||
ansible:
|
||||
description: Configuration rougail-user-data-ansible
|
||||
disabled:
|
||||
type: jinja
|
||||
jinja: |
|
||||
{% if 'ansible' not in step.user_data %}
|
||||
disabled
|
||||
{% endif %}
|
||||
filename:
|
||||
description: Ansible filename inventory
|
||||
type: unix_filename
|
||||
multi: true
|
||||
params:
|
||||
allow_relative: True
|
||||
test_existence: True
|
||||
types:
|
||||
- file
|
||||
secret:
|
||||
description: Secret to decrypt file
|
||||
type: secret
|
||||
"""
|
||||
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
|
||||
|
||||
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
|
Loading…
Reference in a new issue