File tree Expand file tree Collapse file tree 1 file changed +27
-12
lines changed Expand file tree Collapse file tree 1 file changed +27
-12
lines changed Original file line number Diff line number Diff line change @@ -29,18 +29,33 @@ function waitfor_boot_finished {
2929}
3030
3131function install_packages {
32- # Setup Ansible on host VM
33- apt-get update && sudo apt-get install software-properties-common -y
34- add-apt-repository --yes --update ppa:ansible/ansible && sudo apt-get install ansible -y
35- ansible-galaxy collection install community.general
36-
37- # Update apt and install required packages
38- apt-get update
39- apt-get install -y \
40- gdisk \
41- e2fsprogs \
42- debootstrap \
43- nvme-cli
32+ trap ' echo "Error on line $LINENO"' ERR
33+
34+ retry () {
35+ local retries=3
36+ local count=1
37+ until " $@ " ; do
38+ [[ $count -eq $retries ]] && return 1
39+ echo " Command failed, attempt $count /$retries "
40+ (( count++ ))
41+ sleep 10
42+ done
43+ return 0
44+ }
45+
46+ retry apt-get update
47+ retry apt-get install -y software-properties-common
48+ retry add-apt-repository --yes --update ppa:ansible/ansible
49+
50+ retry apt-get install -y ansible
51+ if ! command -v ansible & > /dev/null; then
52+ echo " Ansible installation failed"
53+ return 1
54+ fi
55+
56+ retry ansible-galaxy collection install community.general
57+ retry apt-get update
58+ retry apt-get install -y gdisk e2fsprogs debootstrap nvme-cli
4459}
4560
4661# Partition the new root EBS volume
You can’t perform that action at this time.
0 commit comments