-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split the function of disable BitLocerk service and decrypt volume
Signed-off-by: Yanan Shen <yanans@vmware.com>
- Loading branch information
Showing
4 changed files
with
58 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright 2023 VMware, Inc. | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
--- | ||
# Decrypt the BitLocker encrypted volumes | ||
# Parameters: | ||
# decrypt_wait_time: the time in seconds to wait for the volume decryption. | ||
# | ||
- name: "Get encrypted volumes in guest OS" | ||
include_tasks: win_get_bitlocker_volume.yml | ||
|
||
- name: "Decrypt the BitLocker volumes" | ||
when: bitlocker_volume_list | length > 0 | ||
block: | ||
- name: "Initialize the decryption wait time" | ||
ansible.builtin.set_fact: | ||
decrypt_wait_time: 900 | ||
when: decrypt_wait_time is undefined or not decrypt_wait_time | ||
|
||
- name: "Decrypt the BitLocker volumes" | ||
include_tasks: win_execute_cmd.yml | ||
vars: | ||
win_powershell_cmd: >- | ||
$BLV = Get-BitLockerVolume; | ||
Disable-BitLocker -MountPoint $BLV | ||
- name: "Check if Decryption is completed" | ||
ansible.windows.win_shell: "(Get-BitLockerVolume | Where-Object { $_.EncryptionPercentage -GT 0 } | measure).Count" | ||
register: decrypt_volume_result | ||
delegate_to: "{{ vm_guest_ip }}" | ||
ignore_errors: true | ||
until: | ||
- decrypt_volume_result.stdout_lines is defined | ||
- decrypt_volume_result.stdout_lines | length != 0 | ||
- decrypt_volume_result.stdout_lines[0] | int == 0 | ||
retries: "{{ (decrypt_wait_time | int / 60) | int }}" | ||
delay: 60 | ||
|
||
- name: "Volume decryption failed" | ||
ansible.builtin.fail: | ||
msg: "Failed to decrypt the OS volumes in {{ decrypt_wait_time }} seconds." | ||
when: | ||
- decrypt_volume_result.stdout_lines is defined | ||
- decrypt_volume_result.stdout_lines | length != 0 | ||
- decrypt_volume_result.stdout_lines[0] | int > 0 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters