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 2020# Parse options
2121OPTIND=1
2222
23- while getopts " :n:p:c:f:i:b:" opt; do
23+ while getopts " :n:p:c:f:i:b:a: " opt; do
2424 case ${opt} in
2525 n) NAME=$OPTARG ;;
2626 p) POOL=$OPTARG ;;
2727 c) CAPACITY=$OPTARG ;;
2828 f) FORMAT=$OPTARG ;;
2929 i) IMAGE=$OPTARG ;;
3030 b) BACKING_IMAGE=$OPTARG ;;
31+ a) CHECK=$OPTARG ;;
3132 \? )
3233 echo " Invalid option: -$OPTARG " >&2
3334 exit 1
@@ -66,6 +67,12 @@ elif ! echo "$output" | grep 'Storage volume not found' >/dev/null 2>&1; then
6667 exit $result
6768fi
6869
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+
6976# Create the volume.
7077if [[ -n $BACKING_IMAGE ]]; then
7178 if [[ " $FORMAT " != ' qcow2' ]]; then
Original file line number Diff line number Diff line change 2525 {% elif item.backing_image is defined %}
2626 -b {{ item.backing_image }}
2727 {% endif %}
28+ -a {{ ansible_check_mode }}
2829 with_items : " {{ volumes }}"
2930 when : item.device | default(libvirt_volume_default_device) == 'disk'
3031 environment : " {{ libvirt_vm_script_env }}"
3132 register : volume_result
3233 changed_when :
3334 - volume_result is success
3435 - (volume_result.stdout | from_json).changed | default(True)
36+ check_mode : False
3537 become : true
You can’t perform that action at this time.
0 commit comments