# 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 loop device image shell: | mkdir -p {{ loopback_image | dirname }} truncate -s {{ loopback_image_size }} {{ loopback_image }} - name: Create loop device shell: | mknod {{ loopback_device }} b $(grep loop /proc/devices | cut -c3) {{ loopback_device | regex_search('[0-9]+') }} - name: Create loop-setup systemd unit template: src: files/loop-setup.service dest: /etc/systemd/system/loop-setup.service notify: - Systemd reload - name: Systemd reload shell: systemctl daemon-reload - name: Configure loop-setup systemd unit service: name: loop-setup enabled: yes state: started notify: - Systemd reload - Restart loop-setup - name: Check {{ loopback_device }} is attached shell: | losetup | grep -i {{ loopback_device }} ...