fix(ansible): group names Ansible accepts, and interpreter discovery without the warning (#5334)
Every run warned twice because of Steward's own inventory: - 'Invalid characters were found in group names': the group 'Docker Swarm' went into the inventory as typed. ansible_group_name() cleans it to docker_swarm (lower case, [a-z0-9_], never a leading digit); two names that clean alike get _2, _3 so neither folds into the other. The group page says what plays call it. The display name is unchanged. - Python interpreter discovery: ansible_env sets ANSIBLE_PYTHON_INTERPRETER=auto_silent unless the environment already sets one; a target or group's ansible_python_interpreter still wins. Runs are scoped by target set (steward:group:<id>), not by group name, and --limit is free text, so neither path depends on the name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -109,7 +109,7 @@ def test_ansible_run_scope_column_exists():
|
||||
def test_create_target_and_group_and_fetch():
|
||||
"""Can create a target+group, assign membership, and fetch via fetch_scope_targets."""
|
||||
from steward.models.ansible_inventory import AnsibleTarget, AnsibleGroup
|
||||
from steward.ansible.inventory_gen import fetch_scope_targets, generate_inventory
|
||||
from steward.ansible.inventory_gen import ansible_group_name, fetch_scope_targets, generate_inventory
|
||||
|
||||
app = _make_app()
|
||||
target_id = str(uuid.uuid4())
|
||||
@@ -157,7 +157,7 @@ def test_create_target_and_group_and_fetch():
|
||||
targets = await fetch_scope_targets(db, f"steward:group:{group_id}")
|
||||
inv = generate_inventory(targets)
|
||||
assert target_name in inv["all"]["hosts"]
|
||||
assert target_name in inv[group_name]["hosts"]
|
||||
assert target_name in inv[ansible_group_name(group_name)]["hosts"] # test_group_… (#5334)
|
||||
assert inv["_meta"]["hostvars"][target_name]["ansible_host"] == "10.0.99.1"
|
||||
assert inv["_meta"]["hostvars"][target_name]["ansible_user"] == "ubuntu"
|
||||
assert inv["_meta"]["hostvars"][target_name]["env"] == "test"
|
||||
|
||||
Reference in New Issue
Block a user