From 7cd62269a31a5f4b944fd7ce8cc47de80fcc91c4 Mon Sep 17 00:00:00 2001
From: shirenn <shirenn@crans.org>
Date: Mon, 8 Feb 2021 15:01:23 +0100
Subject: [PATCH] pepcrans :)

---
 group_vars/linx.yml                      | 4 ++++
 host_vars/linx.adm.crans.org.yml         | 3 +++
 hosts                                    | 3 +++
 plays/linx.yml                           | 6 ++----
 roles/linx/templates/linx/server.conf.j2 | 2 +-
 5 files changed, 13 insertions(+), 5 deletions(-)
 create mode 100644 group_vars/linx.yml
 create mode 100644 host_vars/linx.adm.crans.org.yml

diff --git a/group_vars/linx.yml b/group_vars/linx.yml
new file mode 100644
index 00000000..4523854c
--- /dev/null
+++ b/group_vars/linx.yml
@@ -0,0 +1,4 @@
+---
+glob_linx:
+  siteurl: "https://linx.crans.org/"
+  name: "CRANS Linx"
diff --git a/host_vars/linx.adm.crans.org.yml b/host_vars/linx.adm.crans.org.yml
new file mode 100644
index 00000000..9f8e71f2
--- /dev/null
+++ b/host_vars/linx.adm.crans.org.yml
@@ -0,0 +1,3 @@
+---
+loc_linx:
+  ip: "{{ query('ldap', 'ip', 'linx', 'adm') | first }}"
diff --git a/hosts b/hosts
index cb195e01..a31b5959 100644
--- a/hosts
+++ b/hosts
@@ -67,6 +67,9 @@ sam.adm.crans.org
 daniel.adm.crans.org
 jack.adm.crans.org
 
+[linx]
+linx.adm.crans.org
+
 [monitoring]
 monitoring.adm.crans.org
 
diff --git a/plays/linx.yml b/plays/linx.yml
index 80c29864..6ef26cf1 100755
--- a/plays/linx.yml
+++ b/plays/linx.yml
@@ -1,9 +1,7 @@
 #!/usr/bin/env ansible-playbook
 ---
-- hosts: linx.adm.crans.org
+- hosts: linx
   vars:
-    linx:
-      ip: "{{ query('ldap', 'ip', 'linx', 'adm') }}"
-      siteurl: "https://linx.crans.org/"
+    linx: "{{ glob_linx | default({}) | combine(loc_linx | default({})) }}"
   roles:
     - linx
diff --git a/roles/linx/templates/linx/server.conf.j2 b/roles/linx/templates/linx/server.conf.j2
index 25af772c..984f37f1 100644
--- a/roles/linx/templates/linx/server.conf.j2
+++ b/roles/linx/templates/linx/server.conf.j2
@@ -1,7 +1,7 @@
 {{ ansible_header | comment }}
 
 bind = {{ linx.ip }}:8080
-sitename = CRANS Linx
+sitename = {{ linx.name }}
 siteurl = {{ linx.siteurl }}
 maxsize = 10000000
 maxexpiry = 604800
-- 
GitLab