ansible: first proposl for nicer inventory names
authorChristian Pointner <equinox@realraum.at>
Sun, 22 Apr 2018 11:59:37 +0000 (13:59 +0200)
committerChristian Pointner <equinox@realraum.at>
Sun, 22 Apr 2018 11:59:37 +0000 (13:59 +0200)
ansible/hosts.ini
ansible/roles/localconfig/templates/ssh/10r3.conf.j2

index b618973..a741934 100644 (file)
@@ -3,23 +3,38 @@ host_domain=realraum.at
 ansible_host={{ inventory_hostname }}.{{ host_domain }}
 ansible_user=root
 
+[net-zone-mgmt]
+#torwaechter
+alfred
+calendar
+galley
+hacksch
+## TODO: remove the variable once https://github.com/ansible/ansible/issues/39119 is fixed
+metrics localconfig_ssh_config_user=root
+r3home
+tickets
+
+[net-zone-mgmt:vars]
+host_domain=mgmt.realraum.at
+
+##########################
+
 [baremetalservers]
-alfred.mgmt
+alfred
 
 [kvmhosts]
-alfred.mgmt
+alfred
 
 [virtualservers]
 athsdisc
-calendar.mgmt
+calendar
 ctf
 entrance
-galley.mgmt
-hacksch.mgmt
-## TODO: remove the variable once https://github.com/ansible/ansible/issues/39119 is fixed
-metrics.mgmt localconfig_ssh_config_user=root
-r3home.mgmt
-tickets.mgmt
+galley
+hacksch
+metrics
+r3home
+tickets
 vex
 
 [servers:children]
@@ -33,7 +48,7 @@ wuerfel
 
 #[alix]
 #gw
-#torwaechter.mgmt
+#torwaechter
 
 #[apu]
 #gnocchi1
index ba11160..dd33944 100644 (file)
@@ -2,12 +2,11 @@
 # realraum ssh-config (generated by ansible NOC repo)
 
 #######################################
-### dynamically generated hosts
+### dynamically generated host configs
 
 {% for host in (groups['all'] | sort) %}
-{% set shortname = (host.split('.') | first) %}
-Host {{ host }}.realraum.at r3-{{ shortname }} r3g-{{ shortname }} r3e-{{ shortname }}
-    Hostname {{ host }}.realraum.at
+Host {{ hostvars[host].ansible_host }} r3-{{ host }} r3g-{{ host }} r3e-{{ host }}
+    Hostname {{ hostvars[host].ansible_host }}
 {% if 'localconfig_ssh_config_proxycommand' in hostvars[host] %}
     ProxyCommand {{ hostvars[host].localconfig_ssh_config_proxycommand }}
 {% endif %}