knot: rewrite role
This commit is contained in:
28
roles/knot/tasks/RedHat.yaml
Normal file
28
roles/knot/tasks/RedHat.yaml
Normal file
@ -0,0 +1,28 @@
|
||||
---
|
||||
- name: Install knot {{- knot_version }} packages
|
||||
dnf:
|
||||
name: "{{ knot_packages }}"
|
||||
state: "{{ 'latest' if knot_version == 'latest' else 'present' }}"
|
||||
update_cache: true
|
||||
|
||||
- name: Include XDP configuratio
|
||||
when: knot_xdp
|
||||
block:
|
||||
- name: Create override directory for knot systemd unit
|
||||
file:
|
||||
name: /etc/systemd/system/knot.service.d
|
||||
state: directory
|
||||
- name: Create override.conf for knot for XDP
|
||||
copy:
|
||||
dest: /etc/systemd/system/knot.service.d/override.conf
|
||||
content: |
|
||||
[Service]
|
||||
CapabilityBoundingSet=CAP_NET_RAW CAP_NET_ADMIN CAP_SYS_ADMIN CAP_IPC_LOCK CAP_SYS_RESOURCE
|
||||
AmbientCapabilities=CAP_NET_RAW CAP_NET_ADMIN CAP_SYS_ADMIN CAP_IPC_LOCK CAP_SYS_RESOURCE
|
||||
notify: Restart knot
|
||||
|
||||
- name: Install deps for XDP
|
||||
dnf:
|
||||
name: "{{ knot_deps_packages }}"
|
||||
state: present
|
||||
update_cache: true
|
@ -1,7 +0,0 @@
|
||||
---
|
||||
# RedHat Family (RedHat, Fendora, CentOS, Amazon, etc)
|
||||
- name: packages (RedHat)
|
||||
yum:
|
||||
name: knot
|
||||
state: present
|
||||
when: ansible_os_family == "RedHat"
|
40
roles/knot/tasks/main.yaml
Normal file
40
roles/knot/tasks/main.yaml
Normal file
@ -0,0 +1,40 @@
|
||||
---
|
||||
- name: Make sure handlers are flushed immediately
|
||||
meta: flush_handlers
|
||||
|
||||
- name: Load a variable file based on the OS type
|
||||
include_vars: "{{ lookup('first_found', params) }}"
|
||||
vars:
|
||||
params:
|
||||
files:
|
||||
- "{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_major_version'] }}.yaml"
|
||||
- "{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}.yaml"
|
||||
- "{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_major_version'] }}.yaml"
|
||||
- "{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_version'] }}.yaml"
|
||||
- "{{ ansible_facts['distribution'] }}.yaml"
|
||||
- "{{ ansible_facts['os_family'] }}.yaml"
|
||||
- main.yaml
|
||||
paths:
|
||||
- "vars"
|
||||
tags: knot_vars
|
||||
|
||||
- name: Include knot install for {{ ansible_distribution }}
|
||||
include_tasks: "{{ ansible_facts['os_family'] }}.yaml"
|
||||
|
||||
- name: Configure knot
|
||||
copy:
|
||||
content: "{{ knot_conf }}"
|
||||
dest: /etc/knot/knot.conf
|
||||
mode: 0640
|
||||
owner: "root"
|
||||
group: "knot"
|
||||
validate: "knotc -c %s conf-check"
|
||||
notify: Restart knot
|
||||
|
||||
- name: Enable and start knot
|
||||
systemd:
|
||||
name: "knot"
|
||||
enabled: true
|
||||
state: started
|
||||
masked: false
|
||||
daemon_reload: true
|
@ -1,24 +0,0 @@
|
||||
---
|
||||
- name: install
|
||||
become: true
|
||||
include: install.yml
|
||||
|
||||
# Configuration
|
||||
- name: configure knot
|
||||
become: true
|
||||
copy:
|
||||
content: "{{ knot_conf }}"
|
||||
dest: /etc/knot/knot.conf
|
||||
mode: 0640
|
||||
owner: "root"
|
||||
group: "knot"
|
||||
validate: "knotc -c %s conf-check"
|
||||
notify: restart knot
|
||||
|
||||
- name: enable knot
|
||||
become: true
|
||||
systemd:
|
||||
name: "knot"
|
||||
enabled: yes
|
||||
state: started
|
||||
daemon_reload: yes
|
Reference in New Issue
Block a user