Update main.yml

This commit is contained in:
Mandar Kulkarni 2021-06-30 15:57:39 -07:00
parent 957a7420ca
commit 6d51660be4

View file

@ -125,6 +125,7 @@
- unmount_result['changed'] - unmount_result['changed']
- not dest_stat['stat']['exists'] - not dest_stat['stat']['exists']
when: ansible_system in ('FreeBSD', 'Linux') when: ansible_system in ('FreeBSD', 'Linux')
- name: Block to test remounted option - name: Block to test remounted option
block: block:
- name: Create fstab record for the first swap file - name: Create fstab record for the first swap file
@ -135,6 +136,8 @@
fstype: swap fstype: swap
state: present state: present
register: swap1_created register: swap1_created
when: ansible_system in ('Linux')
- name: Try to create fstab record for the first swap file again - name: Try to create fstab record for the first swap file again
mount: mount:
name: none name: none
@ -143,11 +146,15 @@
fstype: swap fstype: swap
state: present state: present
register: swap1_created_again register: swap1_created_again
when: ansible_system in ('Linux')
- name: Check that we created the swap1 record - name: Check that we created the swap1 record
assert: assert:
that: that:
- swap1_created['changed'] - swap1_created['changed']
- not swap1_created_again['changed'] - not swap1_created_again['changed']
when: ansible_system in ('Linux')
- name: Create fstab record for the second swap file - name: Create fstab record for the second swap file
mount: mount:
name: none name: none
@ -156,6 +163,8 @@
fstype: swap fstype: swap
state: present state: present
register: swap2_created register: swap2_created
when: ansible_system in ('Linux')
- name: Try to create fstab record for the second swap file again - name: Try to create fstab record for the second swap file again
mount: mount:
name: none name: none
@ -164,51 +173,69 @@
fstype: swap fstype: swap
state: present state: present
register: swap2_created_again register: swap2_created_again
when: ansible_system in ('Linux')
- name: Check that we created the swap2 record - name: Check that we created the swap2 record
assert: assert:
that: that:
- swap2_created['changed'] - swap2_created['changed']
- not swap2_created_again['changed'] - not swap2_created_again['changed']
when: ansible_system in ('Linux')
- name: Remove the fstab record for the first swap file - name: Remove the fstab record for the first swap file
mount: mount:
name: none name: none
src: /tmp/swap1 src: /tmp/swap1
state: absent state: absent
register: swap1_removed register: swap1_removed
when: ansible_system in ('Linux')
- name: Try to remove the fstab record for the first swap file again - name: Try to remove the fstab record for the first swap file again
mount: mount:
name: none name: none
src: /tmp/swap1 src: /tmp/swap1
state: absent state: absent
register: swap1_removed_again register: swap1_removed_again
when: ansible_system in ('Linux')
- name: Check that we removed the swap1 record - name: Check that we removed the swap1 record
assert: assert:
that: that:
- swap1_removed['changed'] - swap1_removed['changed']
- not swap1_removed_again['changed'] - not swap1_removed_again['changed']
when: ansible_system in ('Linux')
- name: Remove the fstab record for the second swap file - name: Remove the fstab record for the second swap file
mount: mount:
name: none name: none
src: /tmp/swap2 src: /tmp/swap2
state: absent state: absent
register: swap2_removed register: swap2_removed
when: ansible_system in ('Linux')
- name: Try to remove the fstab record for the second swap file again - name: Try to remove the fstab record for the second swap file again
mount: mount:
name: none name: none
src: /tmp/swap2 src: /tmp/swap2
state: absent state: absent
register: swap2_removed_again register: swap2_removed_again
when: ansible_system in ('Linux')
- name: Check that we removed the swap2 record - name: Check that we removed the swap2 record
assert: assert:
that: that:
- swap2_removed['changed'] - swap2_removed['changed']
- not swap2_removed_again['changed'] - not swap2_removed_again['changed']
when: ansible_system in ('Linux')
- name: Create fstab record with missing last two fields - name: Create fstab record with missing last two fields
copy: copy:
dest: /etc/fstab dest: /etc/fstab
content: '//nas/photo /home/jik/pictures cifs defaults,credentials=/etc/security/nas.creds,uid=jik,gid=users,forceuid,forcegid,noserverino,_netdev content: '//nas/photo /home/jik/pictures cifs defaults,credentials=/etc/security/nas.creds,uid=jik,gid=users,forceuid,forcegid,noserverino,_netdev
' '
when: ansible_system in ('Linux')
- name: Try to change the fstab record with the missing last two fields - name: Try to change the fstab record with the missing last two fields
mount: mount:
src: //nas/photo src: //nas/photo
@ -217,9 +244,13 @@
opts: defaults,credentials=/etc/security/nas.creds,uid=jik,gid=users,forceuid,forcegid,noserverino,_netdev,x-systemd.mount-timeout=0 opts: defaults,credentials=/etc/security/nas.creds,uid=jik,gid=users,forceuid,forcegid,noserverino,_netdev,x-systemd.mount-timeout=0
state: present state: present
register: optional_fields_update register: optional_fields_update
when: ansible_system in ('Linux')
- name: Get the content of the fstab file - name: Get the content of the fstab file
shell: cat /etc/fstab shell: cat /etc/fstab
register: optional_fields_content register: optional_fields_content
when: ansible_system in ('Linux')
- name: Check if the line containing the missing last two fields was changed - name: Check if the line containing the missing last two fields was changed
assert: assert:
that: that:
@ -227,6 +258,7 @@
- ''' 0 0'' in optional_fields_content.stdout' - ''' 0 0'' in optional_fields_content.stdout'
- 1 == optional_fields_content.stdout_lines | length - 1 == optional_fields_content.stdout_lines | length
when: ansible_system in ('Linux') when: ansible_system in ('Linux')
- name: Create empty file - name: Create empty file
command: dd if=/dev/zero of=/tmp/myfs.img bs=1048576 count=20 command: dd if=/dev/zero of=/tmp/myfs.img bs=1048576 count=20
- name: Format FS - name: Format FS
@ -329,6 +361,7 @@
mount: mount:
path: /tmp/myfs path: /tmp/myfs
state: absent state: absent
when: ansible_system in ('Linux')
- name: Remove the test FS - name: Remove the test FS
file: file: