-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a630bfb
Showing
169 changed files
with
2,876 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
**/*.img | ||
**/*.qcow2 | ||
**/.env_local.sh | ||
**/.env.yml | ||
|
||
# Created by .ignore support plugin (hsz.mobi) | ||
.idea | ||
.project | ||
.settings | ||
**/.DS_Store | ||
**/venv | ||
# | ||
**/*.retry | ||
**/json2hcl | ||
|
||
# | ||
**/tmp | ||
**/.tmp | ||
**/*.tar.gz | ||
|
||
# | ||
roles/utils/files/markdown/md-to-toc/build | ||
roles/utils/files/markdown/md-to-toc/dist | ||
|
||
# keys | ||
#**/keys | ||
#**/keys/* | ||
!roles/_local/access/templates/keys | ||
!roles/_local/access/files/keys | ||
!roles/_local/utils/tasks/files/keys | ||
|
||
#roles/utils/files/docker/ | ||
|
||
# py | ||
/roles/utils/files/markdown/md_toc/md_toc.egg-info/ | ||
/roles/utils/files/markdown/md-to-toc/md_to_toc.egg-info | ||
|
||
*.pyc | ||
|
||
|
||
# | ||
**/.kitchen | ||
**/terraform.tfstate.d | ||
|
||
## terrform ignore | ||
|
||
**/.terraform | ||
**/planfile.bin | ||
**/*.tf.swp | ||
**/terraform.tfvars | ||
**/terraform.tfstate | ||
**/terraform.tfstate.backup | ||
|
||
# | ||
roles/jenkins-agent/molecule/roles/* | ||
!roles/jenkins-agent/molecule/roles/.gitkeep | ||
|
||
**/.virtualenv | ||
|
||
/Postgress/postgresDBSamples/ | ||
/k8s/asus2680v3/ssl-helm/files/ | ||
|
||
# | ||
**/cloud-init-*-default.yml | ||
**/prepare-virt-customize.sh |
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,34 @@ | ||
#!/bin/bash | ||
|
||
source ./.envs/.env.sh $@ | ||
|
||
if [ ! -z "${DISPLAY_DEBUG}" ]; then | ||
debug_cf | ||
fi | ||
|
||
if [ ! -z "${DISPLAY_USAGE}" ]; then | ||
cat << EOF | ||
Prepare os | ||
- install dependens | ||
EOF | ||
fi | ||
|
||
echo "prepare-pve:" | ||
echo " CLOUD_INIT_TEMPLATE_NAME = ${CLOUD_INIT_TEMPLATE_NAME}" | ||
echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" | ||
|
||
# prepare, install libguestfs-tools | ||
if dpkg -l | grep libguestfs-tools; then | ||
echo "libguestfs-tools exists..." | ||
else | ||
echo not found | ||
# All commands will be executed on a Proxmox host !!! | ||
sudo apt update -y && sudo apt install libguestfs-tools -y | ||
fi | ||
if dpkg -l | grep wget; then | ||
echo "wget exists..." | ||
else | ||
echo "not found" | ||
# All commands will be executed on a Proxmox host !!! | ||
sudo apt update -y && sudo apt install wget -y | ||
fi |
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,59 @@ | ||
#!/bin/bash | ||
set -e # exit on first error | ||
source ./.envs/.env.sh $@ | ||
|
||
if [ ! -z "${DISPLAY_DEBUG}" ]; then | ||
debug_cf | ||
fi | ||
|
||
if [ ! -z "${DISPLAY_USAGE}" ]; then | ||
cat << EOF | ||
Prepare pve | ||
- check vm | ||
- check templates | ||
-ca|--copy-all) | ||
PV_TEMPLATES_COPY_ALL="all" | ||
-cf-name|--cloud-init-template-name : set env CLOUD_INIT_TEMPLATE_NAME | ||
-img-base|--image-virt-base-name : set env IMAGE_NAME | ||
-img-custom|--image-virt-customize-name : set env IMAGE_VIRT_CUSTOMIZE_NAME | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
if [[ -z ${PV_TEMPLATES_COPY_ALL} ]]; then | ||
export PV_TEMPLATES_COPY_ALL="" | ||
fi | ||
|
||
echo "Prepare pve:" | ||
echo " CLOUD_INIT_TEMPLATE_NAME = ${CLOUD_INIT_TEMPLATE_NAME}" | ||
echo " PV_TEMPLATES_COPY_ALL = ${PV_TEMPLATES_COPY_ALL}" | ||
echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" | ||
|
||
if [[ ${PV_TEMPLATES_COPY_ALL} == "all" ]]; then | ||
echo -e "\nCopy all templates from folder" | ||
cp -f ./.templates/*.yml "${PV_STORAGE_SNIPPETS_PATH}" | ||
exit 0 | ||
fi | ||
|
||
echo -e "\nCopy templates to local ${PV_STORAGE_SNIPPETS_PATH} ..." | ||
|
||
# check | ||
if [[ -z ${CLOUD_INIT_TEMPLATE_NAME} ]]; then | ||
echo -e "\nPlease set CLOUD_INIT_TEMPLATE_NAME via -cf-name|--cloud-init-template-name options\n\n" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -f ./.templates/${CLOUD_INIT_TEMPLATE_NAME} ]]; then | ||
echo -e "\nTemplates ./.templates/${CLOUD_INIT_TEMPLATE_NAME} not exists" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -f ${PV_STORAGE_SNIPPETS_PATH}${CLOUD_INIT_TEMPLATE_NAME} ]]; then | ||
cp ./.templates/${CLOUD_INIT_TEMPLATE_NAME} /var/lib/vz/snippets/ | ||
else | ||
echo -e "\nCLOUD_INIT_TEMPLATE_NAME is: [${CLOUD_INIT_TEMPLATE_NAME}], ${PV_STORAGE_SNIPPETS_PATH}${CLOUD_INIT_TEMPLATE_NAME} - exit ..." | ||
exit 0 | ||
fi |
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,81 @@ | ||
#!/bin/bash | ||
|
||
source ./.envs/.env.sh $@ | ||
|
||
if [ ! -z "${DISPLAY_DEBUG}" ]; then | ||
debug_cf | ||
fi | ||
|
||
#----- celan -------- | ||
echo -e "... Info ..." | ||
echo -e "VM_ID $VM_ID" | ||
|
||
echo -e "... Create ..." | ||
# ./qm-clone-vm-multi.sh --size 15 --net 1 --start 1 --vm 1 2 3 4 | ||
|
||
usage(){ echo 'usage: ...'; exit 2; } | ||
while [ "$#" -gt 1 ]; do | ||
case $1 in | ||
--size) VM_SIZE=$2; shift 2;; | ||
--net) VM_SET_DEFAULT_NET=$2; shift 2;; | ||
--start) VM_START=$2; shift 2;; | ||
--vm) | ||
shift | ||
while [ "$#" -gt 0 ]; do | ||
case $1 in | ||
--vm*) break;; | ||
*) vm+=("$1"); shift;; | ||
esac | ||
done | ||
;; | ||
*) usage ;; | ||
esac | ||
done | ||
[ "$#" -gt 0 ] && usage | ||
|
||
echo "... will increace disk size to +${VM_SIZE}Gb" | ||
|
||
for p in "${vm[@]}"; do | ||
echo "... will create next vm -- ${VM_CLONE_ID}$p" | ||
done | ||
echo "... will vm set default net: ${VM_SET_DEFAULT_NET}" | ||
echo "... will vm start 0/1: ${VM_START}" | ||
|
||
# | ||
for VM_CLONE_ID_INC in "${vm[@]}"; do | ||
|
||
echo "${VM_CLONE_ID}${VM_CLONE_ID_INC}" | ||
qm clone ${VM_ID} "${VM_CLONE_ID}${VM_CLONE_ID_INC}" --full --name ${VM_CLONE_NAME} > /dev/null | ||
|
||
echo -e "... Setup, copy cloud-init template to local folder /var/lib/vz/snippets/ ..." | ||
echo -e "... qm set ${VM_CLONE_ID}${VM_CLONE_ID_INC} --cicustom user=local:snippets/${VM_ID}-${OS_DISTR_NAME}${CLOUD_INIT_EXTRA:--}cloud-init.yml" | ||
qm set ${VM_CLONE_ID}${VM_CLONE_ID_INC} --cicustom "user=local:snippets/${VM_ID}-${OS_DISTR_NAME}${CLOUD_INIT_EXTRA:--}cloud-init.yml" | ||
qm set ${VM_CLONE_ID}${VM_CLONE_ID_INC} --ipconfig0 "${VM_IPCONFIG0}" | ||
|
||
# run first time, no image provide | ||
if [ -z "$VM_SIZE" ]; then | ||
echo -e "... skip resize..." | ||
else | ||
echo -e "... resize vm to ${1}GB..." | ||
echo -e "... qm resize ${VM_CLONE_ID}${VM_CLONE_ID_INC} scsi0 \"+${VM_SIZE}G\"..." | ||
sleep 5 | ||
qm resize "${VM_CLONE_ID}${VM_CLONE_ID_INC}" scsi0 "+${VM_SIZE}G" | ||
fi | ||
|
||
#echo -e "... qm set "${VM_CLONE_ID}${VM_CLONE_ID_INC}" --ipconfig0 \"ip=192.168.0.16${VM_CLONE_ID_INC}/24,gw=192.168.0.189\"" | ||
echo -e "... qm set "${VM_CLONE_ID}${VM_CLONE_ID_INC}" --ipconfig0 ${VM_IPCONFIG0}" | ||
if [ -z "$VM_SET_DEFAULT_NET" ]; then | ||
echo -e "... skip net default net..." | ||
else | ||
#qm set "${VM_CLONE_ID}${VM_CLONE_ID_INC}" --ipconfig0 "ip=192.168.0.16${VM_CLONE_ID_INC}/24,gw=192.168.0.189" | ||
qm set "${VM_CLONE_ID}${VM_CLONE_ID_INC}" --ipconfig0 "${VM_IPCONFIG0}" | ||
fi | ||
|
||
echo -e "... qm start "${VM_CLONE_ID}${VM_CLONE_ID_INC}"" | ||
if [ -z "$VM_START" ]; then | ||
echo -e "...skip start..." | ||
else | ||
qm start "${VM_CLONE_ID}${VM_CLONE_ID_INC}" | ||
fi | ||
|
||
done |
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,53 @@ | ||
#!/bin/bash | ||
set -e # exit on first error | ||
source ./.envs/.env.sh $@ | ||
|
||
if [ ! -z "${DISPLAY_DEBUG}" ]; then | ||
debug_cf | ||
fi | ||
|
||
if [ ! -z "${DISPLAY_USAGE}" ]; then | ||
cat << EOF | ||
usage: ...\n ./qm-clone-vm.sh --size 15 --net 1 --start 1'; | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
echo -e "... Check, that cloud-init template in local folder, like /var/lib/vz/snippets/ and exist of the file" | ||
./prepare-pve.sh $@ | ||
|
||
echo -e "... clone VM ${VM_ID} to VM_CLONE_ID ${VM_CLONE_ID}" | ||
if [ ! -z "${DISPLAY_DEBUG}" ]; then | ||
echo -e "... qm clone ${VM_ID} ${VM_CLONE_ID} --full --name ${VM_CLONE_NAME}" | ||
qm clone "${VM_ID}" "${VM_CLONE_ID}" --full --name ${VM_CLONE_NAME} | ||
else | ||
echo -e "... qm clone ${VM_ID} ${VM_CLONE_ID} --full --name ${VM_CLONE_NAME} > /dev/null" | ||
qm clone "${VM_ID}" "${VM_CLONE_ID}" --full --name ${VM_CLONE_NAME} > /dev/null | ||
fi | ||
|
||
echo -e "... qm set ${VM_ID} --cicustom user=local:snippets/${CLOUD_INIT_TEMPLATE_NAME}" | ||
qm set ${VM_ID} --cicustom "user=local:snippets/${CLOUD_INIT_TEMPLATE_NAME}" | ||
qm set ${VM_ID} --ipconfig0 "${VM_IPCONFIG0}" | ||
|
||
if [ -z "$VM_DISK_PLUS" ]; then | ||
echo -e "... skip resize..." | ||
else | ||
echo -e "... resize vm to ${VM_DISK_PLUS}GB..." | ||
echo -e "... qm resize ${VM_ID} scsi0 \"+${VM_DISK_PLUS}G\"..." | ||
sleep 5 | ||
qm resize ${VM_ID} scsi0 "+${VM_DISK_PLUS}G" | ||
fi | ||
|
||
if [ -z "$VM_KEEP_DEFAULT_NET" ]; then | ||
qm set "${VM_CLONE_ID}" --ipconfig0 "${VM_IPCONFIG0}" | ||
else | ||
echo -e "... skip set default net" | ||
fi | ||
|
||
echo -e "... qm start ${VM_CLONE_ID} (VM_START is $VM_START)" | ||
|
||
if [ -z $VM_START ]; then | ||
echo -e "...skip start..." | ||
else | ||
qm start "${VM_CLONE_ID}" | ||
fi |
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,34 @@ | ||
#!/bin/bash | ||
|
||
source ./.envs/.env.sh $@ | ||
|
||
if [ ! -z "${DISPLAY_DEBUG}" ]; then | ||
debug_cf | ||
fi | ||
|
||
echo -e "... Info ..." | ||
echo -e "VM_ID $VM_ID" | ||
echo -e "VM_CLONE_ID $VM_CLONE_ID" | ||
|
||
echo -e "... Create ..." | ||
qm clone ${VM_ID} ${VM_CLONE_ID} --full --name ${VM_CLONE_NAME} > /dev/null | ||
|
||
echo -e "... Setup, copy cloud-init template to local folder /var/lib/vz/snippets/ ..." | ||
echo -e "... qm set ${VM_CLONE_ID} --cicustom user=local:snippets/${VM_ID}-${OS_DISTR_NAME}${CLOUD_INIT_EXTRA:--}cloud-init.yml" | ||
qm set ${VM_CLONE_ID} --cicustom "user=local:snippets/${VM_ID}-${OS_DISTR_NAME}${CLOUD_INIT_EXTRA:--}cloud-init.yml" | ||
qm set ${VM_CLONE_ID} --ipconfig0 "${VM_IPCONFIG0}" | ||
|
||
# run first time, no image provide | ||
if [ -z "$1" ]; then | ||
echo -e "... skip resize..." | ||
else | ||
echo -e "... resize vm to ${1}GB..." | ||
echo -e "... qm resize ${VM_CLONE_ID} scsi0 \"+${1}G\"..." | ||
sleep 5 | ||
qm resize ${VM_CLONE_ID} scsi0 "+${1}G" | ||
fi | ||
|
||
echo -e "Example:" | ||
echo -e "... qm set ${VM_CLONE_ID} --ipconfig0 \"ip=192.168.0.161/24,gw=192.168.0.189\"" | ||
#qm start ${VM_CLONE_ID} | ||
echo -e "... qm start ${VM_CLONE_ID}" |
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,66 @@ | ||
#!/bin/bash | ||
set -e # exit on first error | ||
source ./.envs/.env.sh $@ | ||
|
||
if [ ! -z "${DISPLAY_DEBUG}" ]; then | ||
debug_cf | ||
fi | ||
|
||
if [ ! -z "${DISPLAY_USAGE}" ]; then | ||
cat << EOF | ||
Clone VM based on cloud image | ||
-vm-start|--vm-start | ||
-vm-disk|--vm-disk-plus | ||
-img-custom|--image-virt-customize-name IMAGE_VIRT_CUSTOMIZE_NAME | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
echo -e "... Check, that cloud-init template in local folder /var/lib/vz/snippets/ ..." | ||
./prepare-pve.sh $@ | ||
# ... | ||
|
||
echo -e "... Create ..." | ||
# Create RAW VM templates, without disk | ||
echo " qm create ${VM_ID} --name ${VM_NAME} --memory ${VM_MEM} ${VM_SETTINGS}" | ||
qm create ${VM_ID} --name ${VM_NAME} --memory ${VM_MEM} ${VM_SETTINGS} | ||
|
||
echo -e "\nqm importdisk disk ..." | ||
echo -e "\nqm importdisk ${VM_ID} ${IMAGE_VIRT_CUSTOMIZE_PATH}${IMAGE_VIRT_CUSTOMIZE_NAME} ${PV_STORAGE_ID}" | ||
qm importdisk ${VM_ID} ${IMAGE_VIRT_CUSTOMIZE_PATH}${IMAGE_VIRT_CUSTOMIZE_NAME} ${PV_STORAGE_ID} > /dev/null | ||
|
||
# Attache on exist VM, old syntax is buggy | ||
# unused0:local-lvm:vm-9031-disk-0 | ||
if [ "$PV_STORAGE_TYPE" == "lvm" ]; then | ||
echo "import LVM disk" | ||
qm set ${VM_ID} --scsihw virtio-scsi-pci --scsi0 ${PV_STORAGE_ID}:vm-${VM_ID}-disk-0 # no RAW in LVM | ||
else | ||
echo "import RAW disk" | ||
qm set ${VM_ID} --scsihw virtio-scsi-pci --scsi0 ${PV_STORAGE_ID}:${VM_ID}/vm-${VM_ID}-disk-0.raw # no RAW in LVM | ||
fi | ||
|
||
# Connect Cloud-init disk | ||
qm set ${VM_ID} --ide2 ${PV_STORAGE_ID}:cloudinit | ||
# Make boot from scsi0 | ||
qm set ${VM_ID} --boot c --bootdisk scsi0 | ||
# Set VGA to std | ||
qm set ${VM_ID} --serial0 socket --vga std | ||
|
||
# | ||
echo -e "... qm set ${VM_ID} --cicustom user=local:snippets/${CLOUD_INIT_TEMPLATE_NAME}" | ||
qm set ${VM_ID} --cicustom "user=local:snippets/${CLOUD_INIT_TEMPLATE_NAME}" | ||
qm set ${VM_ID} --ipconfig0 "${VM_IPCONFIG0}" | ||
|
||
# run first time, no image provide | ||
if [ -z "$VM_DISK_PLUS" ]; then | ||
echo -e "... skip resize..." | ||
else | ||
echo -e "... resize vm to ${VM_DISK_PLUS}GB..." | ||
echo -e "... qm resize ${VM_ID} scsi0 \"+${VM_DISK_PLUS}G\"..." | ||
sleep 5 | ||
qm resize ${VM_ID} scsi0 "+${VM_DISK_PLUS}G" | ||
fi | ||
|
||
echo -e "Example:" | ||
echo -e "... qm set ${VM_ID} --ipconfig0 \"ip=192.168.0.161/24,gw=192.168.0.189\"" | ||
echo -e "... qm start ${VM_ID}" |
Oops, something went wrong.