Commit 0de5dc23 authored by Martin van Es's avatar Martin van Es
Browse files

WIP

parent d083febb
#!/bin/sh
#ansible-galaxy collection install community.general
ansible-playbook playbook.yml -i inventory/inventory $@
# Inventory Aliases
local ansible_connection=local
# 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
......@@ -20,6 +22,7 @@ okeanos
# Hosts that receive the GeoDNS role
[geodns]
local
et2
mdxcdn
......
......@@ -4,7 +4,11 @@ go_link: https://go.dev/dl/go1.16.13.linux-amd64.tar.gz
geodns_repo: https://github.com/abh/geodns.git
geodns_dir: /opt/geodns
geo_dns_version: v3.2.0
geo_dns_config: "{{ geodns_dir}}/config"
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
......@@ -9,3 +9,5 @@
- geodns.service
- geodns-config.service
- geodns-config.timer
- geodns-update.service
- geodns-update.timer
---
- name: Install packages
apt:
state: present
name:
- ansible
- netcat-openbsd
- name: Check if go binary exists
stat:
......@@ -16,7 +22,7 @@
ansible.builtin.git:
repo: "{{ geodns_repo }}"
dest: "{{ geodns_dir }}"
version: "{{ geo_dns_version }}"
version: "{{ geodns_version }}"
register: geodns_git
- name: Check if geodns binary exists
......@@ -38,13 +44,13 @@
state: directory
mode: '0755'
with_items:
- "{{ geo_dns_config }}"
- "{{ geodns_config }}"
- "{{ geolite_dir }}"
- name: Copy geoDNS config
ansible.builtin.copy:
src: "{{ tld }}.yaml"
dest: "{{ geo_dns_config }}/{{ tld }}.yaml"
dest: "{{ geodns_config }}/{{ tld }}.yaml"
mode: '0644'
notify:
- "enable geodns job"
......@@ -52,7 +58,7 @@
- name: Copy geoDNS config parser
ansible.builtin.copy:
src: "geoconfig.py"
dest: "{{ geo_dns_config }}/geoconfig.py"
dest: "{{ geodns_config }}/geoconfig.py"
mode: '0755'
notify:
- "enable geodns job"
......@@ -70,14 +76,14 @@
- name: Create geoDNS config
ansible.builtin.template:
src: "geodns.conf.j2"
dest: "{{ geo_dns_config }}/geodns.conf"
dest: "{{ geodns_config }}/geodns.conf"
notify:
- "enable geodns job"
- name: Run GeoDns config job once
ansible.builtin.command:
cmd: "/opt/geodns/config/geoconfig.py {{ tld }}"
chdir: "{{ geo_dns_config }}"
chdir: "{{ geodns_config }}"
- name: Copy geoDNS service files
ansible.builtin.template:
......@@ -87,5 +93,16 @@
- geodns.service
- geodns-config.service
- geodns-config.timer
- geodns-update.service
- 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
......@@ -3,8 +3,8 @@ Description=GeoDNS config
[Service]
Type=oneshot
WorkingDirectory={{ geo_dns_config }}
ExecStart={{ geo_dns_config }}/geoconfig.py {{ tld }}
WorkingDirectory={{ geodns_config }}
ExecStart={{ geodns_config }}/geoconfig.py {{ tld }}
ExecStartPost=/bin/systemctl restart geodns
[Install]
......
[Unit]
Description=GeoDNS config
[Service]
Type=oneshot
WorkingDirectory={{ mdxsaas_dir }}
ExecStart=git pull
ExecStart={{ mdxsaas_dir }}/deploy.sh --tags geodns --limit local
ExecStartPost=/bin/systemctl restart geodns
[Install]
WantedBy=multi-user.target
[Unit]
Description=Run GeoDNS update
[Timer]
OnCalendar=*-*-* *:0/5:00
Unit=geodns-update.service
[Install]
WantedBy=timers.target
......@@ -5,7 +5,7 @@ After=syslog.target network.target
[Service]
Type=simple
WorkingDirectory={{ geodns_dir }}
ExecStart={{ geodns_dir }}/geodns -config={{ geo_dns_config }} -log -interface {{ ansible_facts.default_ipv4.address }} -port 53
ExecStart={{ geodns_dir }}/geodns -config={{ geodns_config }} -log -interface {{ ansible_facts.default_ipv4.address }} -port 53
# ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=10
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment