diff --git a/build.gradle b/build.gradle index cfe4bb0..8acf46f 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ group = 'com.thoughtworks.gocd' gocdPlugin { id = 'com.thoughtworks.gocd.elastic-agent.ecs' - pluginVersion = '7.4.1' + pluginVersion = '8.0.0' goCdVersion = '21.4.0' name = 'GoCD Elastic Agent Plugin for Amazon ECS' description = 'GoCD Elastic Agent Plugin for Amazon Elastic Container Service allow for more efficient use of instances' diff --git a/src/main/resources/userdata.template b/src/main/resources/userdata.template index a2fa2ec..71a931b 100644 --- a/src/main/resources/userdata.template +++ b/src/main/resources/userdata.template @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -35,62 +30,3 @@ CUSTOM_USER_DATA_SCRIPT log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS="OVERRIDE_STORAGE_OPTION --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/full-userdata.sh b/src/test/resources/userdata/full-userdata.sh index 837e1da..134f8c7 100644 --- a/src/test/resources/userdata/full-userdata.sh +++ b/src/test/resources/userdata/full-userdata.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -45,62 +40,3 @@ some-script log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS="--storage-opt foo=bsfds --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/linux-default.sh b/src/test/resources/userdata/linux-default.sh index 3f32e9a..cc74891 100644 --- a/src/test/resources/userdata/linux-default.sh +++ b/src/test/resources/userdata/linux-default.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -35,62 +30,3 @@ log "Finished executing GoCD's user data script, now executing custom user data log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/linux-with-cluster.sh b/src/test/resources/userdata/linux-with-cluster.sh index 10411f8..41ea999 100644 --- a/src/test/resources/userdata/linux-with-cluster.sh +++ b/src/test/resources/userdata/linux-with-cluster.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -39,62 +34,3 @@ log "Finished executing GoCD's user data script, now executing custom user data log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/linux-with-docker-registry.sh b/src/test/resources/userdata/linux-with-docker-registry.sh index 5df4600..0845d72 100644 --- a/src/test/resources/userdata/linux-with-docker-registry.sh +++ b/src/test/resources/userdata/linux-with-docker-registry.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -40,62 +35,3 @@ log "Finished executing GoCD's user data script, now executing custom user data log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/linux-with-image-cleanup.sh b/src/test/resources/userdata/linux-with-image-cleanup.sh index f1cb169..151bf95 100644 --- a/src/test/resources/userdata/linux-with-image-cleanup.sh +++ b/src/test/resources/userdata/linux-with-image-cleanup.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -39,62 +34,3 @@ log "Finished executing GoCD's user data script, now executing custom user data log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/linux-with-init-script.sh b/src/test/resources/userdata/linux-with-init-script.sh index bc9841f..afd0045 100644 --- a/src/test/resources/userdata/linux-with-init-script.sh +++ b/src/test/resources/userdata/linux-with-init-script.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -35,62 +30,3 @@ echo "this is an example init script." log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/linux-with-task-cleanup.sh b/src/test/resources/userdata/linux-with-task-cleanup.sh index 87d514a..db08770 100644 --- a/src/test/resources/userdata/linux-with-task-cleanup.sh +++ b/src/test/resources/userdata/linux-with-task-cleanup.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -39,62 +34,3 @@ log "Finished executing GoCD's user data script, now executing custom user data log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/userdata-from-ec2-config.sh b/src/test/resources/userdata/userdata-from-ec2-config.sh index b737817..3133775 100644 --- a/src/test/resources/userdata/userdata-from-ec2-config.sh +++ b/src/test/resources/userdata/userdata-from-ec2-config.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -42,62 +37,3 @@ linux-script log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/with-custom-attributes.sh b/src/test/resources/userdata/with-custom-attributes.sh index 2d62a49..a317a7d 100644 --- a/src/test/resources/userdata/with-custom-attributes.sh +++ b/src/test/resources/userdata/with-custom-attributes.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -39,62 +34,3 @@ log "Finished executing GoCD's user data script, now executing custom user data log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/with-storage-config.sh b/src/test/resources/userdata/with-storage-config.sh index b85ce22..cc74891 100644 --- a/src/test/resources/userdata/with-storage-config.sh +++ b/src/test/resources/userdata/with-storage-config.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -35,62 +30,3 @@ log "Finished executing GoCD's user data script, now executing custom user data log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS="--storage-opt dm.fs=ext4 --storage-opt dm.basesize=20G --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file