Added cloud-init KB and examples

This commit is contained in:
Michele Cereda
2022-11-27 11:56:25 +01:00
parent e1832bd9f9
commit 09007d76a5
4 changed files with 76 additions and 25 deletions

21
cloud-init/base.yaml Normal file
View File

@@ -0,0 +1,21 @@
#cloud-config
# Sources:
# - https://github.com/trajano/terraform-docker-swarm-aws/blob/master/common.cloud-config
# Upgrade the instance
# Deactivated as this could take a long time if the image is old
# https://cloudinit.readthedocs.io/en/latest/topics/modules.html#package-update-upgrade-install
# https://cloudinit.readthedocs.io/en/latest/topics/examples.html#run-apt-or-yum-upgrade
package_upgrade: false
package_reboot_if_required: false
# Install required packages
# This will always update the list of packages, regardless of package_update's value.
# https://cloudinit.readthedocs.io/en/latest/topics/modules.html#package-update-upgrade-install
# https://cloudinit.readthedocs.io/en/latest/topics/examples.html#install-arbitrary-packages
packages:
- jq
- nc
- traceroute
- unzip

View File

@@ -0,0 +1,37 @@
#cloud-config
# Sources:
# - https://github.com/trajano/terraform-docker-swarm-aws/blob/master/common.cloud-config
# Add the Docker repository
# https://cloudinit.readthedocs.io/en/latest/topics/modules.html#yum-add-repo
# https://cloudinit.readthedocs.io/en/latest/topics/examples.html#adding-a-yum-repository
#
# Got from the official installation guide at
# https://docs.docker.com/engine/install/rhel/#install-using-the-repository :
# yum install -y yum-utils && \
# yum-config-manager --add-repo \
# https://download.docker.com/linux/rhel/docker-ce.repo && \
# cat /etc/yum.repos.d/docker-ce.repo
yum_repos:
docker-ce:
name: Docker CE Stable - $basearch
enabled: true
baseurl: https://download.docker.com/linux/rhel/$releasever/$basearch/stable
priority: 1
gpgcheck: true
gpgkey: https://download.docker.com/linux/rhel/gpg
# Install required packages
# This will always update the list of packages, regardless of package_update's value.
# https://cloudinit.readthedocs.io/en/latest/topics/modules.html#package-update-upgrade-install
# https://cloudinit.readthedocs.io/en/latest/topics/examples.html#install-arbitrary-packages
#
# docker-ce already depends on docker-ce-cli and containerd.io
packages:
- docker-ce
# Enable and start the service after installation
runcmd:
- systemctl daemon-reload
- systemctl enable --now docker.service