File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 20
20
# Parse options
21
21
OPTIND=1
22
22
23
- while getopts " :n:p:c:f:i:b:" opt; do
23
+ while getopts " :n:p:c:f:i:b:a: " opt; do
24
24
case ${opt} in
25
25
n) NAME=$OPTARG ;;
26
26
p) POOL=$OPTARG ;;
27
27
c) CAPACITY=$OPTARG ;;
28
28
f) FORMAT=$OPTARG ;;
29
29
i) IMAGE=$OPTARG ;;
30
30
b) BACKING_IMAGE=$OPTARG ;;
31
+ a) CHECK=$OPTARG ;;
31
32
\? )
32
33
echo " Invalid option: -$OPTARG " >&2
33
34
exit 1
@@ -66,6 +67,12 @@ elif ! echo "$output" | grep 'Storage volume not found' >/dev/null 2>&1; then
66
67
exit $result
67
68
fi
68
69
70
+ # Stop here in check mode, there will be a change
71
+ if [[ $CHECK = " True" ]]; then
72
+ echo ' {"changed": true}'
73
+ exit 0
74
+ fi
75
+
69
76
# Create the volume.
70
77
if [[ -n $BACKING_IMAGE ]]; then
71
78
if [[ " $FORMAT " != ' qcow2' ]]; then
Original file line number Diff line number Diff line change 25
25
{% elif item.backing_image is defined %}
26
26
-b {{ item.backing_image }}
27
27
{% endif %}
28
+ -a {{ ansible_check_mode }}
28
29
with_items : " {{ volumes }}"
29
30
when : item.device | default(libvirt_volume_default_device) == 'disk'
30
31
environment : " {{ libvirt_vm_script_env }}"
31
32
register : volume_result
32
33
changed_when :
33
34
- volume_result is success
34
35
- (volume_result.stdout | from_json).changed | default(True)
36
+ check_mode : False
35
37
become : true
You can’t perform that action at this time.
0 commit comments