From 9aeadbe40350e551c524943c24bd7994af58f381 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 15 Jan 2023 18:27:35 +0100 Subject: Simplify variable use, add fact support --- personal_infra/puppet/site/00-common.pp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'personal_infra/puppet/site') diff --git a/personal_infra/puppet/site/00-common.pp b/personal_infra/puppet/site/00-common.pp index c5023081..b542eb9e 100644 --- a/personal_infra/puppet/site/00-common.pp +++ b/personal_infra/puppet/site/00-common.pp @@ -1,28 +1,28 @@ include automatic_updates -$tinc_hosts = lookup("'$ansible_inventory_hostname'.groups.tinc") -$tinc_other_hosts = $tinc_hosts.filter |$host_name| { $host_name != $ansible_inventory_hostname } +$tinc_hosts = lookup("groups.tinc") +$tinc_other_hosts = $tinc_hosts.filter |$host_name| { $host_name != $facts["networking"]["fqdn"] } $tinc_locations = Hash($tinc_hosts.map |$host_name| { [ - lookup("'$host_name'.network.tinc.location"), + lookup("hostvars.'$host_name'.network.tinc.location"), { - subnet => lookup("'$host_name'.network.self_internal_network"), - address => lookup("'$host_name'.network.public_hostname"), + subnet => lookup("hostvars.'$host_name'.network.self_internal_network"), + address => lookup("hostvars.'$host_name'.network.public_hostname"), } ] }) -$tinc_connect_to = $tinc_other_hosts.map |$host_name| { lookup("'$host_name'.network.tinc.location") } +$tinc_connect_to = $tinc_other_hosts.map |$host_name| { lookup("hostvars.'$host_name'.network.tinc.location") } -$tinc_other_networks = $tinc_other_hosts.map |$host_name| { lookup("'$host_name'.network.self_internal_network") } +$tinc_other_networks = $tinc_other_hosts.map |$host_name| { lookup("hostvars.'$host_name'.network.self_internal_network") } -if 'tinc' in lookup("'$ansible_inventory_hostname'.group_names") { +if 'tinc' in lookup("group_names") { class {'tinc': - tinc_name => lookup("'$ansible_inventory_hostname'.tinc_global.name"), - tinc_location => lookup("'$ansible_inventory_hostname'.network.tinc.location"), + tinc_name => lookup("tinc_global.name"), + tinc_location => lookup("network.tinc.location"), tinc_connect_to => $tinc_connect_to, tinc_locations => $tinc_locations, - tinc_ip => lookup("'$ansible_inventory_hostname'.network.self_internal_ip"), - tinc_netmask => lookup("'$ansible_inventory_hostname'.network.self_internal_netmask"), + tinc_ip => lookup("network.self_internal_ip"), + tinc_netmask => lookup("network.self_internal_netmask"), tinc_other_networks => $tinc_other_networks, } } -- cgit v1.2.3