Execution
Date
08 Dec 2025 13:27:39 +0000
Duration
00:05:33.94
Controller
aio1.openstack.local
User
root
Versions
Ansible
2.18.6
ara
1.7.4 / 1.7.4
Python
3.12.3
Summary
2
Hosts
316
Tasks
313
Results
18
Plays
136
Files
0
Records
File: /home/zuul/src/opendev.org/openstack/ansible-role-systemd_service/tasks/main.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | --- # Copyright 2017, Rackspace US, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - name: Create TEMP run dir ansible.builtin.file: path: "{{ item.systemd_run_dir | default(systemd_run_dir) }}/{{ item.systemd_slice_name | default(systemd_slice_name) | replace(' ', '_') }}" state: directory owner: "{{ item.systemd_user_name | default(systemd_user_name) }}" group: "{{ item.systemd_group_name | default(systemd_group_name) }}" mode: "02755" loop: "{{ systemd_services }}" loop_control: label: "{{ loop_label | to_json }}" vars: loop_label: path: "{{ item.systemd_run_dir | default(systemd_run_dir) }}/{{ item.systemd_slice_name | default(systemd_slice_name) | replace(' ', '_') }}" owner: "{{ item.systemd_user_name | default(systemd_user_name) }}" group: "{{ item.systemd_group_name | default(systemd_group_name) }}" tags: - systemd-service - name: Create TEMP service lock dir ansible.builtin.file: path: "{{ item.systemd_lock_dir | default(systemd_lock_dir) }}/{{ item.systemd_slice_name | default(systemd_slice_name) | replace(' ', '_') }}" state: directory owner: "{{ item.systemd_user_name | default(systemd_user_name) }}" group: "{{ item.systemd_group_name | default(systemd_group_name) }}" mode: "02755" loop: "{{ systemd_services }}" loop_control: label: "{{ loop_label | to_json }}" vars: loop_label: path: "{{ item.systemd_lock_dir | default(systemd_lock_dir) }}/{{ item.systemd_slice_name | default(systemd_slice_name) | replace(' ', '_') }}" owner: "{{ item.systemd_user_name | default(systemd_user_name) }}" group: "{{ item.systemd_group_name | default(systemd_group_name) }}" tags: - systemd-service - name: Create service.d overrides dir ansible.builtin.file: path: "/etc/systemd/system/{{ item.service_name | replace(' ', '_') }}.service.d" state: directory owner: "{{ item.systemd_user_name | default(systemd_user_name) }}" group: "{{ item.systemd_group_name | default(systemd_group_name) }}" mode: "02755" loop: "{{ systemd_services | rejectattr('systemd_overrides', 'undefined') }}" loop_control: label: "{{ loop_label | to_json }}" vars: loop_label: path: "/etc/systemd/system/{{ item.service_name | replace(' ', '_') }}.service.d" owner: "{{ item.systemd_user_name | default(systemd_user_name) }}" group: "{{ item.systemd_group_name | default(systemd_group_name) }}" tags: - systemd-service - name: Create tmpfiles.d entry ansible.builtin.template: src: "systemd-tmpfiles.j2" dest: "/etc/tmpfiles.d/{{ item.systemd_tempd_prefix | default(systemd_tempd_prefix) }}-{{ item.service_name | replace(' ', '_') }}.conf" loop: "{{ systemd_services }}" loop_control: label: "{{ loop_label | to_json }}" vars: loop_label: src: "systemd-tmpfiles.j2" dest: "/etc/tmpfiles.d/{{ item.systemd_tempd_prefix | default(systemd_tempd_prefix) }}-{{ item.service_name | replace(' ', '_') }}.conf" tags: - systemd-service - name: Place the systemd service openstack.config_template.config_template: src: "systemd-service.j2" dest: "/etc/systemd/system/{{ item.service_name | replace(' ', '_') }}.service" config_overrides: "{{ item.config_overrides | default(systemd_service_config_overrides) }}" config_type: "ini" loop: "{{ systemd_services | rejectattr('systemd_overrides_only', 'true') }}" loop_control: label: "{{ loop_label | to_json }}" vars: loop_label: src: "systemd-service.j2" dest: "/etc/systemd/system/{{ item.service_name | replace(' ', '_') }}.service" config_overrides: "{{ item.config_overrides | default(systemd_service_config_overrides) }}" config_type: "ini" notify: - systemd service changed register: systemd_services_result tags: - systemd-service - name: Place the systemd override ansible.builtin.template: src: "systemd-service-overrides.j2" dest: "/etc/systemd/system/{{ item.service_name | replace(' ', '_') }}.service.d/override.conf" loop: "{{ systemd_services | rejectattr('systemd_overrides', 'undefined') }}" loop_control: label: "{{ loop_label | to_json }}" vars: loop_label: src: "systemd-service-overrides.j2" dest: "/etc/systemd/system/{{ item.service_name | replace(' ', '_') }}.service.d/override.conf" notify: - systemd service changed register: systemd_override_result tags: - systemd-service - name: Place the systemd timer ansible.builtin.template: src: "systemd-timer.j2" dest: "/etc/systemd/system/{{ item.service_name | replace(' ', '_') }}.timer" mode: "0644" owner: "root" group: "root" loop: "{{ systemd_services | selectattr('timer', 'defined') }}" loop_control: label: "{{ loop_label | to_json }}" vars: loop_label: src: "systemd-timer.j2" dest: "/etc/systemd/system/{{ item.service_name | replace(' ', '_') }}.timer" notify: - systemd service changed register: systemd_timer_result tags: - systemd-service - name: Place the systemd socket ansible.builtin.template: src: "systemd-socket.j2" dest: "/etc/systemd/system/{{ item.1.socket_name | replace(' ', '_') }}.socket" mode: "0644" owner: "root" group: "root" loop: "{{ systemd_services | subelements('sockets', skip_missing=True) }}" loop_control: label: "{{ loop_label | to_json }}" vars: loop_label: src: "systemd-socket.j2" dest: "/etc/systemd/system/{{ item.1.socket_name | replace(' ', '_') }}.socket" notify: - systemd socket changed - systemd service changed register: systemd_socket tags: - systemd-service - name: Reload systemd on unit change ansible.builtin.systemd: daemon_reload: true when: - (systemd_services_result is changed) or (systemd_timer_result is changed) or (systemd_override_result is changed ) or (systemd_socket.results | selectattr('changed', 'true') | length > 0) - name: Including systemd_load tasks ansible.builtin.include_tasks: systemd_load.yml vars: _systemd_service_name: "{{ service.service_name | replace(' ', '_') }}" loop_label: service_name: "{{ _systemd_service_name }}" loop: "{{ systemd_services }}" loop_control: loop_var: service label: "{{ loop_label | to_json }}" args: apply: tags: - systemd-service tags: - systemd-service - name: Load socket ansible.builtin.systemd: name: "{{ item.socket_name | replace(' ', '_') }}.socket" enabled: "{{ item.enabled | default(systemd_service_enabled) }}" state: "{{ item.state | default(omit) }}" loop: "{{ systemd_services | selectattr('sockets', 'defined') | map(attribute='sockets') | flatten(1) }}" loop_control: label: "{{ loop_label | to_json }}" vars: loop_label: name: "{{ item.socket_name | replace(' ', '_') }}.socket" enabled: "{{ item.enabled | default(systemd_service_enabled) }}" state: "{{ item.state | default(omit) }}" tags: - systemd-service |