Execution
Date
08 Dec 2025 13:50:33 +0000
Duration
00:06:27.80
Controller
aio1.openstack.local
User
root
Versions
Ansible
2.18.6
ara
1.7.4 / 1.7.4
Python
3.12.11
Summary
7
Hosts
589
Tasks
576
Results
37
Plays
222
Files
0
Records
File: /home/zuul/src/opendev.org/openstack/ansible-role-systemd_mount/tasks/systemd_mounts.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 | --- # Copyright 2018, 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: Set mount facts ansible.builtin.set_fact: systemd_mount_suffix: "{{ (item.type == 'swap') | ternary('swap', 'mount') }}" systemd_mount_item: "{{ item.where | default(item.what) }}" - name: Escape mount service file name ansible.builtin.command: systemd-escape -p --suffix="{{ systemd_mount_suffix }}" "{{ systemd_mount_item }}" changed_when: false register: mount_service_name_escaped when: item.escape_name | default(true) - name: Define mount service name ansible.builtin.set_fact: mount_service_name: "{{ mount_service_name_escaped.stdout | default([systemd_mount_item, systemd_mount_suffix] | join('.')) }}" # NOTE(noonedeadpunk): with s3fs IO error would raise on attempt to change permissions. - name: Create mount target(s) ansible.builtin.file: path: "{{ item.where }}" state: directory owner: "{{ item.owner | default(omit) }}" group: "{{ item.group | default(omit) }}" mode: "0755" failed_when: false when: - item.where is defined - item.state | default('unknown') != 'absent' - item.type != 'swap' tags: - systemd-mount - name: Place mount credentials when required ansible.builtin.copy: dest: "/etc/passwd-{{ mount_service_name }}" content: "{{ item.credentials }}" owner: "root" group: "root" mode: "0600" when: - item.type == "fuse.s3fs" - "'credentials' in item" - name: Create systemd mount services(s) openstack.config_template.config_template: src: "systemd-mount.j2" dest: "/etc/systemd/system/{{ mount_service_name }}" owner: "root" group: "root" mode: "{{ item.unit_mode | default('0644') }}" config_overrides: "{{ item.config_overrides | default({}) }}" config_type: "ini" when: - item.state | default('unknown') != 'absent' - (item.mount_overrides_only is not defined) or (item.mount_overrides_only is defined and not item.mount_overrides_only) tags: - systemd-mount - name: Provision mount overrides file when: - item.mount_overrides_only is defined - item.mount_overrides_only | bool - item.config_overrides | length > 0 tags: - systemd-mount block: - name: Create overrides folder for mount ansible.builtin.file: path: "/etc/systemd/system/{{ mount_service_name }}.d" owner: "root" group: "root" mode: "0755" state: directory - name: Create overrides file openstack.config_template.config_template: dest: "/etc/systemd/system/{{ mount_service_name }}.d/overrides.conf" owner: "root" group: "root" mode: "0644" config_overrides: "{{ item.config_overrides | default({}) }}" config_type: "ini" - name: Load or Unload mount(s) ansible.builtin.systemd: daemon_reload: true name: "{{ mount_service_name }}" enabled: "{{ item.enabled | default(true) }}" when: - item.state | default('unknown') != 'absent' # NOTE(cloudnull): The systemd module is not used to start the # mount because we don't want to inavertently # "restart" a mount unnecessarily. To ensure # we're able to load new options without # requiring a mount restart the systemctl # command is used with the "reload-or-restart" # argument. Additionally this command escapes # the name of the mount. If this command fails # the task will be rescued and the regular # systemd module will be attempted before # failing the task run. - name: Set the state of the mount # noqa: command-instead-of-module ansible.builtin.command: "systemctl {{ systemd_mount_states[item.state] }} {{ mount_service_name }}" changed_when: false ignore_errors: true register: set_mount_state_command when: - item.state is defined - name: Set the state of the mount (fallback) ansible.builtin.systemd: name: "{{ mount_service_name }}" state: "{{ item.state }}" when: - set_mount_state_command is failed - name: Unload mount(s) ansible.builtin.systemd: daemon_reload: true name: "{{ mount_service_name }}" enabled: false no_block: true when: - item.state | default('unknown') == 'absent' notify: Remove mount |