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": { "GROUP1_01": {
"ansible_host": "group1.net", "ansible_host": "group1.net",
"rougail": { "rougail": {
"manual": { "leadership": [
"https_proxy": { {
"address": null "leader": "a"
}, },
"socks_proxy": { {
"address": null "leader": "b",
"follower": "value"
} }
} ]
} }
}, },
"GROUP2_01": { "GROUP2_01": {
"ansible_host": "group2.net", "ansible_host": "group2.net",
"rougail": { "rougail": {
"manual": { "leadership": [
"https_proxy": { {
"address": null "leader": "a"
}, },
"socks_proxy": { {
"address": null "leader": "b",
"follower": "value"
} }
} ]
} }
}, },
"GROUP2_02": { "GROUP2_02": {
"ansible_host": "group3.net", "ansible_host": "group3.net",
"rougail": { "rougail": {
"manual": { "leadership": [
"https_proxy": { {
"address": null "leader": "a"
}, },
"socks_proxy": { {
"address": null "leader": "b",
"follower": "value"
} }
} ]
} }
}, },
"group4.net": { "group4.net": {
"ansible_host": "group4.net", "ansible_host": "group4.net",
"rougail": { "rougail": {
"manual": { "leadership": [
"https_proxy": { {
"address": null "leader": "a"
}, },
"socks_proxy": { {
"address": null "leader": "b",
"follower": "value"
} }
} ]
} }
}, },
"group5.net": { "group5.net": {
"ansible_host": "group5.net", "ansible_host": "group5.net",
"rougail": { "rougail": {
"manual": { "leadership": [
"https_proxy": { {
"address": null "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": { "GROUP1_01": {
"ansible_host": "group1.net", "ansible_host": "group1.net",
"rougail": { "rougail": {
"manual": { "leadership": [
"https_proxy": { {
"address": "string1" "leader": "a"
}, },
"socks_proxy": { {
"address": "string1" "leader": "b",
"follower": "value"
} }
} ]
} }
}, },
"GROUP2_01": { "GROUP2_01": {
"ansible_host": "group2.net", "ansible_host": "group2.net",
"rougail": { "rougail": {
"manual": { "leadership": [
"https_proxy": { {
"address": "string1" "leader": "a"
}, },
"socks_proxy": { {
"address": "string1" "leader": "b",
"follower": "value"
} }
} ]
} }
}, },
"GROUP2_02": { "GROUP2_02": {
"ansible_host": "group3.net", "ansible_host": "group3.net",
"rougail": { "rougail": {
"manual": { "leadership": [
"https_proxy": { {
"address": "string1" "leader": "a"
}, },
"socks_proxy": { {
"address": "string1" "leader": "b",
"follower": "value"
} }
} ]
} }
}, },
"group4.net": { "group4.net": {
"ansible_host": "group4.net", "ansible_host": "group4.net",
"rougail": { "rougail": {
"manual": { "leadership": [
"https_proxy": { {
"address": "string1" "leader": "a"
}, },
"socks_proxy": { {
"address": "string1" "leader": "b",
"follower": "value"
} }
} ]
} }
}, },
"group5.net": { "group5.net": {
"ansible_host": "group5.net", "ansible_host": "group5.net",
"rougail": { "rougail": {
"manual": { "leadership": [
"https_proxy": { {
"address": "string1" "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": { "GROUP1_01": {
"ansible_host": "group1.net", "ansible_host": "group1.net",
"rougail": { "rougail": {
"manual": { "leadership": [
"https_proxy": { {
"address": "string1" "leader": "a"
}, },
"socks_proxy": { {
"address": "string1" "leader": "b",
"follower": "value"
} }
} ]
} }
}, },
"GROUP2_01": { "GROUP2_01": {
"ansible_host": "group2.net", "ansible_host": "group2.net",
"rougail": { "rougail": {
"manual": { "leadership": [
"https_proxy": { {
"address": "string1" "leader": "a"
}, },
"socks_proxy": { {
"address": "string1" "leader": "b",
"follower": "value"
} }
} ]
} }
}, },
"GROUP2_02": { "GROUP2_02": {
"ansible_host": "group3.net", "ansible_host": "group3.net",
"rougail": { "rougail": {
"manual": { "leadership": [
"https_proxy": { {
"address": "string1" "leader": "a"
}, },
"socks_proxy": { {
"address": "string1" "leader": "b",
"follower": "value"
} }
} ]
} }
}, },
"group4.net": { "group4.net": {
"ansible_host": "group4.net", "ansible_host": "group4.net",
"rougail": { "rougail": {
"manual": { "leadership": [
"https_proxy": { {
"address": "string1" "leader": "a"
}, },
"socks_proxy": { {
"address": "string1" "leader": "b",
"follower": "value"
} }
} ]
} }
}, },
"group5.net": { "group5.net": {
"ansible_host": "group5.net", "ansible_host": "group5.net",
"rougail": { "rougail": {
"manual": { "leadership": [
"https_proxy": { {
"address": "string1" "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 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) rougailconfig = get_rougail_config(test_dir, namespace)
if not rougailconfig: if not rougailconfig:
return return
@ -39,9 +39,9 @@ def _test_dictionaries(test_dir, namespace, ext, *, read_write=True, mandatory=F
rougailconfig['step.output'] = 'ansible' rougailconfig['step.output'] = 'ansible'
rougailconfig["json.read_write"] = read_write rougailconfig["json.read_write"] = read_write
rougailconfig["json.mandatory"] = mandatory rougailconfig["json.mandatory"] = mandatory
extra_dictionaries = rougailconfig["extra_dictionaries"] extra_namespaces = rougailconfig["extra_namespaces"]
extra_dictionaries["hosts"] = [str(Path(__file__).parent / "hosts")] extra_namespaces["hosts"] = [str(Path(__file__).parent / "hosts")]
rougailconfig['extra_dictionaries'] = extra_dictionaries rougailconfig['extra_namespaces'] = extra_namespaces
################################## ##################################
dir_name = 'test' dir_name = 'test'
if namespace: 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 # do not test without namespace, ansible needs namespaces
def test_dictionaries_ansible_namespace(test_dir): def test_structural_files_ansible_namespace(test_dir):
_test_dictionaries(test_dir, True, EXT) _test_structural_files(test_dir, True, EXT)
def test_dictionaries_ansible_namespace_errors(test_dir): def test_structural_files_ansible_namespace_errors(test_dir):
_test_dictionaries(test_dir, True, EXT, do_calc=False, mandatory=True) _test_structural_files(test_dir, True, EXT, do_calc=False, mandatory=True)
def test_dictionaries_ansible_namespace_read_only(test_dir): def test_structural_files_ansible_namespace_read_only(test_dir):
_test_dictionaries(test_dir, True, EXT, read_write=False) _test_structural_files(test_dir, True, EXT, read_write=False)
def test_dictionaries_ansible_namespace_mandatory(test_dir): def test_structural_files_ansible_namespace_mandatory(test_dir):
_test_dictionaries(test_dir, True, EXT, mandatory=True) _test_structural_files(test_dir, True, EXT, mandatory=True)
def test_dictionaries_ansible_namespace_mandatory_read_only(test_dir): def test_structural_files_ansible_namespace_mandatory_read_only(test_dir):
_test_dictionaries(test_dir, True, EXT, read_write=False, mandatory=True) _test_structural_files(test_dir, True, EXT, read_write=False, mandatory=True)
def test_warnings(): def test_warnings():
@ -105,9 +105,9 @@ def test_warnings():
rougailconfig['step.output'] = 'ansible' rougailconfig['step.output'] = 'ansible'
rougailconfig['step.user_data'] = ['yaml'] rougailconfig['step.user_data'] = ['yaml']
rougailconfig['yaml.filename'] = ['tests/warnings/yaml/config.yml'] rougailconfig['yaml.filename'] = ['tests/warnings/yaml/config.yml']
extra_dictionaries = rougailconfig["extra_dictionaries"] extra_namespaces = rougailconfig["extra_namespaces"]
extra_dictionaries["hosts"] = [str(Path(__file__).parent / "hosts")] extra_namespaces["hosts"] = [str(Path(__file__).parent / "hosts")]
rougailconfig['extra_dictionaries'] = extra_dictionaries rougailconfig['extra_namespaces'] = extra_namespaces
################################## ##################################
rougail = Rougail(rougailconfig) rougail = Rougail(rougailconfig)
config = rougail.run() config = rougail.run()
@ -201,9 +201,9 @@ def test_no_warnings():
rougailconfig['ansible.export_warnings'] = False rougailconfig['ansible.export_warnings'] = False
rougailconfig['step.user_data'] = ['yaml'] rougailconfig['step.user_data'] = ['yaml']
rougailconfig['yaml.filename'] = ['tests/warnings/yaml/config.yml'] rougailconfig['yaml.filename'] = ['tests/warnings/yaml/config.yml']
extra_dictionaries = rougailconfig["extra_dictionaries"] extra_namespaces = rougailconfig["extra_namespaces"]
extra_dictionaries["hosts"] = [str(Path(__file__).parent / "hosts")] extra_namespaces["hosts"] = [str(Path(__file__).parent / "hosts")]
rougailconfig['extra_dictionaries'] = extra_dictionaries rougailconfig['extra_namespaces'] = extra_namespaces
################################## ##################################
rougail = Rougail(rougailconfig) rougail = Rougail(rougailconfig)
config = rougail.run() config = rougail.run()