diff --git a/inventory/local b/inventory/local
index ff50ec0c279ec40478280255f7f0e0fd505ef45a..d33c048c4f9d912bb9edac3589a81fa7a4bd285a 100644
--- a/inventory/local
+++ b/inventory/local
@@ -6,6 +6,7 @@ local ansible_connection=local
# Hosts that receive the mdproxy role
[mdproxy]
+local
# Hosts that receive the GeoDNS role
[geodns]
diff --git a/playbook.yml b/playbook.yml
index f89049221b0d3a9fddc8cc04308004fde36927c9..fa49cdb39e4f8b42d4fd540b6944c1f4067028bc 100644
--- a/playbook.yml
+++ b/playbook.yml
@@ -8,6 +8,7 @@
hosts: geodns
gather_facts: false
roles:
+ - {role: local, tags: ['local']}
- {role: geodns, tags: ['geodns']}
- name: MDSigner
@@ -21,5 +22,6 @@
hosts: mdproxy
gather_facts: false
roles:
+ - {role: local, tags: ['local']}
- {role: apache, tags: ['apache']}
- {role: mdproxy, tags: ['mdproxy']}
diff --git a/roles/geodns/defaults/main.yml b/roles/geodns/defaults/main.yml
index 291d8ef061e09e302d734e61d47e2f713e207c16..18ad3dd6cc5f62101d0c1a2dd35bcff3619117d2 100644
--- a/roles/geodns/defaults/main.yml
+++ b/roles/geodns/defaults/main.yml
@@ -8,7 +8,3 @@ geodns_version: v3.2.0
geodns_config: "{{ geodns_dir}}/config"
geolite_dir: "{{ geodns_dir }}/GeoLite2DB"
-
-mdxsaas_repo: https://gitlab.geant.org/TI_Incubator/mdx-saas-config.git
-mdxsaas_dir: /opt/mdx-saas
-mdxsaas_version: main
diff --git a/roles/geodns/tasks/main.yml b/roles/geodns/tasks/main.yml
index 83b8b9f9c99175f165bd9b95d1ba0158d0800695..6e09285afa2ed05b1fea4370faaad9de9323f17f 100644
--- a/roles/geodns/tasks/main.yml
+++ b/roles/geodns/tasks/main.yml
@@ -3,7 +3,6 @@
apt:
state: present
name:
- - ansible
- netcat-openbsd
- name: Install Ansible community.general
@@ -101,15 +100,3 @@
- geodns-update.timer
notify:
- "enable geodns job"
-
-- name: Clone MDX-SAAS-config repository
- ansible.builtin.git:
- repo: "{{ mdxsaas_repo }}"
- dest: "{{ mdxsaas_dir }}"
- version: "{{ mdxsaas_version }}"
- register: mdxsaas_git
-
-- name: Write MDX-SAAS repo version
- ansible.builtin.shell:
- cmd: "git rev-parse HEAD > {{ geodns_config }}/revision"
- chdir: "{{ mdxsaas_dir }}"
diff --git a/roles/geodns/templates/geodns-update.service.j2 b/roles/geodns/templates/geodns-update.service.j2
index 17b702cf2daac8a8502b85c56410116cb0c9ac2d..b548274b40ce065c9bb0207ca78f45358f213757 100644
--- a/roles/geodns/templates/geodns-update.service.j2
+++ b/roles/geodns/templates/geodns-update.service.j2
@@ -5,7 +5,7 @@ Description=GeoDNS update
Type=oneshot
WorkingDirectory={{ mdxsaas_dir }}
ExecStart=git pull
-ExecStart=ansible-playbook playbook.yml -i inventory/local --tags geodns --limit local
+ExecStart=ansible-playbook playbook.yml -i inventory/local --tags local,geodns --limit local
ExecStartPost=/bin/systemctl restart geodns
[Install]
diff --git a/roles/geodns/templates/geodns-update.timer.j2 b/roles/geodns/templates/geodns-update.timer.j2
index 0a4e475fd37b1b243d872e8c2b86fa0083709bd7..0241baefe95b82eb0ecb99f096996201c7b6ae8c 100644
--- a/roles/geodns/templates/geodns-update.timer.j2
+++ b/roles/geodns/templates/geodns-update.timer.j2
@@ -2,7 +2,7 @@
Description=Run GeoDNS update
[Timer]
-OnCalendar=*-*-* *:0/5:00
+OnCalendar=*-*-* *:02:00
Unit=geodns-update.service
[Install]
diff --git a/roles/local/defaults/main.yml b/roles/local/defaults/main.yml
new file mode 100644
index 0000000000000000000000000000000000000000..8b71038d5e3be83375b23fe73e75a38f8699ba7b
--- /dev/null
+++ b/roles/local/defaults/main.yml
@@ -0,0 +1,5 @@
+---
+
+mdxsaas_repo: https://gitlab.geant.org/TI_Incubator/mdx-saas-config.git
+mdxsaas_dir: /opt/mdx-saas
+mdxsaas_version: main
diff --git a/roles/local/tasks/main.yml b/roles/local/tasks/main.yml
new file mode 100644
index 0000000000000000000000000000000000000000..5791679057b8861ad02c13f04142e620f52471da
--- /dev/null
+++ b/roles/local/tasks/main.yml
@@ -0,0 +1,18 @@
+---
+- name: Install packages
+ apt:
+ state: present
+ name:
+ - ansible
+
+- name: Clone MDX-SAAS-config repository
+ ansible.builtin.git:
+ repo: "{{ mdxsaas_repo }}"
+ dest: "{{ mdxsaas_dir }}"
+ version: "{{ mdxsaas_version }}"
+ register: mdxsaas_git
+
+- name: Write MDX-SAAS repo version
+ ansible.builtin.shell:
+ cmd: "git rev-parse HEAD > {{ geodns_config }}/revision"
+ chdir: "{{ mdxsaas_dir }}"
diff --git a/roles/mdproxy/tasks/main.yml b/roles/mdproxy/tasks/main.yml
index 92fd204b78f68ca7da6facce440b8b826078d03a..fa1e33c4f9ad4743f89bb99c857ed5a21d4ce4ad 100644
--- a/roles/mdproxy/tasks/main.yml
+++ b/roles/mdproxy/tasks/main.yml
@@ -13,7 +13,11 @@
- name: Copy mdproxy service files
ansible.builtin.template:
- src: "mdproxy.service.j2"
- dest: "/etc/systemd/system/mdproxy.service"
+ src: "{{ item }}.j2"
+ dest: "/etc/systemd/system/{{ item }}"
+ with_items:
+ - mdproxy.service
+ - mdproxy-update.service
+ - mdproxy-update.timer
notify:
- "enable mdproxy job"
diff --git a/roles/mdproxy/templates/mdproxy-update.service.j2 b/roles/mdproxy/templates/mdproxy-update.service.j2
new file mode 100644
index 0000000000000000000000000000000000000000..bcdce656326ee9cee7aaf0e57074a25e650ea7d8
--- /dev/null
+++ b/roles/mdproxy/templates/mdproxy-update.service.j2
@@ -0,0 +1,12 @@
+[Unit]
+Description=mdproxy update
+
+[Service]
+Type=oneshot
+WorkingDirectory={{ mdxsaas_dir }}
+ExecStart=git pull
+ExecStart=ansible-playbook playbook.yml -i inventory/local --tags local,mdproxy --limit local
+ExecStartPost=/bin/systemctl restart mdproxy
+
+[Install]
+WantedBy=multi-user.target
diff --git a/roles/mdproxy/templates/mdproxy-update.timer.j2 b/roles/mdproxy/templates/mdproxy-update.timer.j2
new file mode 100644
index 0000000000000000000000000000000000000000..9806d2c10f5cce5a51a21ad07af821a3b8a306d3
--- /dev/null
+++ b/roles/mdproxy/templates/mdproxy-update.timer.j2
@@ -0,0 +1,9 @@
+[Unit]
+Description=Run mdproxy update
+
+[Timer]
+OnCalendar=*-*-* *:04:00
+Unit=mdproxy-update.service
+
+[Install]
+WantedBy=timers.target