From 1ca680a0b15075dd72890f32c51f46cb4df3ea96 Mon Sep 17 00:00:00 2001
From: Martin van Es <martin@mrvanes.com>
Date: Tue, 15 Mar 2022 15:44:42 +0100
Subject: [PATCH] Move ansible user and key to inventory configuration and make
 use of aliases for easier config

---
 ansible.cfg                  |  3 +--
 inventory/group_vars/all.yml |  8 ++++----
 inventory/inventory          | 29 ++++++++++++++++++++---------
 3 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/ansible.cfg b/ansible.cfg
index c478a02..d2ebe93 100644
--- a/ansible.cfg
+++ b/ansible.cfg
@@ -1,10 +1,9 @@
 [defaults]
 gathering = smart
-remote_user = ansible
 
 [privilege_escalation]
 become = True
 
 [ssh_connection]
 pipelining = True
-ssh_args = -o ControlMaster=auto -o ControlPersist=3600s -o StrictHostKeyChecking=false -i .ssh/id_ansible
+ssh_args = -o ControlMaster=auto -o ControlPersist=3600s -o StrictHostKeyChecking=false
diff --git a/inventory/group_vars/all.yml b/inventory/group_vars/all.yml
index 0324e04..d379a43 100644
--- a/inventory/group_vars/all.yml
+++ b/inventory/group_vars/all.yml
@@ -3,7 +3,7 @@
 tld: srv.mdx.incubator.geant.org
 
 hosts:
-  et2.gndev.hexaa.eu:
+  et2:
     hostname: srv1
     altname: 'server-md2.et2.com'
 
@@ -20,7 +20,7 @@ hosts:
         signer: 'http://srv2-signer.srv.mdx.incubator.geant.org'
         altname: 'edugain-md.et2.com'
 
-  mdxcdn.pt-38.utr.surfcloud.nl:
+  mdxcdn:
     hostname: srv2
     altname: 'server-md2.et2.com'
 
@@ -36,7 +36,7 @@ hosts:
       edugain:
         signer: 'http://localhost:5001'
 
-  62.217.72.109:
+  okeanos:
     hostname: srv3
 
     mdproxy:
@@ -46,7 +46,7 @@ hosts:
       edugain:
         signer: 'http://srv2-signer.srv.mdx.incubator.geant.org'
 
-  alternative-mdx.pt-76.utr.surfcloud.nl:
+  alternative-mdx:
     hostname: srv4
     altname: 'server-md.example.com'
 
diff --git a/inventory/inventory b/inventory/inventory
index 90ffe36..cbe5ab9 100644
--- a/inventory/inventory
+++ b/inventory/inventory
@@ -1,18 +1,29 @@
+# Inventory Aliases
+# Make sure to change group_vars/all.yml for the same hosts keys
+et2             ansible_host=et2.gndev.hexaa.eu ansible_user=ansible ansible_ssh_private_key_file=.ssh/id_ansible
+mdxcdn          ansible_host=mdxcdn.pt-38.utr.surfcloud.nl ansible_user=ansible ansible_ssh_private_key_file=.ssh/id_ansible
+alternative-mdx ansible_host=alternative-mdx.pt-76.utr.surfcloud.nl ansible_user=ansible ansible_ssh_private_key_file=.ssh/id_ansible
+okeanos         ansible_host=62.217.72.109 ansible_user=ansible ansible_ssh_private_key_file=.ssh/id_ansible
+
+# Hosts that receive the mdserver role
 [mdserver]
-et2.gndev.hexaa.eu
-mdxcdn.pt-38.utr.surfcloud.nl
-alternative-mdx.pt-76.utr.surfcloud.nl
+et2
+mdxcdn
+alternative-mdx
 
+# Hosts that receive the mdproxy role
 [mdproxy]
-et2.gndev.hexaa.eu
-mdxcdn.pt-38.utr.surfcloud.nl
-alternative-mdx.pt-76.utr.surfcloud.nl
-62.217.72.109
+et2
+mdxcdn
+alternative-mdx
+okeanos
 
+# Hosts that receive the GeoDNS role
 [geodns]
-et2.gndev.hexaa.eu
-mdxcdn.pt-38.utr.surfcloud.nl
+et2
+mdxcdn
 
+# All hosts for base role
 [all:children]
 mdserver
 mdproxy
-- 
GitLab