2. Create Autoscale Profile from Cloud-init script

Purpose: The use of cloud-init scripts allows users to flexibly customize parameters and automate the process of setting up network, storage, etc. This script should be tested on Virtual Instances before being used for Autocale Profile creation.

Requirements (Can be ignored if VPC is already available):

Step 1: Go to Autoscaling page > Autoscale Profile > Select Create profile.

Step 2: Configure the profile following fields of information:

Sample Cloud-init script: With this sample script, the nodes in one group will run a static website, users can allocate Floating IP to the node and access to the website through that Floating IP.

#cloud-config

# Update apt database on first boot (run 'apt-get update').
# Note, if packages are given, or package_upgrade is true, then
# update will be done independent of this setting.
package_update: true
chpasswd:
  list: |
    root:Welcome***123

# if packages are specified, this package_update will be set to true
# packages may be supplied as a single package name or as a list
# with the format [<package>, <version>] wherein the specific
# package version will be installed.
packages:
  - nginx
  - git
  
# runcmd contains a list of either lists or a string
# each item will be executed in order at rc.local like level with
# output to the console
# - runcmd only runs during the first boot
# - if the item is a list, the items will be properly executed as if
#   passed to execve(3) (with the first arg as the command).
# - if the item is a string, it will be simply written to the file and
#   will be interpreted by 'sh'
runcmd:
  - systemctl enable nginx
  - systemctl start nginx
  - git clone https://github.com/cloudacademy/static-website-example.git
  - cp -r ./static-website-example/* /var/www/html/
  - rm -r ./static-website-example

Step 3: Select Create Profile.

The system will confirm and create profile.

Last updated