Skip to content

Commit

Permalink
Add support for systemd overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterlexis authored and atosatto committed Jul 11, 2018
1 parent 418a786 commit fa9633a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 1 deletion.
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 %}

0 comments on commit fa9633a

Please sign in to comment.