From d14557e7638e9c1a00f0daa58fad490aefe712fd Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Mon, 7 Nov 2022 18:03:12 +0100 Subject: [PATCH] Cleanup the tasks so that we can use UUIDs. --- tasks/additional_disks.yml | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/tasks/additional_disks.yml b/tasks/additional_disks.yml index 471771f..9c596f2 100644 --- a/tasks/additional_disks.yml +++ b/tasks/additional_disks.yml @@ -1,13 +1,21 @@ --- - block: - name: Install the NFS client utilities when we are going to mount a NFS file system - apt: pkg=nfs-common state=present update_cache=yes cache_valid_time=1800 - with_items: '{{ disks_and_mountpoints_list }}' + ansible.builtin.apt: + pkg: nfs-common + state: present + update_cache: true + cache_valid_time: 1800 + loop: '{{ disks_and_mountpoints_list }}' when: item.fstype == 'nfs' - name: Install the NFS 4 acl tools if we are going to mount a NFS file system - apt: pkg=nfs4-acl-tools state=present update_cache=yes cache_valid_time=1800 - with_items: '{{ disks_and_mountpoints_list }}' + ansible.builtin.apt: + pkg: nfs4-acl-tools + state: present + update_cache: true + cache_valid_time: 1800 + loop: '{{ disks_and_mountpoints_list }}' when: item.fstype == 'nfs' when: ansible_distribution_file_variety == "Debian" @@ -15,15 +23,23 @@ - block: - name: Create a file system on the new disks - filesystem: dev=/dev/{{ item.device }} fstype={{ item.fstype }} force=no - with_items: '{{ disks_and_mountpoints_list }}' + ansible.builtin.filesystem: + dev: '{{ item.root_device | default('/dev/') }}{{ item.device }}' + fstype: '{{ item.fstype }}' + force: false + loop: '{{ disks_and_mountpoints_list }}' when: - additional_disks - item.create_filesystem - item.fstype != 'nfs' - name: Manage the additional file systems - mount: name={{ item.mountpoint }} src={{ item.root_device | default('/dev') }}/{{ item.device }} fstype={{ item.fstype }} opts={{ item.opts }} state={{ item.state }} - with_items: '{{ disks_and_mountpoints_list }}' + ansible.posix.mount: + name: '{{ item.mountpoint }}' + src: '{{ item.root_device | default('/dev/') }}{{ item.device }}' + fstype: '{{ item.fstype }}' + opts: '{{ item.opts }}' + state: '{{ item.state }}' + loop: '{{ disks_and_mountpoints_list }}' tags: [ 'data_disk', 'mountpoint' ]