Repository navigation
expose DNS feature with nsupdate provider and a dedicated DNS server #532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| --- | ||
| help: Setup a machine with BIND |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| - name: Setup remote named | ||
| hosts: | ||
| - named | ||
| become: true | ||
| roles: | ||
| - role: bind | ||
| tasks: | ||
| - name: Fetch rndc key | ||
| ansible.builtin.fetch: | ||
| src: "/etc/named/rndc.key" | ||
| dest: "{{ obsah_state_path }}/rndc.key" | ||
| flat: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| ansible.builtin.package: | ||
| name: | ||
| - nmap | ||
| - bind-utils | ||
|
|
||
| - name: Execute tests | ||
| gather_facts: false | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| $TTL 2d ; default TTL for zone | ||
| @ IN SOA @ hostmaster.invalid. ( | ||
| 0 ; serial number | ||
| 12h ; refresh | ||
| 15m ; update retry | ||
| 3w ; expiry | ||
| 2h ; minimum | ||
| ) | ||
| IN NS localhost. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| --- | ||
| - name: Install BIND | ||
| ansible.builtin.package: | ||
| name: | ||
| - bind | ||
| - bind-utils | ||
| state: present | ||
|
|
||
| - name: Generate the rndc key | ||
| ansible.builtin.command: | ||
| cmd: rndc-confgen -a -c /etc/named/rndc.key | ||
| creates: /etc/named/rndc.key | ||
|
|
||
| - name: Set permissions on rndc key | ||
| ansible.builtin.file: | ||
| path: /etc/named/rndc.key | ||
| owner: root | ||
| group: named | ||
| mode: '0640' | ||
|
|
||
| - name: Copy the base zone files | ||
| ansible.builtin.copy: | ||
| src: empty.zone | ||
| dest: "/var/named/{{ item }}.db" | ||
| owner: root | ||
| group: named | ||
| mode: '0640' | ||
| loop: | ||
| - example.test | ||
| - 2.0.192.in-addr.arpa | ||
| - 8.b.d.0.1.0.0.2.ip6.arpa | ||
|
|
||
| - name: Configure example.test zone | ||
| ansible.builtin.blockinfile: | ||
| path: /etc/named.conf | ||
| block: | | ||
| include "/etc/named/rndc.key"; | ||
| zone "example.test" { | ||
| type primary; | ||
| file "example.test.db"; | ||
| allow-update { key "rndc-key"; }; | ||
| }; | ||
| zone "2.0.192.in-addr.arpa" { | ||
| type primary; | ||
| file "2.0.192.in-addr.arpa.db"; | ||
| allow-update { key "rndc-key"; }; | ||
| }; | ||
| zone "8.b.d.0.1.0.0.2.ip6.arpa" { | ||
| type primary; | ||
| file "8.b.d.0.1.0.0.2.ip6.arpa.db"; | ||
| allow-update { key "rndc-key"; }; | ||
| }; | ||
|
|
||
| - name: Configure BIND to listen on any IP | ||
| ansible.builtin.lineinfile: | ||
| path: /etc/named.conf | ||
| regexp: '^(\s+{{ item }})' | ||
| line: '\g<1> { any; };' | ||
| backrefs: true | ||
| loop: | ||
| - listen-on port 53 | ||
| - listen-on-v6 port 53 | ||
| - allow-query | ||
|
|
||
| - name: Start BIND | ||
| ansible.builtin.service: | ||
| name: named | ||
| state: started | ||
| enabled: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| - name: Include tasks for {{ item }} | ||
| ansible.builtin.include_tasks: feature.yaml | ||
| vars: | ||
| feature_enabled: "{{ foreman_proxy_dns_provider_name == item }}" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coderabbit (in a nitpick) pointed out that this is now a boolean, while the original intent of the variable was to map the whole spectrum of (Mostly commenting so it's not lost in the rabbit hole, hah) |
||
| feature_name: "{{ item }}" | ||
| loop: "{{ foreman_proxy_dns_provider_list }}" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --- | ||
| - name: Create RNDC Key podman secret | ||
| containers.podman.podman_secret: | ||
| state: present | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taking it a step further, this should probably look at the enabled state too. Ideally we would clean up items (secrets, systemd drop-ins).
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now this file is not included when the feature is disabled, but we certainly can extend this. |
||
| name: foreman_proxy-dns_nsupdate-rndc_key | ||
| data: "{{ lookup('ansible.builtin.file', foreman_proxy_dns_nsupdate_keyfile) }}" | ||
| notify: | ||
| - Restart Foreman Proxy | ||
| - Refresh Foreman Proxy | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| - name: Mount RNDC key | ||
| ansible.builtin.copy: | ||
| dest: /etc/containers/systemd/foreman-proxy.container.d/dns_nsupdate-rndc_key.conf | ||
| content: | | ||
| [Container] | ||
| Secret=foreman_proxy-dns_nsupdate-rndc_key,type=mount,target=/etc/foreman-proxy/rndc.key | ||
| mode: '0644' | ||
| owner: root | ||
| group: root | ||
| notify: | ||
| - Restart Foreman Proxy | ||
| - Refresh Foreman Proxy | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| :enabled: {{ feature_enabled }} | ||
|
|
||
| :use_provider: {{ foreman_proxy_dns_provider_name }} | ||
| :dns_ttl: {{ foreman_proxy_dns_ttl }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| --- | ||
| :dns_key: /etc/foreman-proxy/rndc.key | ||
| :dns_server: {{ foreman_proxy_dns_server }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also look at the dns feature being enabled?