diff --git a/host_vars/competitorsvcs.studentrobotics.org.yml b/host_vars/competitorsvcs.studentrobotics.org.yml index e586f5a..adc169e 100644 --- a/host_vars/competitorsvcs.studentrobotics.org.yml +++ b/host_vars/competitorsvcs.studentrobotics.org.yml @@ -11,3 +11,6 @@ add_hsts_header: true certbot_certs: - domains: - "{{ canonical_hostname }}" + +# Mythic have additionally routed this IP to the VM +clat_v6_addr: 2a00:1098:80:bc::2 diff --git a/playbook.yml b/playbook.yml index 5f68400..eb3977d 100644 --- a/playbook.yml +++ b/playbook.yml @@ -20,6 +20,7 @@ roles: - competitor-services-nginx - code-submitter + - clatd - discord-bot - name: Kit services diff --git a/roles/clatd/README.md b/roles/clatd/README.md new file mode 100644 index 0000000..00e7f8c --- /dev/null +++ b/roles/clatd/README.md @@ -0,0 +1,7 @@ +# [`clatd`](https://github.com/toreanderson/clatd) + +A CLAT / SIIT-DC Edge Relay implementation for Linux. + +Used to provide IPv4 outbound connectivity to an IPv6-only VM. + +It's likely `clat-v6-addr` will need to be configured to assign the correct IP to the created `clat` interface. This may require an additional IPv6 address be routed to the VM. diff --git a/roles/clatd/handlers/main.yml b/roles/clatd/handlers/main.yml new file mode 100644 index 0000000..27fdca0 --- /dev/null +++ b/roles/clatd/handlers/main.yml @@ -0,0 +1,4 @@ +- name: Restart clatd + service: + name: clatd + state: restarted diff --git a/roles/clatd/tasks/main.yml b/roles/clatd/tasks/main.yml new file mode 100644 index 0000000..cbec919 --- /dev/null +++ b/roles/clatd/tasks/main.yml @@ -0,0 +1,49 @@ +- name: Download + git: + repo: https://github.com/toreanderson/clatd + dest: "{{ install_dir }}" + force: true + version: 3ea303b5210bf701df30323933c86f9ffe4d3dd4 + register: clatd_repo + notify: Restart clatd + +- name: Get installed version (if installed) + slurp: + src: "{{ installed_version_file }}" + ignore_errors: true # Ignore if the file is missing, since it's about to be created + register: installed_version_slurp + +- name: Resolve installed version + set_fact: + installed_version: "{{ installed_version_slurp.content | b64decode }}" + when: not installed_version_slurp.failed + +- name: Install + community.general.make: + chdir: "{{ install_dir }}" + targets: + - installdeps # Install system dependencies + - install # Install clatd + when: installed_version is not defined or clatd_repo.after not in installed_version # noqa: no-handler - Use a handler to ensure execution order + notify: Restart clatd + register: install_clatd + +- name: Update installed version + copy: + content: "{{ clatd_repo.after }}" + dest: "{{ installed_version_file }}" + mode: "0644" + when: install_clatd.changed # noqa: no-handler - Use a handler to ensure execution order + +- name: Install configuration + template: + src: clatd.conf + dest: /etc/clatd.conf + mode: "0644" + notify: Restart clatd + +- name: Enable service + service: + name: clatd + state: started + enabled: true diff --git a/roles/clatd/templates/clatd.conf b/roles/clatd/templates/clatd.conf new file mode 100644 index 0000000..b36510d --- /dev/null +++ b/roles/clatd/templates/clatd.conf @@ -0,0 +1,3 @@ +{% if clat_v6_addr is defined %} +clat-v6-addr={{ clat_v6_addr }} +{% endif %} diff --git a/roles/clatd/vars/main.yml b/roles/clatd/vars/main.yml new file mode 100644 index 0000000..9993952 --- /dev/null +++ b/roles/clatd/vars/main.yml @@ -0,0 +1,2 @@ +install_dir: /opt/clatd +installed_version_file: /opt/clatd.version