Recently, I wanted to demonstrate Aria Automation’s multi-cloud capabilities. Therefore I wanted to use the official tutorial available on the VMware documentation web site as a basis (https://docs.vmware.com/en/vRealize-Automation/8.11/Using-and-Managing-Cloud-Assembly/GUID-6EC5AFE5-3C18-4F68-A7E3-82ADD4490002.html). In this tutorial we deploy the same cloud template to more than one cloud provider, in this case AWS and Microsoft Azure.
Setting up the infrastructure on AWS and Azure (labeled “part 1” in the official tutorial) works as described there (except that you have to select other image mappings), also the creation of the Aria Automation example project (labeled “part 2” in the official tutorial) works as described, but I had problems with the Automation Assembler templates to deploy the basic cloud template and the expanded cloud template (labeled “part 3” in the official tutorial).
Thus I’ve played around a bit and came up with two working cloud templates.
Create the basic cloud template
In this Automation Assembler design example, we start with a cloud template that contains only minimal WordPress resources, such as having only one application server.
Here is the working cloud template:
formatVersion: 1
inputs:
env:
type: string
enum:
- cz:vsphere
- cz:aws
- cz:azure
default: cz:aws
title: Environment
description: Target Environment
size:
type: string
enum:
- StdSmall-c2-m2
- StdMedium-c4-m8
- StdLarge-c16-m32
default: StdSmall-c2-m2
description: Size of Nodes
title: Tier Machine Size
username:
type: string
minLength: 4
maxLength: 20
pattern: '[a-z]+'
title: Username
description: Username for SSH login and database
userpassword:
type: string
pattern: '[a-z0-9A-Z@#$]+'
encrypted: true
title: User Password
description: User Password for SSH login and database
resources:
WebTier:
type: Cloud.Machine
properties:
name: wordpress
image: Ubuntu22-Agnostic
flavor: ${input.size}
constraints:
- tag: ${input.env}
networks:
- network: ${resource["WP-Network-Public"].id}
resourceGroupName: '${input.env == "cz:azure" ? "lab-rg" : ""}'
cloudConfig: |
#cloud-config
ssh_pwauth: yes
chpasswd:
list: |
${input.username}:${input.userpassword}
expire: false
users:
- name: ${input.username}
lock_passwd: false
sudo: ['ALL=(ALL) NOPASSWD:ALL']
groups: [wheel, sudo, admin]
shell: '/bin/bash'
repo_update: true
repo_upgrade: all
packages:
- apache2
- php
- php-mysql
- libapache2-mod-php
- mysql-client
- gcc
- make
- autoconf
- libc-dev
- pkg-config
- libmcrypt-dev
- php-pear
- php-dev
runcmd:
- echo "Defaults:${input.username} !requiretty" >> /etc/sudoers.d/${input.username}
- mkdir -p /var/www/html/mywordpresssite && cd /var/www/html && wget https://wordpress.org/latest.tar.gz && tar -xzf /var/www/html/latest.tar.gz -C /var/www/html/mywordpresssite --strip-components 1
- i=0; while [ $i -le 10 ]; do mysql --connect-timeout=3 -h ${DBTier.networks[0].address} -u root -pmysqlpassword -e "SHOW STATUS;" && break || sleep 15; i=$((i+1)); done
- mysql -u root -pmysqlpassword -h ${DBTier.networks[0].address} -e "create database wordpress_blog;"
- mv /var/www/html/mywordpresssite/wp-config-sample.php /var/www/html/mywordpresssite/wp-config.php
- pecl channel-update pecl.php.net
- pecl update-channels
- pecl install mcrypt
- sed -i -e s/"define( 'DB_NAME', 'database_name_here' );"/"define( 'DB_NAME', 'wordpress_blog' );"/ /var/www/html/mywordpresssite/wp-config.php && sed -i -e s/"define( 'DB_USER', 'username_here' );"/"define( 'DB_USER', 'root' );"/ /var/www/html/mywordpresssite/wp-config.php && sed -i -e s/"define( 'DB_PASSWORD', 'password_here' );"/"define( 'DB_PASSWORD', 'mysqlpassword' );"/ /var/www/html/mywordpresssite/wp-config.php && sed -i -e s/"define( 'DB_HOST', 'localhost' );"/"define( 'DB_HOST', '${DBTier.networks[0].address}' );"/ /var/www/html/mywordpresssite/wp-config.php
- sed -i '950i extension=mcrypt.so' /etc/php/7.4/apache2/php.ini
- service apache2 reload
DBTier:
type: Cloud.Machine
properties:
name: mysql
image: Ubuntu22-Agnostic
flavor: ${input.size}
constraints:
- tag: ${input.env}
networks:
- network: ${resource["WP-Network-Public"].id}
resourceGroupName: '${input.env == "cz:azure" ? "lab-rg" : ""}'
remoteAccess:
authentication: usernamePassword
username: ${input.username}
password: ${input.userpassword}
cloudConfig: |
#cloud-config
ssh_pwauth: yes
chpasswd:
list: |
${input.username}:${input.userpassword}
expire: false
users:
- name: ${input.username}
lock_passwd: false
sudo: ['ALL=(ALL) NOPASSWD:ALL']
groups: [wheel, sudo, admin]
shell: '/bin/bash'
repo_update: true
repo_upgrade: all
packages:
- mysql-server
runcmd:
- echo "Defaults:${input.username} !requiretty" >> /etc/sudoers.d/${input.username}
- sed -e '/bind-address/ s/^#*/#/' -i /etc/mysql/mysql.conf.d/mysqld.cnf
- service mysql restart
- mysql -e "CREATE USER 'root'@'%' IDENTIFIED BY 'mysqlpassword';"
- mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';"
- mysql -e "FLUSH PRIVILEGES;"
attachedDisks: []
WP-Network-Public:
type: Cloud.Network
properties:
name: WP-Network-Public
networkType: public
azureResourceGroup:
type: Cloud.Azure.ResourceGroup
properties:
count: '${input.env == "cz:azure"? 1 : 0 }'
useExisting: true
name: lab-rg
Expand the cloud template
After we’ve created the basic Automation Assembler template for the example application, we expand it into a multiple tier application.
To expand the cloud template, we add the following enhancements.
- An option to cluster application servers for increased capacity
- A public-facing network and load balancer in front of the application servers
- A backup server with archive storage
Here is the working cloud template:
formatVersion: 1
inputs:
env:
type: string
enum:
- cz:vsphere
- cz:aws
- cz:azure
default: cz:aws
title: Environment
description: Target Environment
size:
type: string
enum:
- StdSmall-c2-m2
- StdMedium-c4-m8
- StdLarge-c16-m32
default: StdSmall-c2-m2
description: Size of Nodes
title: Tier Machine Size
username:
type: string
minLength: 4
maxLength: 20
pattern: '[a-z]+'
title: Username
description: Username for SSH login and database
userpassword:
type: string
pattern: '[a-z0-9A-Z@#$]+'
encrypted: true
title: User Password
description: User Password for SSH login and database
count:
type: integer
default: 2
maximum: 5
minimum: 2
title: WordPress Cluster Size
description: WordPress Cluster Size (Number of Nodes)
storagetype:
type: string
enum:
- storage:general
- storage:fast
description: Archive Storage Disk Type
title: Archive Disk Type
resources:
WebTier:
type: Cloud.Machine
properties:
name: wordpress
image: Ubuntu22-Agnostic
flavor: ${input.size}
count: ${input.count}
constraints:
- tag: ${input.env}
networks:
- network: ${resource["WP-Network-Private"].id}
assignPublicIpAddress: true
cloudConfig: |
#cloud-config
ssh_pwauth: yes
chpasswd:
list: |
${input.username}:${input.userpassword}
expire: false
users:
- name: ${input.username}
lock_passwd: false
sudo: ['ALL=(ALL) NOPASSWD:ALL']
groups: [wheel, sudo, admin]
shell: '/bin/bash'
repo_update: true
repo_upgrade: all
packages:
- apache2
- php
- php-mysql
- libapache2-mod-php
- mysql-client
- gcc
- make
- autoconf
- libc-dev
- pkg-config
- libmcrypt-dev
- php-pear
- php-dev
runcmd:
- echo "Defaults:${input.username} !requiretty" >> /etc/sudoers.d/${input.username}
- mkdir -p /var/www/html/mywordpresssite && cd /var/www/html && wget https://wordpress.org/latest.tar.gz && tar -xzf /var/www/html/latest.tar.gz -C /var/www/html/mywordpresssite --strip-components 1
- i=0; while [ $i -le 10 ]; do mysql --connect-timeout=3 -h ${DBTier.networks[0].address} -u root -pmysqlpassword -e "SHOW STATUS;" && break || sleep 15; i=$((i+1)); done
- mysql -u root -pmysqlpassword -h ${DBTier.networks[0].address} -e "create database wordpress_blog;"
- mv /var/www/html/mywordpresssite/wp-config-sample.php /var/www/html/mywordpresssite/wp-config.php
- pecl channel-update pecl.php.net
- pecl update-channels
- pecl install mcrypt
- sed -i -e s/"define( 'DB_NAME', 'database_name_here' );"/"define( 'DB_NAME', 'wordpress_blog' );"/ /var/www/html/mywordpresssite/wp-config.php && sed -i -e s/"define( 'DB_USER', 'username_here' );"/"define( 'DB_USER', 'root' );"/ /var/www/html/mywordpresssite/wp-config.php && sed -i -e s/"define( 'DB_PASSWORD', 'password_here' );"/"define( 'DB_PASSWORD', 'mysqlpassword' );"/ /var/www/html/mywordpresssite/wp-config.php && sed -i -e s/"define( 'DB_HOST', 'localhost' );"/"define( 'DB_HOST', '${DBTier.networks[0].address}' );"/ /var/www/html/mywordpresssite/wp-config.php
- sed -i '950i extension=mcrypt.so' /etc/php/7.4/apache2/php.ini
- service apache2 reload
DBTier:
type: Cloud.Machine
properties:
name: mysql
image: Ubuntu22-Agnostic
flavor: ${input.size}
constraints:
- tag: ${input.env}
networks:
- network: ${resource["WP-Network-Private"].id}
assignPublicIpAddress: true
remoteAccess:
authentication: usernamePassword
username: ${input.username}
password: ${input.userpassword}
cloudConfig: |
#cloud-config
ssh_pwauth: yes
chpasswd:
list: |
${input.username}:${input.userpassword}
expire: false
users:
- name: ${input.username}
lock_passwd: false
sudo: ['ALL=(ALL) NOPASSWD:ALL']
groups: [wheel, sudo, admin]
shell: '/bin/bash'
repo_update: true
repo_upgrade: all
packages:
- mysql-server
runcmd:
- echo "Defaults:${input.username} !requiretty" >> /etc/sudoers.d/${input.username}
- sed -e '/bind-address/ s/^#*/#/' -i /etc/mysql/mysql.conf.d/mysqld.cnf
- service mysql restart
- mysql -e "CREATE USER 'root'@'%' IDENTIFIED BY 'mysqlpassword';"
- mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';"
- mysql -e "FLUSH PRIVILEGES;"
attachedDisks: []
LoadBalancer:
type: Cloud.LoadBalancer
properties:
name: myapp-lb
network: ${resource["WP-Network-Public"].id}
instances:
- ${WebTier.id}
routes:
- protocol: HTTP
port: '80'
instanceProtocol: HTTP
instancePort: '80'
healthCheckConfiguration:
protocol: HTTP
port: '80'
urlPath: /mywordpresssite/wp-admin/install.php
intervalSeconds: 6
timeoutSeconds: 5
unhealthyThreshold: 2
healthyThreshold: 2
internetFacing: true
WP-Network-Private:
type: Cloud.Network
properties:
name: WP-Network-Private
networkType: existing
WP-Network-Public:
type: Cloud.Network
properties:
name: WP-Network-Public
networkType: public
backup:
type: Cloud.Machine
properties:
name: backup
flavor: ${input.size}
image: Ubuntu22-Agnostic
networks:
- network: ${resource["WP-Network-Private"].id}
attachedDisks:
- source: ${resource.ArchiveDisk.id}
ArchiveDisk:
type: Cloud.Volume
properties:
name: ArchiveDisk
capacityGb: 5
constraints:
- tag: ${input.storagetype}
That’s all for now.
You can find the cloud template YAML files discussed in this post on my Github vRA repository.
Leave a Reply