Skip to content

Commit

Permalink
Merge pull request #71 from srobo/clatd
Browse files Browse the repository at this point in the history
Add role to install clatd
  • Loading branch information
RealOrangeOne authored Sep 5, 2024
2 parents 9313522 + 869a2d0 commit d143393
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 0 deletions.
3 changes: 3 additions & 0 deletions host_vars/competitorsvcs.studentrobotics.org.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
roles:
- competitor-services-nginx
- code-submitter
- clatd
- discord-bot

- name: Kit services
Expand Down
7 changes: 7 additions & 0 deletions roles/clatd/README.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions roles/clatd/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- name: Restart clatd
service:
name: clatd
state: restarted
49 changes: 49 additions & 0 deletions roles/clatd/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions roles/clatd/templates/clatd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% if clat_v6_addr is defined %}
clat-v6-addr={{ clat_v6_addr }}
{% endif %}
2 changes: 2 additions & 0 deletions roles/clatd/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
install_dir: /opt/clatd
installed_version_file: /opt/clatd.version

0 comments on commit d143393

Please sign in to comment.