diff --git a/locale/fr/LC_MESSAGES/rougail_output_ansible.po b/locale/fr/LC_MESSAGES/rougail_output_ansible.po index b53c2f8..418a75a 100644 --- a/locale/fr/LC_MESSAGES/rougail_output_ansible.po +++ b/locale/fr/LC_MESSAGES/rougail_output_ansible.po @@ -18,7 +18,7 @@ msgstr "" #: src/rougail/output_exporter/__init__.py:73 msgid "The following variables are mandatory but have no value:" -msgstr "Les variables suiveuses sont obligatoire mais n'ont pas de valeur :" +msgstr "Les variables suivantes sont obligatoire mais n'ont pas de valeur :" #: src/rougail/output_exporter/__init__.py:84 msgid "The following variables are inaccessible but are empty and mandatory :" diff --git a/locale/rougail_output_ansible.pot b/locale/rougail_output_ansible.pot index 6fd3c0a..cea5bc1 100644 --- a/locale/rougail_output_ansible.pot +++ b/locale/rougail_output_ansible.pot @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2024-11-01 11:03+0100\n" +"POT-Creation-Date: 2024-12-29 10:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -15,43 +15,19 @@ msgstr "" "Generated-By: pygettext.py 1.5\n" -#: src/rougail/output_exporter/__init__.py:73 -msgid "The following variables are mandatory but have no value:" +#: src/rougail/output_ansible/__init__.py:55 +msgid "no namespace configured" msgstr "" -#: src/rougail/output_exporter/__init__.py:84 -msgid "The following variables are inaccessible but are empty and mandatory :" +#: src/rougail/output_ansible/__init__.py:63 +msgid "cannot find hosts namespace \"{0}\"" msgstr "" -#: src/rougail/output_exporter/output/console.py:53 -msgid "Undocumented variable" +#: src/rougail/output_ansible/__init__.py:68 +msgid "malformated hosts namespace \"{0}\", should has \"hostnames\"" msgstr "" -#: src/rougail/output_exporter/output/console.py:54 -msgid "Undocumented but modified variable" -msgstr "" - -#: src/rougail/output_exporter/output/console.py:57 -msgid "Unmodifiable variable" -msgstr "" - -#: src/rougail/output_exporter/output/console.py:61 -msgid "Default value" -msgstr "" - -#: src/rougail/output_exporter/output/console.py:62 -msgid "Modified value" -msgstr "" - -#: src/rougail/output_exporter/output/console.py:63 -msgid "Original default value" -msgstr "" - -#: src/rougail/output_exporter/output/console.py:67 -msgid "Caption" -msgstr "" - -#: src/rougail/output_exporter/output/console.py:92 -msgid "Variables:" +#: src/rougail/output_ansible/__init__.py:95 +msgid "cannot find \"hostnames\" in \"{0}\" namespace" msgstr "" diff --git a/src/rougail/output_ansible/__init__.py b/src/rougail/output_ansible/__init__.py index a9bce01..e8e916d 100644 --- a/src/rougail/output_ansible/__init__.py +++ b/src/rougail/output_ansible/__init__.py @@ -20,6 +20,7 @@ from typing import Optional from json import dumps from tiramisu import groups +from rougail.utils import normalize_family from .i18n import _ from ..output_json import RougailOutputJson @@ -42,6 +43,7 @@ class RougailOutputAnsible(RougailOutputJson): except AttributeError: self.support_namespace = False self.host_namespace = self.rougailconfig["ansible.host_namespace"] + self.namespace_is_hostname = self.rougailconfig["ansible.namespace_is_hostname"] def exporter(self) -> None: super().exporter() @@ -99,11 +101,20 @@ class RougailOutputAnsible(RougailOutputJson): ret_hosts = {} for name, hosts in hostnames.items(): if 'hosts' in hosts: + if 'prefix_name' in hosts: + host_name = hosts['prefix_name'] + add_index = True + elif len(hosts["hosts"]) == 1: + host_name = hosts["hosts"][0] + add_index = False + else: + raise Exception("cannot find prefix_name") for idx, host in enumerate(hosts['hosts']): index = str(idx + 1) if idx < 9: index = '0' + index - host_name = hosts['prefix_name'] + index + if 'prefix_name' in hosts: + host_name = hosts['prefix_name'] + index ret_hosts.setdefault(name, {})[host_name] = host ret.setdefault(name, {}).setdefault('hosts', []).append(host_name) else: @@ -112,7 +123,12 @@ class RougailOutputAnsible(RougailOutputJson): for hosts in ret_hosts.values(): for host, domain_name in hosts.items(): ret['_meta']['hostvars'][host] = {'ansible_host': domain_name} - ret['_meta']['hostvars'][host].update(self.dico) + if self.namespace_is_hostname: + host_namespace = normalize_family(host) + if host_namespace in self.dico: + ret['_meta']['hostvars'][host].update(self.dico[host_namespace]) + else: + ret['_meta']['hostvars'][host].update(self.dico) self.dico = ret diff --git a/src/rougail/output_ansible/config.py b/src/rougail/output_ansible/config.py index e9a5b82..617264c 100644 --- a/src/rougail/output_ansible/config.py +++ b/src/rougail/output_ansible/config.py @@ -25,8 +25,8 @@ def get_rougail_config( ) -> dict: options = """ list: - description: parameter added only to be compatible with Ansible - negative_description: parameter added only to be compatible with Ansible + description: parameter added only to be compatible with Ansible + negative_description: parameter added only to be compatible with Ansible default: false disabled: type: jinja @@ -53,6 +53,11 @@ ansible: host_namespace: description: Namespace with host values default: "hosts" + + namespace_is_hostname: + description: Only variables in hostname namespace is available by a host + negative_description: All variables is available for all hosts + default: false """ return { "name": "ansible", diff --git a/src/rougail/output_ansible/locale/fr/LC_MESSAGES/rougail_output_ansible.mo b/src/rougail/output_ansible/locale/fr/LC_MESSAGES/rougail_output_ansible.mo index fb7e0ae..a6ac73d 100644 Binary files a/src/rougail/output_ansible/locale/fr/LC_MESSAGES/rougail_output_ansible.mo and b/src/rougail/output_ansible/locale/fr/LC_MESSAGES/rougail_output_ansible.mo differ diff --git a/tests/hosts/00-ip.yml b/tests/hosts/00-ip.yml index 619177a..2d942c3 100644 --- a/tests/hosts/00-ip.yml +++ b/tests/hosts/00-ip.yml @@ -5,19 +5,23 @@ hostnames: hidden: true group1: + hosts: type: domainname multi: true default: - group1.net + prefix_name: default: GROUP1_ group2: + hosts: type: domainname multi: true default: - group2.net + prefix_name: default: GROUP2_ diff --git a/tests/results/test_namespace/00_9default_information_other_variable2.json b/tests/results/test_namespace/00_9default_information_other_variable2.json new file mode 100644 index 0000000..26a7682 --- /dev/null +++ b/tests/results/test_namespace/00_9default_information_other_variable2.json @@ -0,0 +1,42 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "var1": "string1", + "var2": "string1" + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "var1": "string1", + "var2": "string1" + } + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace/00_9extra_ouside.json b/tests/results/test_namespace/00_9extra_ouside.json new file mode 100644 index 0000000..a9492d3 --- /dev/null +++ b/tests/results/test_namespace/00_9extra_ouside.json @@ -0,0 +1,46 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "variable": "string1" + }, + "extra": { + "variable": "string1" + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "variable": "string1" + }, + "extra": { + "variable": "string1" + } + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace/01_6string_multi.json b/tests/results/test_namespace/01_6string_multi.json index 9a35202..e898083 100644 --- a/tests/results/test_namespace/01_6string_multi.json +++ b/tests/results/test_namespace/01_6string_multi.json @@ -14,7 +14,11 @@ "string2", "string3" ], - "var3": "string1", + "var3": [ + "string1", + "string2", + "string3" + ], "var4": [ "string1", "string2", @@ -55,7 +59,11 @@ "string2", "string3" ], - "var3": "string1", + "var3": [ + "string1", + "string2", + "string3" + ], "var4": [ "string1", "string2", diff --git a/tests/results/test_namespace/16_6exists_family.json b/tests/results/test_namespace/16_6exists_family.json new file mode 100644 index 0000000..376094e --- /dev/null +++ b/tests/results/test_namespace/16_6exists_family.json @@ -0,0 +1,36 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": {} + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": {} + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_empty2.json b/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_empty2.json new file mode 100644 index 0000000..9e1fa6e --- /dev/null +++ b/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_empty2.json @@ -0,0 +1,134 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "var": [ + "val1", + "val2" + ], + "dynval1": { + "var": [ + "string1", + "string2", + "string3" + ], + "dyn_string1": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string2": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string3": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + } + }, + "dynval2": { + "var": [ + "string1", + "string2", + "string3" + ], + "dyn_string1": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string2": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string3": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + } + } + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "var": [ + "val1", + "val2" + ], + "dynval1": { + "var": [ + "string1", + "string2", + "string3" + ], + "dyn_string1": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string2": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string3": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + } + }, + "dynval2": { + "var": [ + "string1", + "string2", + "string3" + ], + "dyn_string1": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string2": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string3": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + } + } + } + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace_mandatory/00_9default_information_other_variable2.json b/tests/results/test_namespace_mandatory/00_9default_information_other_variable2.json new file mode 100644 index 0000000..26a7682 --- /dev/null +++ b/tests/results/test_namespace_mandatory/00_9default_information_other_variable2.json @@ -0,0 +1,42 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "var1": "string1", + "var2": "string1" + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "var1": "string1", + "var2": "string1" + } + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace_mandatory/00_9extra_ouside.json b/tests/results/test_namespace_mandatory/00_9extra_ouside.json new file mode 100644 index 0000000..a9492d3 --- /dev/null +++ b/tests/results/test_namespace_mandatory/00_9extra_ouside.json @@ -0,0 +1,46 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "variable": "string1" + }, + "extra": { + "variable": "string1" + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "variable": "string1" + }, + "extra": { + "variable": "string1" + } + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace_mandatory/01_6string_multi.json b/tests/results/test_namespace_mandatory/01_6string_multi.json index 9a35202..e898083 100644 --- a/tests/results/test_namespace_mandatory/01_6string_multi.json +++ b/tests/results/test_namespace_mandatory/01_6string_multi.json @@ -14,7 +14,11 @@ "string2", "string3" ], - "var3": "string1", + "var3": [ + "string1", + "string2", + "string3" + ], "var4": [ "string1", "string2", @@ -55,7 +59,11 @@ "string2", "string3" ], - "var3": "string1", + "var3": [ + "string1", + "string2", + "string3" + ], "var4": [ "string1", "string2", diff --git a/tests/results/test_namespace_mandatory/16_6exists_family.json b/tests/results/test_namespace_mandatory/16_6exists_family.json new file mode 100644 index 0000000..376094e --- /dev/null +++ b/tests/results/test_namespace_mandatory/16_6exists_family.json @@ -0,0 +1,36 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": {} + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": {} + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace_mandatory/60_6family_dynamic_sub_dynamic_empty2.json b/tests/results/test_namespace_mandatory/60_6family_dynamic_sub_dynamic_empty2.json new file mode 100644 index 0000000..9e1fa6e --- /dev/null +++ b/tests/results/test_namespace_mandatory/60_6family_dynamic_sub_dynamic_empty2.json @@ -0,0 +1,134 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "var": [ + "val1", + "val2" + ], + "dynval1": { + "var": [ + "string1", + "string2", + "string3" + ], + "dyn_string1": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string2": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string3": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + } + }, + "dynval2": { + "var": [ + "string1", + "string2", + "string3" + ], + "dyn_string1": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string2": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string3": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + } + } + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "var": [ + "val1", + "val2" + ], + "dynval1": { + "var": [ + "string1", + "string2", + "string3" + ], + "dyn_string1": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string2": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string3": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + } + }, + "dynval2": { + "var": [ + "string1", + "string2", + "string3" + ], + "dyn_string1": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string2": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string3": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + } + } + } + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace_read_write/00_9default_information_other_variable2.json b/tests/results/test_namespace_read_write/00_9default_information_other_variable2.json new file mode 100644 index 0000000..11cd802 --- /dev/null +++ b/tests/results/test_namespace_read_write/00_9default_information_other_variable2.json @@ -0,0 +1,42 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "var1": null, + "var2": null + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "var1": null, + "var2": null + } + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace_read_write/00_9extra_ouside.json b/tests/results/test_namespace_read_write/00_9extra_ouside.json new file mode 100644 index 0000000..2877672 --- /dev/null +++ b/tests/results/test_namespace_read_write/00_9extra_ouside.json @@ -0,0 +1,46 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "variable": "value in extra" + }, + "extra": { + "variable": "value in extra" + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "variable": "value in extra" + }, + "extra": { + "variable": "value in extra" + } + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace_read_write/01_6string_multi.json b/tests/results/test_namespace_read_write/01_6string_multi.json index b87208d..540355a 100644 --- a/tests/results/test_namespace_read_write/01_6string_multi.json +++ b/tests/results/test_namespace_read_write/01_6string_multi.json @@ -6,7 +6,7 @@ "rougail": { "var1": [], "var2": [], - "var3": null, + "var3": [], "var4": [ "value" ], @@ -29,7 +29,7 @@ "rougail": { "var1": [], "var2": [], - "var3": null, + "var3": [], "var4": [ "value" ], diff --git a/tests/results/test_namespace_read_write/16_6exists_family.json b/tests/results/test_namespace_read_write/16_6exists_family.json new file mode 100644 index 0000000..376094e --- /dev/null +++ b/tests/results/test_namespace_read_write/16_6exists_family.json @@ -0,0 +1,36 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": {} + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": {} + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace_read_write/60_6family_dynamic_sub_dynamic_empty2.json b/tests/results/test_namespace_read_write/60_6family_dynamic_sub_dynamic_empty2.json new file mode 100644 index 0000000..c7d489c --- /dev/null +++ b/tests/results/test_namespace_read_write/60_6family_dynamic_sub_dynamic_empty2.json @@ -0,0 +1,58 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "var": [ + "val1", + "val2" + ], + "dynval1": { + "var": [] + }, + "dynval2": { + "var": [] + } + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "var": [ + "val1", + "val2" + ], + "dynval1": { + "var": [] + }, + "dynval2": { + "var": [] + } + } + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace_read_write_mandatory/00_9default_information_other_variable2.json b/tests/results/test_namespace_read_write_mandatory/00_9default_information_other_variable2.json new file mode 100644 index 0000000..26a7682 --- /dev/null +++ b/tests/results/test_namespace_read_write_mandatory/00_9default_information_other_variable2.json @@ -0,0 +1,42 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "var1": "string1", + "var2": "string1" + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "var1": "string1", + "var2": "string1" + } + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace_read_write_mandatory/00_9extra_ouside.json b/tests/results/test_namespace_read_write_mandatory/00_9extra_ouside.json new file mode 100644 index 0000000..a9492d3 --- /dev/null +++ b/tests/results/test_namespace_read_write_mandatory/00_9extra_ouside.json @@ -0,0 +1,46 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "variable": "string1" + }, + "extra": { + "variable": "string1" + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "variable": "string1" + }, + "extra": { + "variable": "string1" + } + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace_read_write_mandatory/01_6string_multi.json b/tests/results/test_namespace_read_write_mandatory/01_6string_multi.json index 9a35202..e898083 100644 --- a/tests/results/test_namespace_read_write_mandatory/01_6string_multi.json +++ b/tests/results/test_namespace_read_write_mandatory/01_6string_multi.json @@ -14,7 +14,11 @@ "string2", "string3" ], - "var3": "string1", + "var3": [ + "string1", + "string2", + "string3" + ], "var4": [ "string1", "string2", @@ -55,7 +59,11 @@ "string2", "string3" ], - "var3": "string1", + "var3": [ + "string1", + "string2", + "string3" + ], "var4": [ "string1", "string2", diff --git a/tests/results/test_namespace_read_write_mandatory/16_6exists_family.json b/tests/results/test_namespace_read_write_mandatory/16_6exists_family.json new file mode 100644 index 0000000..376094e --- /dev/null +++ b/tests/results/test_namespace_read_write_mandatory/16_6exists_family.json @@ -0,0 +1,36 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": {} + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": {} + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace_read_write_mandatory/60_6family_dynamic_sub_dynamic_empty2.json b/tests/results/test_namespace_read_write_mandatory/60_6family_dynamic_sub_dynamic_empty2.json new file mode 100644 index 0000000..9e1fa6e --- /dev/null +++ b/tests/results/test_namespace_read_write_mandatory/60_6family_dynamic_sub_dynamic_empty2.json @@ -0,0 +1,134 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "var": [ + "val1", + "val2" + ], + "dynval1": { + "var": [ + "string1", + "string2", + "string3" + ], + "dyn_string1": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string2": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string3": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + } + }, + "dynval2": { + "var": [ + "string1", + "string2", + "string3" + ], + "dyn_string1": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string2": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string3": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + } + } + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "var": [ + "val1", + "val2" + ], + "dynval1": { + "var": [ + "string1", + "string2", + "string3" + ], + "dyn_string1": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string2": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string3": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + } + }, + "dynval2": { + "var": [ + "string1", + "string2", + "string3" + ], + "dyn_string1": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string2": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + }, + "dyn_string3": { + "var": "string1", + "var_identifier": "string1", + "var_identifiers": "string1" + } + } + } + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace_read_write_mandatory_errors/00_9default_information_other_variable2.json b/tests/results/test_namespace_read_write_mandatory_errors/00_9default_information_other_variable2.json new file mode 100644 index 0000000..9ef0862 --- /dev/null +++ b/tests/results/test_namespace_read_write_mandatory_errors/00_9default_information_other_variable2.json @@ -0,0 +1,23 @@ +{ + "_meta": { + "hostvars": { + "localhost": { + "_errors": [ + "The following variables are mandatory but have no value:", + " - rougail.var1 (a first variable)", + " - rougail.var2 (a second variable)" + ] + } + } + }, + "all": { + "children": [ + "ungrouped" + ] + }, + "ungrouped": { + "hosts": [ + "localhost" + ] + } +} diff --git a/tests/results/test_namespace_read_write_mandatory_errors/00_9extra_ouside.json b/tests/results/test_namespace_read_write_mandatory_errors/00_9extra_ouside.json new file mode 100644 index 0000000..2877672 --- /dev/null +++ b/tests/results/test_namespace_read_write_mandatory_errors/00_9extra_ouside.json @@ -0,0 +1,46 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "variable": "value in extra" + }, + "extra": { + "variable": "value in extra" + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "variable": "value in extra" + }, + "extra": { + "variable": "value in extra" + } + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace_read_write_mandatory_errors/16_6exists_family.json b/tests/results/test_namespace_read_write_mandatory_errors/16_6exists_family.json new file mode 100644 index 0000000..376094e --- /dev/null +++ b/tests/results/test_namespace_read_write_mandatory_errors/16_6exists_family.json @@ -0,0 +1,36 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": {} + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": {} + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} diff --git a/tests/results/test_namespace_read_write_mandatory_errors/60_6family_dynamic_sub_dynamic_empty2.json b/tests/results/test_namespace_read_write_mandatory_errors/60_6family_dynamic_sub_dynamic_empty2.json new file mode 100644 index 0000000..c7d489c --- /dev/null +++ b/tests/results/test_namespace_read_write_mandatory_errors/60_6family_dynamic_sub_dynamic_empty2.json @@ -0,0 +1,58 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "var": [ + "val1", + "val2" + ], + "dynval1": { + "var": [] + }, + "dynval2": { + "var": [] + } + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "var": [ + "val1", + "val2" + ], + "dynval1": { + "var": [] + }, + "dynval2": { + "var": [] + } + } + } + } + }, + "all": { + "children": [ + "ungrouped", + "groups" + ] + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +}