ansible: add reboot playbook and short hostname support
- Add reboot.yml playbook with rolling reboot (serial: 1) - Uses systemd reboot.target for NixOS compatibility - Waits for each host to come back before proceeding - Update dynamic inventory to use short hostnames - ansible_host set to FQDN for connections - Allows -l testvm01 instead of -l testvm01.home.2rjus.net - Update static.yml to match short hostname convention Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -102,28 +102,32 @@ def build_inventory(hosts_data: dict) -> dict:
|
||||
|
||||
fqdn = f"{hostname}.{domain}"
|
||||
|
||||
# Use short hostname as inventory name, FQDN for connection
|
||||
inventory_name = hostname
|
||||
|
||||
# Add to flake_hosts group
|
||||
inventory["flake_hosts"]["hosts"].append(fqdn)
|
||||
inventory["flake_hosts"]["hosts"].append(inventory_name)
|
||||
|
||||
# Add host variables
|
||||
inventory["_meta"]["hostvars"][fqdn] = {
|
||||
inventory["_meta"]["hostvars"][inventory_name] = {
|
||||
"ansible_host": fqdn, # Connect using FQDN
|
||||
"fqdn": fqdn,
|
||||
"tier": tier,
|
||||
"role": role,
|
||||
"short_hostname": hostname,
|
||||
}
|
||||
|
||||
# Group by tier
|
||||
tier_group = f"tier_{sanitize_group_name(tier)}"
|
||||
if tier_group not in tier_groups:
|
||||
tier_groups[tier_group] = []
|
||||
tier_groups[tier_group].append(fqdn)
|
||||
tier_groups[tier_group].append(inventory_name)
|
||||
|
||||
# Group by role (if set)
|
||||
if role:
|
||||
role_group = f"role_{sanitize_group_name(role)}"
|
||||
if role_group not in role_groups:
|
||||
role_groups[role_group] = []
|
||||
role_groups[role_group].append(fqdn)
|
||||
role_groups[role_group].append(inventory_name)
|
||||
|
||||
# Add tier groups to inventory
|
||||
for group_name, hosts in tier_groups.items():
|
||||
|
||||
Reference in New Issue
Block a user