move to project lifecycle structure
This commit is contained in:
14
systemd/graduated/ddns/README.md
Normal file
14
systemd/graduated/ddns/README.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# DDNS Service
|
||||
|
||||
Since we occasionally need an ipv4 address we'll make one.
|
||||
|
||||
This creates and keeps updated `ipv4.reeselink.com`.
|
||||
|
||||
This requires the aws cli to be installed on each node with credentials that can modify
|
||||
records in route53.
|
||||
|
||||
<https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html>
|
||||
|
||||
```bash
|
||||
ansible-playbook -i ansible/inventory.yaml ddns/install_ddns.yaml
|
||||
```
|
||||
5
systemd/graduated/ddns/ddns.service
Normal file
5
systemd/graduated/ddns/ddns.service
Normal file
@@ -0,0 +1,5 @@
|
||||
[Unit]
|
||||
Description=Updates the IPv4 records with the current public IPV4 address
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/scripts/ddns.sh
|
||||
20
systemd/graduated/ddns/ddns.sh
Executable file
20
systemd/graduated/ddns/ddns.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get public IP address (there are many ways to do it, I picked this way)
|
||||
PUBLIC_IP=$(curl -4 ifconfig.me)
|
||||
|
||||
# Update reeselink records
|
||||
cat /etc/ddns/reeselink_record_template.json \
|
||||
| jq '.Changes[0].ResourceRecordSet.ResourceRecords[0].Value = "'$PUBLIC_IP'"' \
|
||||
> /etc/ddns/reeselink_record.json
|
||||
|
||||
# Update reeseapps records
|
||||
cat /etc/ddns/reeseapps_record_template.json \
|
||||
| jq '.Changes[].ResourceRecordSet.ResourceRecords[0].Value = "'$PUBLIC_IP'"' \
|
||||
> /etc/ddns/reeseapps_record.json
|
||||
|
||||
# Update reeselink records
|
||||
aws route53 change-resource-record-sets --hosted-zone-id Z0092652G7L97DSINN18 --change-batch file:///etc/ddns/reeselink_record.json
|
||||
|
||||
# Update reeseapps records
|
||||
aws route53 change-resource-record-sets --hosted-zone-id Z012820733346FJ0U4FUF --change-batch file:///etc/ddns/reeseapps_record.json
|
||||
11
systemd/graduated/ddns/ddns.timer
Normal file
11
systemd/graduated/ddns/ddns.timer
Normal file
@@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=Run ddns service every hour
|
||||
|
||||
[Timer]
|
||||
OnCalendar=hourly
|
||||
AccuracySec=10min
|
||||
Persistent=true
|
||||
Unit=ddns.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
63
systemd/graduated/ddns/install_ddns.yaml
Normal file
63
systemd/graduated/ddns/install_ddns.yaml
Normal file
@@ -0,0 +1,63 @@
|
||||
- name: Update nginx stream configuration
|
||||
hosts: yellow
|
||||
vars_files:
|
||||
- vars.yaml
|
||||
tasks:
|
||||
- name: Ensure moreutils, jq is installed
|
||||
ansible.builtin.dnf:
|
||||
name:
|
||||
- moreutils
|
||||
- jq
|
||||
state: present
|
||||
- name: Create /usr/local/scripts dir
|
||||
ansible.builtin.file:
|
||||
path: /usr/local/scripts
|
||||
state: directory
|
||||
mode: '0755'
|
||||
- name: Copy ddns.sh
|
||||
template:
|
||||
src: ddns.sh
|
||||
dest: /usr/local/scripts/ddns.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
- name: Create /etc/ddns dir
|
||||
ansible.builtin.file:
|
||||
path: /etc/ddns
|
||||
state: directory
|
||||
mode: '0755'
|
||||
- name: Copy reeseapps_record_template.json
|
||||
template:
|
||||
src: reeseapps_record_template.json
|
||||
dest: /etc/ddns/reeseapps_record_template.json
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
- name: Copy reeselink_record_template.json
|
||||
template:
|
||||
src: reeselink_record_template.json
|
||||
dest: /etc/ddns/reeselink_record_template.json
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
- name: Copy ddns.service
|
||||
template:
|
||||
src: ddns.service
|
||||
dest: /etc/systemd/system/ddns.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
- name: Copy ddns.timer
|
||||
template:
|
||||
src: ddns.timer
|
||||
dest: /etc/systemd/system/ddns.timer
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
- name: Run ddns script
|
||||
ansible.builtin.shell: /usr/local/scripts/ddns.sh
|
||||
- name: Reload ddns timer
|
||||
ansible.builtin.systemd_service:
|
||||
state: restarted
|
||||
name: ddns.timer
|
||||
enabled: true
|
||||
96
systemd/graduated/ddns/reeseapps_record_template.json
Normal file
96
systemd/graduated/ddns/reeseapps_record_template.json
Normal file
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"Comment": "Update Public IPV4 Address",
|
||||
"Changes": [
|
||||
{
|
||||
"Action": "UPSERT",
|
||||
"ResourceRecordSet": {
|
||||
"Name": "homeassistant.reeseapps.com",
|
||||
"Type": "A",
|
||||
"TTL": 300,
|
||||
"ResourceRecords": [
|
||||
{
|
||||
"Value": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"Action": "UPSERT",
|
||||
"ResourceRecordSet": {
|
||||
"Name": "nextcloud.reeseapps.com",
|
||||
"Type": "A",
|
||||
"TTL": 300,
|
||||
"ResourceRecords": [
|
||||
{
|
||||
"Value": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"Action": "UPSERT",
|
||||
"ResourceRecordSet": {
|
||||
"Name": "gitea.reeseapps.com",
|
||||
"Type": "A",
|
||||
"TTL": 300,
|
||||
"ResourceRecords": [
|
||||
{
|
||||
"Value": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"Action": "UPSERT",
|
||||
"ResourceRecordSet": {
|
||||
"Name": "git.reeseapps.com",
|
||||
"Type": "A",
|
||||
"TTL": 300,
|
||||
"ResourceRecords": [
|
||||
{
|
||||
"Value": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"Action": "UPSERT",
|
||||
"ResourceRecordSet": {
|
||||
"Name": "jellyfin.reeseapps.com",
|
||||
"Type": "A",
|
||||
"TTL": 300,
|
||||
"ResourceRecords": [
|
||||
{
|
||||
"Value": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"Action": "UPSERT",
|
||||
"ResourceRecordSet": {
|
||||
"Name": "snapdrop.reeseapps.com",
|
||||
"Type": "A",
|
||||
"TTL": 300,
|
||||
"ResourceRecords": [
|
||||
{
|
||||
"Value": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"Action": "UPSERT",
|
||||
"ResourceRecordSet": {
|
||||
"Name": "unifi.reeseapps.com",
|
||||
"Type": "A",
|
||||
"TTL": 300,
|
||||
"ResourceRecords": [
|
||||
{
|
||||
"Value": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
18
systemd/graduated/ddns/reeselink_record_template.json
Normal file
18
systemd/graduated/ddns/reeselink_record_template.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"Comment": "Update Public IPV4 Address",
|
||||
"Changes": [
|
||||
{
|
||||
"Action": "UPSERT",
|
||||
"ResourceRecordSet": {
|
||||
"Name": "ipv4.reeselink.com",
|
||||
"Type": "A",
|
||||
"TTL": 300,
|
||||
"ResourceRecords": [
|
||||
{
|
||||
"Value": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
0
systemd/graduated/ddns/vars.yaml
Normal file
0
systemd/graduated/ddns/vars.yaml
Normal file
Reference in New Issue
Block a user