diff --git a/gen-cloud-init/Makefile b/gen-cloud-init/Makefile index fc6dec1..b860c2a 100644 --- a/gen-cloud-init/Makefile +++ b/gen-cloud-init/Makefile @@ -4,14 +4,36 @@ all: rhel: cp -fv user-data-rhel user-data cp -fv meta-data-rhel meta-data + bash gen-hostname-and-instance-id.sh bash ./build.sh rhel-master-init.iso deploy-rhel: cp -fv rhel-master-init.iso ./isos/ + +rocky: + cp -fv user-data-rocky user-data + cp -fv meta-data-rocky meta-data + bash gen-hostname-and-instance-id.sh + bash ./build.sh rocky-master-init.iso + +deploy-rocky: + cp -fv rocky-master-init.iso ./isos/ + + +alma: + cp -fv user-data-alma user-data + cp -fv meta-data-alma meta-data + bash gen-hostname-and-instance-id.sh + bash ./build.sh alma-master-init.iso + +deploy-alma: + cp -fv alma-master-init.iso ./isos/ + debian: cp -fv user-data-debian user-data cp -fv meta-data-debian meta-data + bash gen-hostname-and-instance-id.sh bash ./build.sh debian-master-init.iso deploy-debian: @@ -20,8 +42,12 @@ deploy-debian: ubuntu: cp -fv user-data-ubuntu user-data cp -fv meta-data-ubuntu meta-data + bash gen-hostname-and-instance-id.sh bash ./build.sh ubuntu-master-init.iso deploy-ubuntu: cp -fv ubuntu-master-init.iso ./isos/ +install-depencies-ubuntu: + apt update + apt install -y ruby genisoimage cloud-init diff --git a/gen-cloud-init/PASSWORD b/gen-cloud-init/PASSWORD new file mode 100644 index 0000000..44b600a --- /dev/null +++ b/gen-cloud-init/PASSWORD @@ -0,0 +1 @@ +veryhardpass diff --git a/gen-cloud-init/build.sh b/gen-cloud-init/build.sh index e7495a0..add763b 100644 --- a/gen-cloud-init/build.sh +++ b/gen-cloud-init/build.sh @@ -15,11 +15,13 @@ fi SSH_KEY1=$(head -1 "SSH_KEY1") SSH_KEY2=$(head -1 "SSH_KEY2") SSH_KEY3=$(head -1 "SSH_KEY3") +PASSWORD=$(head -1 "PASSWORD") -cat user-data | ruby replace.rb "###SSH_KEY_1###" "${SSH_KEY1}" | ruby replace.rb "###SSH_KEY_2###" "${SSH_KEY2}" | ruby replace.rb "###SSH_KEY_3###" "${SSH_KEY3}" > user-data.in && \ +cat user-data | ruby replace.rb "###PASSWORD###" "${PASSWORD}" | ruby replace.rb "###SSH_KEY_1###" "${SSH_KEY1}" | ruby replace.rb "###SSH_KEY_2###" "${SSH_KEY2}" | ruby replace.rb "###SSH_KEY_3###" "${SSH_KEY3}" > user-data.in && \ cp -vf user-data.in user-data -cloud-init devel schema --config-file user-data +#cloud-init devel schema --config-file user-data +#cloud-init query user-data genisoimage -output ${FILENAME} -volid cidata -joliet -rock user-data meta-data diff --git a/gen-cloud-init/gen-hostname-and-instance-id.sh b/gen-cloud-init/gen-hostname-and-instance-id.sh index 77b6514..5529b44 100644 --- a/gen-cloud-init/gen-hostname-and-instance-id.sh +++ b/gen-cloud-init/gen-hostname-and-instance-id.sh @@ -7,7 +7,7 @@ if [ -z "${OS_DISTRO}" ];then fi INSTANCE_ID="$( uuidgen |cut -d '-' -f 1 )" -HOSTNAME="$(OS_DISTRO)-${INSTANCE_ID}" +HOSTNAME="${OS_DISTRO}-${INSTANCE_ID}" cat meta-data | ruby replace.rb "##INSTANCE_ID##" "${INSTANCE_ID}" | ruby replace.rb "##HOSTNAME##" "${HOSTNAME}" > meta-data.in && \ - cp -vf meta-data.in > meta-data \ No newline at end of file + cp -vf meta-data.in meta-data diff --git a/gen-cloud-init/meta-data-ubuntu b/gen-cloud-init/meta-data-ubuntu new file mode 100644 index 0000000..ee3fee3 --- /dev/null +++ b/gen-cloud-init/meta-data-ubuntu @@ -0,0 +1,2 @@ +instance-id: ##INSTANCE_ID## +local-hostname: ##HOSTNAME## diff --git a/gen-cloud-init/user-data-ubuntu b/gen-cloud-init/user-data-ubuntu new file mode 100644 index 0000000..7d89d7e --- /dev/null +++ b/gen-cloud-init/user-data-ubuntu @@ -0,0 +1,31 @@ +#cloud-config + +# remove this block entirely if not using password authentication +password: ###PASSWORD### +ssh_pwauth: True +chpasswd: { expire: False } + +package_upgrade: true +packages: +- git +- htop +- tmux +- wget + +# replace with your own public key (e.g. ~/.ssh/id_rsa.pub) +ssh_authorized_keys: + - ###SSH_KEY_1### + - ###SSH_KEY_2### + - ###SSH_KEY_3### + +users: + - default + - name: root + ssh_authorized_keys: + - ###SSH_KEY_1### + - ###SSH_KEY_2### + - ###SSH_KEY_3### +runcmd: + - [ "/usr/bin/wget" , "https://raw.githubusercontent.com/elico/ispmail-project/master/debian-bullseye-il-sources.list" , "-O" , "/etc/apt/sources.list.debian-11.in" ] + +final_message: "The system is finally up, after $UPTIME seconds"