generated from onedr0p/cluster-template
-
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
1 parent
06287d8
commit be4418c
Showing
18 changed files
with
107 additions
and
123 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners | ||
* @onedr0p | ||
* @solidDoWant |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
jmsepath | ||
jmespath | ||
docker | ||
lxml | ||
openshift |
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
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
2 changes: 0 additions & 2 deletions
2
bootstrap/remote/playbooks/gateway_hosts/roles/coredns_builder/defaults/main.yaml
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
bootstrap/remote/playbooks/gateway_hosts/roles/coredns_builder/files/build/Dockerfile
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
bootstrap/remote/playbooks/gateway_hosts/roles/coredns_builder/tasks/main.yaml
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
bootstrap/remote/playbooks/gateway_hosts/roles/coredns_download/defaults/main.yaml
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,2 @@ | ||
--- | ||
coredns_working_dir_path: "{{ working_dir_path }}/coredns" |
36 changes: 36 additions & 0 deletions
36
bootstrap/remote/playbooks/gateway_hosts/roles/coredns_download/tasks/main.yaml
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,36 @@ | ||
--- | ||
- name: Check if the CoreDNS binary file exists | ||
ansible.builtin.stat: | ||
path: "{{ coredns_working_dir_path }}/coredns" | ||
register: coredns_binary | ||
|
||
- name: Create the coredns directory | ||
ansible.builtin.file: | ||
path: "{{ coredns_working_dir_path }}" | ||
state: directory | ||
mode: "0755" | ||
register: coredns_directory | ||
when: not coredns_binary.stat.exists | ||
|
||
# TODO version this with Renovate | ||
- name: Get the latest k8s_gateway release data from GitHub | ||
ansible.builtin.uri: | ||
url: https://api.github.com/repos/ori-edge/k8s_gateway/releases/latest | ||
method: GET | ||
return_content: true | ||
status_code: 200 | ||
body_format: json | ||
register: github_k8s_gateway_page | ||
when: not coredns_binary.stat.exists | ||
|
||
# TODO don't hardcode OS info | ||
- name: Download and extract the k8s_gateway version of CoreDNS from GitHub | ||
ansible.builtin.unarchive: | ||
src: "{{ github_k8s_gateway_page.json | json_query(query) | first }}" | ||
dest: "{{ coredns_working_dir_path }}" | ||
remote_src: true | ||
include: | ||
- coredns | ||
vars: | ||
query: assets[?ends_with(name, 'freebsd_amd64.tar.gz')].browser_download_url | ||
when: not coredns_binary.stat.exists |
2 changes: 1 addition & 1 deletion
2
bootstrap/remote/playbooks/gateway_hosts/roles/coredns_runner/files/coredns-rc.d
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
81 changes: 43 additions & 38 deletions
81
bootstrap/remote/playbooks/gateway_hosts/roles/coredns_runner/tasks/main.yaml
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 |
---|---|---|
@@ -1,136 +1,141 @@ | ||
--- | ||
- name: Create config directory | ||
file: | ||
ansible.builtin.file: | ||
path: /usr/local/etc/coredns | ||
state: directory | ||
mode: 0755 | ||
mode: "0755" | ||
|
||
- name: Create zones directory | ||
file: | ||
ansible.builtin.file: | ||
path: /usr/local/etc/coredns/config.d | ||
state: directory | ||
mode: 0755 | ||
mode: "0755" | ||
|
||
- name: Create root config directory | ||
file: | ||
ansible.builtin.file: | ||
path: /usr/local/etc/coredns/root_config.d | ||
state: directory | ||
mode: 0755 | ||
mode: "0755" | ||
|
||
- name: Create zonefiles directory | ||
file: | ||
ansible.builtin.file: | ||
path: /usr/local/etc/coredns/zones | ||
state: directory | ||
mode: 0755 | ||
mode: "0755" | ||
|
||
- name: Gather facts on all hosts for DNS record creation | ||
setup: {} | ||
ansible.builtin.setup: {} | ||
delegate_to: "{{ item }}" | ||
delegate_facts: true | ||
when: hostvars[item]['ansible_default_ipv4'] is not defined | ||
with_items: "{{ groups['all'] }}" | ||
|
||
- name: Create Corefile | ||
template: | ||
ansible.builtin.template: | ||
src: Corefile | ||
dest: /usr/local/etc/coredns/Corefile | ||
mode: 0755 | ||
mode: "0755" | ||
vars: | ||
listening_addresses: "{{ ansible_interfaces | select('match', '^(lo\\d+|vtnet1\\S*)$') | join(' ') }}" | ||
|
||
- name: Create config files | ||
template: | ||
ansible.builtin.template: | ||
src: "{{ item }}" | ||
dest: /usr/local/etc/coredns/config.d | ||
mode: 0755 | ||
mode: "0755" | ||
with_fileglob: | ||
- ../templates/config.d/* | ||
|
||
- name: Create zone files | ||
template: | ||
ansible.builtin.template: | ||
src: "{{ item }}" | ||
dest: /usr/local/etc/coredns/zones | ||
mode: 0755 | ||
mode: "0755" | ||
with_fileglob: | ||
- ../templates/zones/* | ||
|
||
- name: Create CoreDNS rc.conf script | ||
copy: | ||
ansible.builtin.copy: | ||
src: coredns-rc.conf | ||
dest: /etc/rc.conf.d/coredns | ||
mode: 0755 | ||
mode: "0755" | ||
|
||
- name: Create CoreDNS rc.d script | ||
copy: | ||
ansible.builtin.copy: | ||
src: coredns-rc.d | ||
dest: /usr/local/etc/rc.d/coredns | ||
mode: 0755 | ||
mode: "0755" | ||
|
||
- name: Create CoreDNS action script | ||
copy: | ||
ansible.builtin.copy: | ||
src: actions_coredns.conf | ||
dest: /usr/local/opnsense/service/conf/actions.d/actions_coredns.conf | ||
mode: 0755 | ||
mode: "0755" | ||
|
||
- name: Create CoreDNS start up script | ||
copy: | ||
ansible.builtin.copy: | ||
src: 99-coredns | ||
dest: /usr/local/etc/rc.syshook.d/start/99-coredns | ||
mode: 0755 | ||
mode: "0755" | ||
|
||
- name: Create CoreDNS log rotation config | ||
copy: | ||
ansible.builtin.copy: | ||
src: coredns-newsyslog.conf | ||
dest: /etc/newsyslog.conf.d/coredns | ||
mode: 0755 | ||
mode: "0755" | ||
|
||
- name: Stop running CoreDNS | ||
shell: /usr/local/etc/rc.d/coredns stop | ||
ansible.builtin.command: /usr/local/etc/rc.d/coredns stop | ||
ignore_errors: true | ||
register: coredns_stop | ||
|
||
- name: Copy CoreDNS | ||
copy: | ||
ansible.builtin.copy: | ||
src: "{{ working_dir_path }}/coredns/coredns" | ||
dest: /usr/local/sbin/coredns | ||
mode: 0755 | ||
mode: "0755" | ||
|
||
- name: Disable Unbound DNS | ||
when: coredns_stop.rc != 0 | ||
|
||
block: | ||
- name: Pull the current OPNsense config | ||
fetch: | ||
ansible.builtin.fetch: | ||
src: "{{ remote_config_path }}" | ||
dest: "{{ local_config_path }}" | ||
flat: true | ||
register: downloaded_config | ||
- name: Disable Unbound | ||
when: downloaded_config.changed | ||
delegate_to: localhost | ||
block: | ||
- name: Remove /opnsense/unbound/enable | ||
xml: | ||
community.general.xml: | ||
path: "{{ local_config_path }}" | ||
xpath: /opnsense/unbound/enable | ||
state: absent | ||
- name: Remove /opnsense/OPNsense/unboundplus/enabled | ||
community.general.xml: | ||
path: "{{ local_config_path }}" | ||
xpath: /opnsense/OPNsense/unboundplus/enabled | ||
state: absent | ||
- name: Remove /opnsense/OPNsense/unboundplus/service_enabled | ||
xml: | ||
community.general.xml: | ||
path: "{{ local_config_path }}" | ||
xpath: /opnsense/OPNsense/unboundplus/service_enabled | ||
state: absent | ||
when: downloaded_config.changed | ||
delegate_to: localhost | ||
- name: Copy the new OPNsense config | ||
copy: | ||
ansible.builtin.copy: | ||
src: "{{ local_config_path }}" | ||
dest: "{{ remote_config_path }}" | ||
backup: true | ||
register: return_config | ||
when: downloaded_config.changed | ||
- name: Reload OPNsense | ||
command: "{{ item }}" | ||
ansible.builtin.command: "{{ item }}" | ||
with_items: | ||
- configctl service reload all | ||
- configctl webgui restart | ||
when: downloaded_config.changed and return_config.changed | ||
when: coredns_stop.rc != 0 | ||
|
||
- name: Run CoreDNS | ||
shell: /usr/local/etc/rc.d/coredns start | ||
ansible.builtin.command: /usr/local/etc/rc.d/coredns start |
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
Oops, something went wrong.