From 1e6e05c5afdc552c95833211db4e9e05ab3a32ef Mon Sep 17 00:00:00 2001
From: handreas <andreas.hamacher@monash.edu>
Date: Tue, 11 Feb 2020 22:56:25 +0000
Subject: [PATCH] refactoring out consistency0 as a variable called reposerver

---
 CICD/vars/vars.yml                            | 2 ++
 roles/calculateEtcHosts/tasks/main.yml        | 2 +-
 roles/calculateEtcHosts/templates/etcHosts.j2 | 2 +-
 roles/config_repos/tasks/main.yml             | 8 ++++----
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/CICD/vars/vars.yml b/CICD/vars/vars.yml
index d1dc95cf..4af25b68 100644
--- a/CICD/vars/vars.yml
+++ b/CICD/vars/vars.yml
@@ -2,6 +2,8 @@
 sudo_group: systems
 nagios_home: "/var/lib/nagios"
 nvidia_version: "390.46"
+reposervername: consistency0
+reposerverip: 118.138.244.7
 
 gpumap:
  'K1': 'K1'
diff --git a/roles/calculateEtcHosts/tasks/main.yml b/roles/calculateEtcHosts/tasks/main.yml
index ff71a956..1d1c6170 100644
--- a/roles/calculateEtcHosts/tasks/main.yml
+++ b/roles/calculateEtcHosts/tasks/main.yml
@@ -8,7 +8,7 @@
 - name: make hosts data
   command: /tmp/makehosts.py /tmp/groups {{ domain }}
   register: hosts_data
-               
+
 - name: write hosts file
   template: dest=/tmp/etcHosts src=etcHosts.j2
 
diff --git a/roles/calculateEtcHosts/templates/etcHosts.j2 b/roles/calculateEtcHosts/templates/etcHosts.j2
index 590826fe..df9a12d0 100644
--- a/roles/calculateEtcHosts/templates/etcHosts.j2
+++ b/roles/calculateEtcHosts/templates/etcHosts.j2
@@ -5,7 +5,7 @@ ff00::0 ip6-mcastprefix
 ff02::1 ip6-allnodes
 ff02::2 ip6-allrouters
 118.138.241.196 hpcldap0.erc.monash.edu.au
-118.138.244.7 consistency0
+{{ reposerverip }} {{ reposervername }}
 
 {% for item in hosts_data.stdout_lines %}
 {{ item }}
diff --git a/roles/config_repos/tasks/main.yml b/roles/config_repos/tasks/main.yml
index 02bc8977..cfb9fec7 100644
--- a/roles/config_repos/tasks/main.yml
+++ b/roles/config_repos/tasks/main.yml
@@ -1,9 +1,9 @@
 ---
 
 - name: make sure out repo server is resolvable
-  lineinfile: 
-    dest: /etc/hosts 
-    line: "118.138.244.7 consistency0"
+  lineinfile:
+    dest: /etc/hosts
+    line: "{{ reposerverip }} {{ reposervername }}"  #this is duplicated in the role calculateEtcHosts
     owner: root
     group: root
 
@@ -51,7 +51,7 @@
 
 - name: disable unwanted repos
   shell: yum-config-manager --disable "{{ item }}"
-  with_items: "{{repolist.stdout_lines|difference(yumenablerepo)}}"
+  with_items: "{{ repolist.stdout_lines|difference(yumenablerepo) }}"
   become: true
   become_user: root
   ignore_errors: true
-- 
GitLab