| 1 |
--- |
| 2 |
- name: Initialize the disk with the default partition style (check mode) |
| 3 |
win_initialize_disk: |
| 4 |
disk_number: 1 |
| 5 |
register: default_part_style_check |
| 6 |
check_mode: yes |
| 7 |
|
| 8 |
- name: Get result of default initialization (check mode) |
| 9 |
ansible.windows.win_command: powershell.exe "if ( (Get-Disk -Number 1).PartitionStyle -eq 'RAW' ) {'true'} else {'false'}" |
| 10 |
register: default_part_style_actual_check |
| 11 |
|
| 12 |
- name: assert default initialization (check mode) |
| 13 |
assert: |
| 14 |
that: |
| 15 |
- default_part_style_check is changed |
| 16 |
- default_part_style_actual_check.stdout == 'true\r\n' |
| 17 |
|
| 18 |
- name: Initialize the disk with the default partition style |
| 19 |
win_initialize_disk: |
| 20 |
disk_number: 1 |
| 21 |
register: default_part_style |
| 22 |
|
| 23 |
- name: Get result of default initialization |
| 24 |
ansible.windows.win_command: powershell.exe "if ( (Get-Disk -Number 1).PartitionStyle -eq 'GPT' ) {'true'} else {'false'}" |
| 25 |
register: default_part_style_actual |
| 26 |
|
| 27 |
- name: assert default initialization |
| 28 |
assert: |
| 29 |
that: |
| 30 |
- default_part_style is changed |
| 31 |
- default_part_style_actual.stdout == 'true\r\n' |
| 32 |
|
| 33 |
- name: Initialize the disk with the default partition style (idempotence) |
| 34 |
win_initialize_disk: |
| 35 |
disk_number: 1 |
| 36 |
register: default_part_style_idempotence |
| 37 |
|
| 38 |
- name: Get result of default initialization (idempotence) |
| 39 |
ansible.windows.win_command: powershell.exe "if ( (Get-Disk -Number 1).PartitionStyle -eq 'GPT' ) {'true'} else {'false'}" |
| 40 |
register: default_part_style_actual_idempotence |
| 41 |
|
| 42 |
- name: assert default initialization (idempotence) |
| 43 |
assert: |
| 44 |
that: |
| 45 |
- not default_part_style_idempotence is changed |
| 46 |
- default_part_style_actual_idempotence.stdout == 'true\r\n' |
| 47 |
|
| 48 |
- name: Partition style change without force fails |
| 49 |
win_initialize_disk: |
| 50 |
disk_number: 1 |
| 51 |
style: mbr |
| 52 |
register: change_part_style |
| 53 |
ignore_errors: True |
| 54 |
|
| 55 |
- name: assert failed partition style change |
| 56 |
assert: |
| 57 |
that: |
| 58 |
- change_part_style is failed |
| 59 |
|
| 60 |
- name: Partition style change with force is successful (check mode) |
| 61 |
win_initialize_disk: |
| 62 |
disk_number: 1 |
| 63 |
style: mbr |
| 64 |
force: yes |
| 65 |
register: change_part_style_forced_check |
| 66 |
check_mode: yes |
| 67 |
|
| 68 |
- name: Get result of forced initialization (check mode) |
| 69 |
ansible.windows.win_command: powershell.exe "if ( (Get-Disk -Number 1).PartitionStyle -eq 'GPT' ) {'true'} else {'false'}" |
| 70 |
register: change_part_style_forced_actual_check |
| 71 |
|
| 72 |
- name: assert forced initialization (check mode) |
| 73 |
assert: |
| 74 |
that: |
| 75 |
- change_part_style_forced_check is changed |
| 76 |
- change_part_style_forced_actual_check.stdout == 'true\r\n' |
| 77 |
|
| 78 |
- name: Partition style change with force is successful |
| 79 |
win_initialize_disk: |
| 80 |
disk_number: 1 |
| 81 |
style: mbr |
| 82 |
force: yes |
| 83 |
register: change_part_style_forced |
| 84 |
|
| 85 |
- name: Get result of forced initialization |
| 86 |
ansible.windows.win_command: powershell.exe "if ( (Get-Disk -Number 1).PartitionStyle -eq 'MBR' ) {'true'} else {'false'}" |
| 87 |
register: change_part_style_forced_actual |
| 88 |
|
| 89 |
- name: assert forced initialization |
| 90 |
assert: |
| 91 |
that: |
| 92 |
- change_part_style_forced is changed |
| 93 |
- change_part_style_forced_actual.stdout == 'true\r\n' |
| 94 |
|
| 95 |
- name: Unknown disk number fails |
| 96 |
win_initialize_disk: |
| 97 |
disk_number: 3 |
| 98 |
register: unknown_disk_number |
| 99 |
ignore_errors: True |
| 100 |
|
| 101 |
- name: assert unknown disk number fails |
| 102 |
assert: |
| 103 |
that: |
| 104 |
- unknown_disk_number is failed |