-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
94 additions
and
163 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM docker.io/alpine:3.20 | ||
|
||
RUN apk add --no-cache \ | ||
ca-certificates \ | ||
openssh \ | ||
git \ | ||
ansible \ | ||
make \ | ||
just \ | ||
py3-dnspython \ | ||
py3-passlib | ||
|
||
ENV ANSIBLE_STDOUT_CALLBACK=unixy | ||
ENV ANSIBLE_LOAD_CALLBACK_PLUGINS=1 | ||
ENV RECORDS="* @" | ||
ENV SCHEDULE="*/10 * * * *" | ||
|
||
WORKDIR /netcup-dns | ||
|
||
COPY ansible/update-dns.yaml ansible | ||
COPY entrypoint.sh . | ||
RUN chmod +x entrypoint.sh | ||
|
||
ENTRYPOINT [ "entrypoint.sh" ] | ||
CMD [ "crond", "-f" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
- hosts: 127.0.0.1 | ||
connection: local | ||
vars: | ||
data_base_path: "/tmp/netcup-dns" | ||
ipv4_path: "{{ data_base_path }}/IPv4" | ||
ipv6_path: "{{ data_base_path }}/IPv6" | ||
|
||
tasks: | ||
- name: Create netcup directory if it does not exist | ||
ansible.builtin.file: | ||
path: "{{ data_base_path }}" | ||
state: directory | ||
|
||
- name: Get IPv4 | ||
vars: | ||
do_check: "{{ lookup('env','IPv4') }}" | ||
when: do_check != 'no' | ||
ignore_errors: yes | ||
ansible.builtin.get_url: | ||
url: "{{ item }}" | ||
dest: "{{ ipv4_path }}" | ||
with_items: | ||
- http://v4.ident.me/ | ||
- http://v4.tnedi.me/ | ||
register: result_v4 | ||
|
||
- name: Get IPv6 | ||
vars: | ||
do_check: "{{ lookup('env','IPv6') }}" | ||
when: do_check != 'no' | ||
ignore_errors: yes | ||
ansible.builtin.get_url: | ||
url: "{{ item }}" | ||
dest: "{{ ipv6_path }}" | ||
with_items: | ||
- http://v6.ident.me/ | ||
- http://v6.tnedi.me/ | ||
register: result_v6 | ||
|
||
- name: Create IPv4 Record | ||
when: result_v4.changed | ||
ignore_errors: yes | ||
community.general.netcup_dns: | ||
api_key: "{{ lookup('env','API_KEY') }}" | ||
api_password: "{{ lookup('env','API_PASSWORD') }}" | ||
customer_id: "{{ lookup('env','CUSTOMER_ID') }}" | ||
domain: "{{ lookup('env','DOMAIN') }}" | ||
record: "{{ item }}" | ||
type: "A" | ||
value: "{{ lookup('file', ipv4_path) }}" | ||
with_items: "{{ lookup('env','RECORDS') | split }}" | ||
|
||
- name: Create IPv6 Record | ||
when: result_v6.changed | ||
ignore_errors: yes | ||
community.general.netcup_dns: | ||
api_key: "{{ lookup('env','API_KEY') }}" | ||
api_password: "{{ lookup('env','API_PASSWORD') }}" | ||
customer_id: "{{ lookup('env','CUSTOMER_ID') }}" | ||
domain: "{{ lookup('env','DOMAIN') }}" | ||
record: "{{ item }}" | ||
type: "A" | ||
value: "{{ lookup('file', ipv6_path) }}" | ||
with_items: "{{ lookup('env','RECORDS') | split }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
echo "${SCHEDULE} ansible-playbook /netcup-dns/update-dns.yaml" > /etc/crontabs/root | ||
exec "$@" |