Skip to content
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

Add support for systemd overrides #37

Merged
merged 1 commit into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ This will create a file called `dns-script.lua` into the `pdns_rec_config_dir`
and add the configuration to load this script to the `recursor.conf`
configuration file.

pdns_rec_service_overrides: {}

Dict with overrides for the service (systemd only).
This can be used to change any systemd settings in the `[Service]` category

Example Playbook
----------------

Expand Down
7 changes: 7 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,10 @@ pdns_rec_config: { }
# This will create a file called `dns-script.lua` into the `pdns_rec_config_dir`
# and add the configuration to load this script to the `recursor.conf`
# pdns_rec_lua_dns_script_content: ""

# Dict with overrides for the service (systemd only)
# Can be used to increase e.g. the number of FDs like this:
# pdns_rec_service_overrides:
# LimitNOFILE: 10000

pdns_rec_service_overrides: {}
4 changes: 4 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
service:
name: "{{ pdns_rec_service_name }}"
state: restarted

- name: Reload systemd and restart PowerDNS Recursor
command: systemctl daemon-reload
notify: Restart PowerDNS Recursor
7 changes: 6 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
include: configure.yml
tags:
- config


- include: systemd.yml
when: ansible_service_mgr == 'systemd'
tags:
- service

- name: Start and enable the PowerDNS Recursor service
service:
name: "{{ pdns_rec_service_name }}"
Expand Down
16 changes: 16 additions & 0 deletions tasks/systemd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- block:
- name: Ensure the override directory exists
file:
path: '/etc/systemd/system/{{ pdns_rec_service_name }}.service.d'
state: directory
owner: root
group: root
- name: Create override for the service
template:
dest: '/etc/systemd/system/{{ pdns_rec_service_name }}.service.d/override.conf'
src: 'override.systemd.conf.j2'
owner: root
group: root
notify: Reload systemd and restart PowerDNS Recursor
when: pdns_rec_service_overrides != {}
4 changes: 4 additions & 0 deletions templates/override.systemd.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Service]
{% for k, v in pdns_rec_service_overrides.items() %}
{{ k }}={{ v }}
{% endfor %}