diff --git a/defaults/main.yml b/defaults/main.yml index e7dada7..432fdb9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -128,3 +128,7 @@ watcher_role_project_group: watcher_all ## Tunable overrides watcher_policy_overrides: {} watcher_conf_overrides: {} + +watcher_api_init_config_overrides: {} +watcher_decision_init_config_overrides: {} +watcher_applier_init_config_overrides: {} diff --git a/releasenotes/notes/watcher-init-config-overrides-ffce7e419061c4da.yaml b/releasenotes/notes/watcher-init-config-overrides-ffce7e419061c4da.yaml new file mode 100644 index 0000000..915a4ae --- /dev/null +++ b/releasenotes/notes/watcher-init-config-overrides-ffce7e419061c4da.yaml @@ -0,0 +1,10 @@ +--- +features: + - New variables have been added to allow a deployer to customize + a watcher systemd unit file to their liking. + - The task dropping the watcher systemd unit files now uses the + ``config_template`` action plugin allowing deployers access to + customize the unit files as they see fit without having to + load extra options into the defaults and polute the generic + systemd unit file with jinja2 variables and conditionals. + diff --git a/tasks/watcher_init.yml b/tasks/watcher_init.yml index dc402e7..ddf2c94 100644 --- a/tasks/watcher_init.yml +++ b/tasks/watcher_init.yml @@ -20,6 +20,7 @@ system_user: "{{ watcher_system_user_name }}" system_group: "{{ watcher_system_group_name }}" service_home: "{{ watcher_system_user_home }}" + init_config_overrides: "{{ watcher_api_init_config_overrides }}" when: inventory_hostname in groups['watcher_api'] - include: watcher_init_common.yml @@ -29,6 +30,7 @@ system_user: "{{ watcher_system_user_name }}" system_group: "{{ watcher_system_group_name }}" service_home: "{{ watcher_system_user_home }}" + init_config_overrides: "{{ watcher_decision_init_config_overrides }}" when: inventory_hostname in groups['watcher_decision_engine'] - include: watcher_init_common.yml @@ -38,4 +40,5 @@ system_user: "{{ watcher_system_user_name }}" system_group: "{{ watcher_system_group_name }}" service_home: "{{ watcher_system_user_home }}" + init_config_overrides: "{{ watcher_applier_init_config_overrides }}" when: inventory_hostname in groups['watcher_applier'] diff --git a/tasks/watcher_init_systemd.yml b/tasks/watcher_init_systemd.yml index cc008f4..8373859 100644 --- a/tasks/watcher_init_systemd.yml +++ b/tasks/watcher_init_systemd.yml @@ -38,12 +38,14 @@ group: "root" - name: Place the systemd init script - template: + config_template: src: "watcher-systemd-init.j2" dest: "/etc/systemd/system/{{ program_name }}.service" mode: "0644" owner: "root" group: "root" + config_overrides: "{{ init_config_overrides }}" + config_type: "ini" register: systemd_init - name: Reload the systemd daemon diff --git a/templates/watcher-systemd-init.j2 b/templates/watcher-systemd-init.j2 index 76da59d..f94789e 100644 --- a/templates/watcher-systemd-init.j2 +++ b/templates/watcher-systemd-init.j2 @@ -21,5 +21,14 @@ TimeoutSec=300 Restart=on-failure RestartSec=150 +# This creates a specific slice which all services will operate from +# The accounting options give us the ability to see resource usage through +# the `systemd-cgtop` command. +Slice=watcher.slice +CPUAccounting=true +BlockIOAccounting=true +MemoryAccounting=false +TasksAccounting=true + [Install] WantedBy=multi-user.target