fix: dictionary => structure

This commit is contained in:
egarette@silique.fr 2025-09-22 14:29:45 +02:00
parent aedaff941f
commit e14a83c5cd
8 changed files with 363 additions and 223 deletions

View file

@ -4,66 +4,71 @@
"GROUP1_01": {
"ansible_host": "group1.net",
"rougail": {
"manual": {
"https_proxy": {
"address": null
"leadership": [
{
"leader": "a"
},
"socks_proxy": {
"address": null
{
"leader": "b",
"follower": "value"
}
}
]
}
},
"GROUP2_01": {
"ansible_host": "group2.net",
"rougail": {
"manual": {
"https_proxy": {
"address": null
"leadership": [
{
"leader": "a"
},
"socks_proxy": {
"address": null
{
"leader": "b",
"follower": "value"
}
}
]
}
},
"GROUP2_02": {
"ansible_host": "group3.net",
"rougail": {
"manual": {
"https_proxy": {
"address": null
"leadership": [
{
"leader": "a"
},
"socks_proxy": {
"address": null
{
"leader": "b",
"follower": "value"
}
}
]
}
},
"group4.net": {
"ansible_host": "group4.net",
"rougail": {
"manual": {
"https_proxy": {
"address": null
"leadership": [
{
"leader": "a"
},
"socks_proxy": {
"address": null
{
"leader": "b",
"follower": "value"
}
}
]
}
},
"group5.net": {
"ansible_host": "group5.net",
"rougail": {
"manual": {
"https_proxy": {
"address": null
"leadership": [
{
"leader": "a"
},
"socks_proxy": {
"address": null
{
"leader": "b",
"follower": "value"
}
}
]
}
}
}

View file

@ -0,0 +1,119 @@
{
"_meta": {
"hostvars": {
"GROUP1_01": {
"ansible_host": "group1.net",
"rougail": {
"leadership": [
{
"leader": "string1"
},
{
"leader": "string2",
"follower": "string2"
},
{
"leader": "string3",
"follower": "string3"
}
]
}
},
"GROUP2_01": {
"ansible_host": "group2.net",
"rougail": {
"leadership": [
{
"leader": "string1"
},
{
"leader": "string2",
"follower": "string2"
},
{
"leader": "string3",
"follower": "string3"
}
]
}
},
"GROUP2_02": {
"ansible_host": "group3.net",
"rougail": {
"leadership": [
{
"leader": "string1"
},
{
"leader": "string2",
"follower": "string2"
},
{
"leader": "string3",
"follower": "string3"
}
]
}
},
"group4.net": {
"ansible_host": "group4.net",
"rougail": {
"leadership": [
{
"leader": "string1"
},
{
"leader": "string2",
"follower": "string2"
},
{
"leader": "string3",
"follower": "string3"
}
]
}
},
"group5.net": {
"ansible_host": "group5.net",
"rougail": {
"leadership": [
{
"leader": "string1"
},
{
"leader": "string2",
"follower": "string2"
},
{
"leader": "string3",
"follower": "string3"
}
]
}
}
}
},
"group1": {
"hosts": [
"GROUP1_01"
]
},
"group2": {
"hosts": [
"GROUP2_01",
"GROUP2_02"
]
},
"group3": {
"hosts": [
"group4.net",
"group5.net"
]
},
"groups": {
"children": [
"group1",
"group2"
]
}
}

View file

@ -4,66 +4,71 @@
"GROUP1_01": {
"ansible_host": "group1.net",
"rougail": {
"manual": {
"https_proxy": {
"address": "string1"
"leadership": [
{
"leader": "a"
},
"socks_proxy": {
"address": "string1"
{
"leader": "b",
"follower": "value"
}
}
]
}
},
"GROUP2_01": {
"ansible_host": "group2.net",
"rougail": {
"manual": {
"https_proxy": {
"address": "string1"
"leadership": [
{
"leader": "a"
},
"socks_proxy": {
"address": "string1"
{
"leader": "b",
"follower": "value"
}
}
]
}
},
"GROUP2_02": {
"ansible_host": "group3.net",
"rougail": {
"manual": {
"https_proxy": {
"address": "string1"
"leadership": [
{
"leader": "a"
},
"socks_proxy": {
"address": "string1"
{
"leader": "b",
"follower": "value"
}
}
]
}
},
"group4.net": {
"ansible_host": "group4.net",
"rougail": {
"manual": {
"https_proxy": {
"address": "string1"
"leadership": [
{
"leader": "a"
},
"socks_proxy": {
"address": "string1"
{
"leader": "b",
"follower": "value"
}
}
]
}
},
"group5.net": {
"ansible_host": "group5.net",
"rougail": {
"manual": {
"https_proxy": {
"address": "string1"
"leadership": [
{
"leader": "a"
},
"socks_proxy": {
"address": "string1"
{
"leader": "b",
"follower": "value"
}
}
]
}
}
}

View file

@ -0,0 +1,119 @@
{
"_meta": {
"hostvars": {
"GROUP1_01": {
"ansible_host": "group1.net",
"rougail": {
"leadership": [
{
"leader": "string1"
},
{
"leader": "string2",
"follower": "string2"
},
{
"leader": "string3",
"follower": "string3"
}
]
}
},
"GROUP2_01": {
"ansible_host": "group2.net",
"rougail": {
"leadership": [
{
"leader": "string1"
},
{
"leader": "string2",
"follower": "string2"
},
{
"leader": "string3",
"follower": "string3"
}
]
}
},
"GROUP2_02": {
"ansible_host": "group3.net",
"rougail": {
"leadership": [
{
"leader": "string1"
},
{
"leader": "string2",
"follower": "string2"
},
{
"leader": "string3",
"follower": "string3"
}
]
}
},
"group4.net": {
"ansible_host": "group4.net",
"rougail": {
"leadership": [
{
"leader": "string1"
},
{
"leader": "string2",
"follower": "string2"
},
{
"leader": "string3",
"follower": "string3"
}
]
}
},
"group5.net": {
"ansible_host": "group5.net",
"rougail": {
"leadership": [
{
"leader": "string1"
},
{
"leader": "string2",
"follower": "string2"
},
{
"leader": "string3",
"follower": "string3"
}
]
}
}
}
},
"group1": {
"hosts": [
"GROUP1_01"
]
},
"group2": {
"hosts": [
"GROUP2_01",
"GROUP2_02"
]
},
"group3": {
"hosts": [
"group4.net",
"group5.net"
]
},
"groups": {
"children": [
"group1",
"group2"
]
}
}

View file

@ -1,94 +0,0 @@
{
"_meta": {
"hostvars": {
"GROUP1_01": {
"ansible_host": "group1.net",
"rougail": {
"manual": {
"https_proxy": {
"address": "string1"
},
"socks_proxy": {
"address": "string1"
}
}
}
},
"GROUP2_01": {
"ansible_host": "group2.net",
"rougail": {
"manual": {
"https_proxy": {
"address": "string1"
},
"socks_proxy": {
"address": "string1"
}
}
}
},
"GROUP2_02": {
"ansible_host": "group3.net",
"rougail": {
"manual": {
"https_proxy": {
"address": "string1"
},
"socks_proxy": {
"address": "string1"
}
}
}
},
"group4.net": {
"ansible_host": "group4.net",
"rougail": {
"manual": {
"https_proxy": {
"address": "string1"
},
"socks_proxy": {
"address": "string1"
}
}
}
},
"group5.net": {
"ansible_host": "group5.net",
"rougail": {
"manual": {
"https_proxy": {
"address": "string1"
},
"socks_proxy": {
"address": "string1"
}
}
}
}
}
},
"group1": {
"hosts": [
"GROUP1_01"
]
},
"group2": {
"hosts": [
"GROUP2_01",
"GROUP2_02"
]
},
"group3": {
"hosts": [
"group4.net",
"group5.net"
]
},
"groups": {
"children": [
"group1",
"group2"
]
}
}

View file

@ -4,66 +4,71 @@
"GROUP1_01": {
"ansible_host": "group1.net",
"rougail": {
"manual": {
"https_proxy": {
"address": "string1"
"leadership": [
{
"leader": "a"
},
"socks_proxy": {
"address": "string1"
{
"leader": "b",
"follower": "value"
}
}
]
}
},
"GROUP2_01": {
"ansible_host": "group2.net",
"rougail": {
"manual": {
"https_proxy": {
"address": "string1"
"leadership": [
{
"leader": "a"
},
"socks_proxy": {
"address": "string1"
{
"leader": "b",
"follower": "value"
}
}
]
}
},
"GROUP2_02": {
"ansible_host": "group3.net",
"rougail": {
"manual": {
"https_proxy": {
"address": "string1"
"leadership": [
{
"leader": "a"
},
"socks_proxy": {
"address": "string1"
{
"leader": "b",
"follower": "value"
}
}
]
}
},
"group4.net": {
"ansible_host": "group4.net",
"rougail": {
"manual": {
"https_proxy": {
"address": "string1"
"leadership": [
{
"leader": "a"
},
"socks_proxy": {
"address": "string1"
{
"leader": "b",
"follower": "value"
}
}
]
}
},
"group5.net": {
"ansible_host": "group5.net",
"rougail": {
"manual": {
"https_proxy": {
"address": "string1"
"leadership": [
{
"leader": "a"
},
"socks_proxy": {
"address": "string1"
{
"leader": "b",
"follower": "value"
}
}
]
}
}
}

View file

@ -1,19 +0,0 @@
{
"_meta": {
"hostvars": {
"localhost": {
"_errors": [
"The following variables are mandatory but have no value:",
" - rougail.manual.https_proxy.address ({{ identifier }} address)",
" - rougail.manual.https_proxy.address (HTTPS address)",
" - rougail.manual.socks_proxy.address (SOCKS address)"
]
}
}
},
"ungrouped": {
"hosts": [
"localhost"
]
}
}

View file

@ -31,7 +31,7 @@ def test_dir(request):
return request.param
def _test_dictionaries(test_dir, namespace, ext, *, read_write=True, mandatory=False, do_calc=True):
def _test_structural_files(test_dir, namespace, ext, *, read_write=True, mandatory=False, do_calc=True):
rougailconfig = get_rougail_config(test_dir, namespace)
if not rougailconfig:
return
@ -39,9 +39,9 @@ def _test_dictionaries(test_dir, namespace, ext, *, read_write=True, mandatory=F
rougailconfig['step.output'] = 'ansible'
rougailconfig["json.read_write"] = read_write
rougailconfig["json.mandatory"] = mandatory
extra_dictionaries = rougailconfig["extra_dictionaries"]
extra_dictionaries["hosts"] = [str(Path(__file__).parent / "hosts")]
rougailconfig['extra_dictionaries'] = extra_dictionaries
extra_namespaces = rougailconfig["extra_namespaces"]
extra_namespaces["hosts"] = [str(Path(__file__).parent / "hosts")]
rougailconfig['extra_namespaces'] = extra_namespaces
##################################
dir_name = 'test'
if namespace:
@ -79,24 +79,24 @@ def _test_dictionaries(test_dir, namespace, ext, *, read_write=True, mandatory=F
# do not test without namespace, ansible needs namespaces
def test_dictionaries_ansible_namespace(test_dir):
_test_dictionaries(test_dir, True, EXT)
def test_structural_files_ansible_namespace(test_dir):
_test_structural_files(test_dir, True, EXT)
def test_dictionaries_ansible_namespace_errors(test_dir):
_test_dictionaries(test_dir, True, EXT, do_calc=False, mandatory=True)
def test_structural_files_ansible_namespace_errors(test_dir):
_test_structural_files(test_dir, True, EXT, do_calc=False, mandatory=True)
def test_dictionaries_ansible_namespace_read_only(test_dir):
_test_dictionaries(test_dir, True, EXT, read_write=False)
def test_structural_files_ansible_namespace_read_only(test_dir):
_test_structural_files(test_dir, True, EXT, read_write=False)
def test_dictionaries_ansible_namespace_mandatory(test_dir):
_test_dictionaries(test_dir, True, EXT, mandatory=True)
def test_structural_files_ansible_namespace_mandatory(test_dir):
_test_structural_files(test_dir, True, EXT, mandatory=True)
def test_dictionaries_ansible_namespace_mandatory_read_only(test_dir):
_test_dictionaries(test_dir, True, EXT, read_write=False, mandatory=True)
def test_structural_files_ansible_namespace_mandatory_read_only(test_dir):
_test_structural_files(test_dir, True, EXT, read_write=False, mandatory=True)
def test_warnings():
@ -105,9 +105,9 @@ def test_warnings():
rougailconfig['step.output'] = 'ansible'
rougailconfig['step.user_data'] = ['yaml']
rougailconfig['yaml.filename'] = ['tests/warnings/yaml/config.yml']
extra_dictionaries = rougailconfig["extra_dictionaries"]
extra_dictionaries["hosts"] = [str(Path(__file__).parent / "hosts")]
rougailconfig['extra_dictionaries'] = extra_dictionaries
extra_namespaces = rougailconfig["extra_namespaces"]
extra_namespaces["hosts"] = [str(Path(__file__).parent / "hosts")]
rougailconfig['extra_namespaces'] = extra_namespaces
##################################
rougail = Rougail(rougailconfig)
config = rougail.run()
@ -201,9 +201,9 @@ def test_no_warnings():
rougailconfig['ansible.export_warnings'] = False
rougailconfig['step.user_data'] = ['yaml']
rougailconfig['yaml.filename'] = ['tests/warnings/yaml/config.yml']
extra_dictionaries = rougailconfig["extra_dictionaries"]
extra_dictionaries["hosts"] = [str(Path(__file__).parent / "hosts")]
rougailconfig['extra_dictionaries'] = extra_dictionaries
extra_namespaces = rougailconfig["extra_namespaces"]
extra_namespaces["hosts"] = [str(Path(__file__).parent / "hosts")]
rougailconfig['extra_namespaces'] = extra_namespaces
##################################
rougail = Rougail(rougailconfig)
config = rougail.run()