mirror of
https://codeberg.org/scottslowe/learning-tools.git
synced 2026-03-11 09:04:37 +00:00
Update cloud-init configuration, add launch script
Update cloud-init configuration per discussion with Dusty Mabe in #atomic on IRC (to fix circular dependency between docker and docker-storage-setup). Add launch script to make it easier. Signed-off-by: Scott Lowe <scott.lowe@scottlowe.org>
This commit is contained in:
parent
9145357ca1
commit
a3a435aafc
2 changed files with 53 additions and 12 deletions
|
|
@ -2,20 +2,18 @@
|
|||
# vim: syntax=yaml
|
||||
|
||||
groups:
|
||||
- docker: [root,centos]
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChbmG4wPh/f5CtB5hmepkUHwLKCBXuVX7CcxryMDfXx4W/2ffLO9J/Ek1w58ED3o5/KExduXjwtpMAvOoBffJsaSmm+Tc1NwzyR7GZ75MJYE1/5z5gkBUkZpjmM6qXCpiD6m3jIbaSxxfNEBL64i6H+UL6Ak1LKuYCLutTex+f4Q0NgJvRQyyG2Ms04egWjp91Kbd/cTA3/zfXGI2T3ZvGScvLcUE/neUgBloykuYi0k+VcFK0RAPjqfITaZXs6vtcPLXSX6CR4eHwgM8WpfO3sCEFkMwIhystAFapzSRdfHgtln0XZz84iydcvZVW1o3W8FTiOoNxDoC9ph6XmlU3 scott.lowe@scottlowe.org
|
||||
- docker: [centos,root]
|
||||
write_files:
|
||||
- content: |
|
||||
[Unit]
|
||||
Description=UNIX Socket for the Docker API
|
||||
PartOf=docker.service
|
||||
|
||||
[Socket]
|
||||
ListenStream=/var/run/docker.sock
|
||||
SocketMode=0660
|
||||
SocketUser=root
|
||||
SocketGroup=docker
|
||||
Service=docker.service
|
||||
|
||||
[Install]
|
||||
WantedBy=sockets.target
|
||||
|
|
@ -54,11 +52,13 @@ write_files:
|
|||
owner: root:root
|
||||
permissions: '0644'
|
||||
runcmd:
|
||||
- systemctl daemon-reload
|
||||
- systemctl enable docker.service
|
||||
- systemctl enable docker.socket
|
||||
- systemctl enable docker-tcp.socket
|
||||
- systemctl stop docker.service
|
||||
- systemctl start docker.socket
|
||||
- systemctl start docker-tcp.socket
|
||||
- systemctl start docker.service
|
||||
- [ systemctl, start, docker-storage-setup ]
|
||||
- [ systemctl, mask, docker-storage-setup ]
|
||||
- [ systemctl, daemon-reload ]
|
||||
- [ systemctl, enable, docker.service ]
|
||||
- [ systemctl, enable, docker.socket ]
|
||||
- [ systemctl, enable, docker-tcp.socket ]
|
||||
- [ systemctl, stop, docker.service ]
|
||||
- [ systemctl, start, docker.socket ]
|
||||
- [ systemctl, start, docker-tcp.socket ]
|
||||
- [ systemctl, start, docker.service ]
|
||||
|
|
|
|||
41
centos-atomic/docker-cloudinit/launch.sh
Executable file
41
centos-atomic/docker-cloudinit/launch.sh
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# This script assumes AWSCLI is installed and configured correctly
|
||||
|
||||
# Set some variables to be used later
|
||||
TYPE="t2.micro"
|
||||
KEYNAME="aws_rsa"
|
||||
|
||||
# First, capture the ID of the user's default VPC
|
||||
VPC_ID=$(aws --output text ec2 describe-vpcs \
|
||||
--filters Name=isDefault,Values=true \
|
||||
--query 'Vpcs[0].VpcId')
|
||||
|
||||
# Use the captured VPC_ID to get the subnet ID of the first subnet
|
||||
# in the first (sorted alphabetically) availability zone in the user's
|
||||
# configured region
|
||||
SN_ID=$(aws --output text ec2 describe-subnets \
|
||||
--filters Name=vpc-id,Values="$VPC_ID" \
|
||||
--query 'sort_by(Subnets,&AvailabilityZone)[0].SubnetId')
|
||||
|
||||
# Capture the ID of the security group named "default" in the
|
||||
# user's default VPC.
|
||||
SG_ID=$(aws --output text ec2 describe-security-groups \
|
||||
--filters Name=group-name,Values="default" \
|
||||
Name=vpc-id,Values="$VPC_ID" \
|
||||
--query 'SecurityGroups[0].GroupId')
|
||||
|
||||
# Capture the AMI ID for the latest version of CentOS 7 Atomic Host
|
||||
IMG_ID=$(aws --output text ec2 describe-images \
|
||||
--owners 410186602215 \
|
||||
--filters Name=name,Values="*CentOS Atomic*" \
|
||||
--query 'sort_by(Images,&CreationDate)[-1].ImageId')
|
||||
|
||||
# Launch an instance using the captured information from above (no cloud-init)
|
||||
#aws ec2 run-instances --image-id $IMG_ID --instance-type $TYPE \
|
||||
#--key-name $KEYNAME --subnet-id $SN_ID --security-group-ids $SG_ID
|
||||
|
||||
# Launch an instance using the captured information from above (with cloud-init)
|
||||
aws ec2 run-instances --image-id $IMG_ID --instance-type $TYPE \
|
||||
--key-name $KEYNAME --user-data file://cloud-config.yml \
|
||||
--subnet-id $SN_ID --security-group-ids $SG_ID
|
||||
Loading…
Reference in a new issue