Last active
February 7, 2018 09:12
-
-
Save nick4fake/65a43764530648b33b30a7dfdf36b9af to your computer and use it in GitHub Desktop.
Revisions
-
nick4fake revised this gist
Aug 27, 2017 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -83,12 +83,13 @@ else rm -Rf /var/lib/docker fi ln -sv /mnt/data/docker /var/lib/docker if [ -f /mnt/data/provision.sh ]; then . /mnt/data/provision.sh fi service docker start || true touch /etc/cluster_created2 EOF1 chmod +x /root/run.sh -
nick4fake revised this gist
Aug 27, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -69,7 +69,7 @@ sleep 5 # mounting volume mkdir -p /mnt/data echo '/dev/xvdm1 /mnt/data ext4 defaults,nofail 0 2' >> /etc/fstab mount -a aws ecr get-login --no-include-email --region ${EC2_REGION} | bash -
nick4fake revised this gist
Aug 27, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -64,7 +64,7 @@ aws ec2 associate-address --allocation-id ${EC_IP_ALLOC} --instance-id ${EC2_INS # attaching volume # https://stackoverflow.com/questions/8423891/attaching-ebs-during-startup-of-amazon-ec2-spot-instance aws ec2 attach-volume --volume-id ${EC_VOLUME} --instance ${EC2_INSTANCE_ID} --device /dev/xvdm sleep 5 # mounting volume -
nick4fake revised this gist
Aug 15, 2017 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ export DEBIAN_FRONTEND=noninteractive apt-get update apt-get -y install python-pip pip install --upgrade --user pip awscli ln -sv /root/.local/bin/aws /usr/sbin/aws echo 'Europe/Kiev' > /etc/timezone @@ -72,6 +72,10 @@ mkdir -p /mnt/data echo '/dev/xvdm /mnt/data ext4 defaults,nofail 0 2' >> /etc/fstab mount -a aws ecr get-login --no-include-email --region ${EC2_REGION} | bash cp -Rv /root/.docker /home/ubuntu/.docker chown -Rv ubuntu:ubuntu /home/ubuntu/.docker service docker stop if [ ! -d /mnt/data/docker ]; then mv /var/lib/docker /mnt/data/docker -
nick4fake revised this gist
Aug 15, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -28,6 +28,7 @@ apt-get -y upgrade apt-get -y install docker-ce adduser ubuntu docker curl -L https://github.com/docker/compose/releases/download/1.14.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose # ----------------------------------- cat << 'EOF1' > /root/run.sh -
nick4fake revised this gist
Aug 15, 2017 . 1 changed file with 9 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,5 @@ #!/usr/bin/env bash # AMI init script set -e export DEBIAN_FRONTEND=noninteractive @@ -37,8 +35,9 @@ cat << 'EOF1' > /root/run.sh set -e EC_VOLUME=$1 EC_IP_ALLOC=$2 EC_KEY=$3 EC_SECRET=$4 # https://stackoverflow.com/questions/625644/find-out-the-instance-id-from-within-an-ec2-machine die() { status=$1; shift; echo "FATAL: $*"; exit $status; } @@ -59,21 +58,24 @@ aws_access_key_id = ${EC_KEY} aws_secret_access_key = ${EC_SECRET} EOF2 # assoc ip aws ec2 associate-address --allocation-id ${EC_IP_ALLOC} --instance-id ${EC2_INSTANCE_ID} --allow-reassociation # attaching volume # https://stackoverflow.com/questions/8423891/attaching-ebs-during-startup-of-amazon-ec2-spot-instance aws ec2 attach-volume --volume-id ${CONF_VOLUME} --instance ${EC2_INSTANCE_ID} --device /dev/xvdm sleep 5 # mounting volume mkdir -p /mnt/data echo '/dev/xvdm /mnt/data ext4 defaults,nofail 0 2' >> /etc/fstab mount -a service docker stop if [ ! -d /mnt/data/docker ]; then mv /var/lib/docker /mnt/data/docker else rm -Rf /var/lib/docker fi ln -sv /mnt/data/docker /var/lib/docker service docker start -
nick4fake revised this gist
Aug 15, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -73,7 +73,7 @@ service docker stop if [ ! -d /mnt/data/docker ]; then mv /var/lib/docker /mnt/data/docker else rm -Rf /var/lib/docker fi ln -sv /mnt/data/docker /var/lib/docker service docker start -
nick4fake revised this gist
Aug 15, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -66,7 +66,7 @@ sleep 5 # mounting volume mkdir -p /mnt/data echo '/dev/xvdm1 /mnt/data ext4 defaults,nofail 0 2' >> /etc/fstab mount -a service docker stop -
nick4fake revised this gist
Aug 15, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -61,7 +61,7 @@ EOF2 # attaching volume # https://stackoverflow.com/questions/8423891/attaching-ebs-during-startup-of-amazon-ec2-spot-instance aws ec2 attach-volume --volume-id ${EC_VOLUME} --instance ${EC2_INSTANCE_ID} --device /dev/xvdm sleep 5 # mounting volume -
nick4fake revised this gist
Aug 15, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/usr/bin/env bash # AMI init script # quick run: # wget -O - https://gist.github.com/nick4fake/65a43764530648b33b30a7dfdf36b9af/raw/setup.sh | bash set -e export DEBIAN_FRONTEND=noninteractive -
nick4fake revised this gist
Aug 15, 2017 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ #!/usr/bin/env bash # AMI init script # quick run: # wget -O - https://gist.github.com/nick4fake/65a43764530648b33b30a7dfdf36b9af/raw/074dc7fb2ed8111f5de59adcca87af334b28cdda/setup.sh | bash set -e export DEBIAN_FRONTEND=noninteractive -
nick4fake renamed this gist
Aug 15, 2017 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -76,6 +76,10 @@ fi ln -sv /mnt/data/docker /var/lib/docker service docker start if [ -f /mnt/data/provision.sh ]; then . /mnt/data/provision.sh fi touch /etc/cluster_created2 EOF1 chmod +x /root/run.sh -
nick4fake created this gist
Aug 15, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,85 @@ #!/usr/bin/env bash # AMI init script set -e export DEBIAN_FRONTEND=noninteractive apt-get update apt-get -y install python-pip pip install --upgrade --user awscli ln -sv /root/.local/bin/aws /usr/sbin/aws echo 'Europe/Kiev' > /etc/timezone dpkg-reconfigure --frontend noninteractive tzdata # Adding docker repo # https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" apt-get update apt-get -y upgrade # Installing docker apt-get -y install docker-ce adduser ubuntu docker curl -L https://github.com/docker/compose/releases/download/1.14.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose # ----------------------------------- cat << 'EOF1' > /root/run.sh #!/usr/bin/env bash set -e EC_VOLUME=$1 EC_KEY=$2 EC_SECRET=$3 # https://stackoverflow.com/questions/625644/find-out-the-instance-id-from-within-an-ec2-machine die() { status=$1; shift; echo "FATAL: $*"; exit $status; } EC2_INSTANCE_ID="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id || die \"wget instance-id has failed: $?\"`" test -n "$EC2_INSTANCE_ID" || die 'cannot obtain instance-id' EC2_AVAIL_ZONE="`wget -q -O - http://169.254.169.254/latest/meta-data/placement/availability-zone || die \"wget availability-zone has failed: $?\"`" test -n "$EC2_AVAIL_ZONE" || die 'cannot obtain availability-zone' EC2_REGION="`echo \"$EC2_AVAIL_ZONE\" | sed -e 's:\([0-9][0-9]*\)[a-z]*\$:\\1:'`" mkdir ~/.aws cat << EOF2 >> ~/.aws/config [default] region = ${EC2_REGION} EOF2 cat << EOF2 >> ~/.aws/credentials [default] aws_access_key_id = ${EC_KEY} aws_secret_access_key = ${EC_SECRET} EOF2 # attaching volume # https://stackoverflow.com/questions/8423891/attaching-ebs-during-startup-of-amazon-ec2-spot-instance aws ec2 attach-volume --volume-id ${CONF_VOLUME} --instance ${EC2_INSTANCE_ID} --device /dev/xvdm sleep 5 # mounting volume mkdir -p /mnt/data echo '/dev/xvdm /mnt/data ext4 defaults,nofail 0 2' >> /etc/fstab mount -a service docker stop if [ ! -d /mnt/data/docker ]; then mv /var/lib/docker /mnt/data/docker else rm -Rf /var/lib/docker fi ln -sv /mnt/data/docker /var/lib/docker service docker start touch /etc/cluster_created2 EOF1 chmod +x /root/run.sh # ----------------------------------- touch /etc/cluster_created1