As a developer, you can begin by using a blueprint in vRealize Automation Cloud Assembly that only includes the most basic WordPress components, like having just one application server.
vRealize Automation Cloud Assembly is a tool that lets you create and manage infrastructure through code. To get started, you can drag and drop components onto the design canvas, and then add more details using the code editor on the right.
The code editor allows you to directly type, cut, and paste code. If you’re not comfortable with editing code, you can simply select a resource on the canvas, click on the code editor’s Properties tab, and enter values there. Whatever you enter will show up in the code as if you typed it out yourself.
Before starting, it’s important to be familiar with your infrastructure. While the examples given here use values from a specific use case, you should replace them with your own values. Before you can start reproducing this blueprint make sure you have created an Ubuntu template in vCenter + Image Mappings and Flavor Mappings in Aria Automation. You’ll probably also will need to tag Network Profiles so Aria Automation knows which network to select.
Create an Image Mapping called ubuntu
Create the Flavor Mappings large, medium and small
Create a blueprint from a Blank canvas
Paste the following YAML in the code section of your new blueprint
inputs:
size:
type: string
enum:
- small
- medium
- large
description: Size of Nodes
title: Tier Machine Size
username:
type: string
minLength: 4
maxLength: 20
pattern: '[a-z]+'
title: Database Username
description: Database Username
userpassword:
type: string
pattern: '[a-z0-9A-Z@#$]+'
encrypted: true
title: Database Password
description: Database Password
databaseDiskSize:
type: number
default: 4
maximum: 10
title: MySQL Data Disk Size
description: Database Disk Size
network:
type: string
title: Network name
default: VLAN1611
resources:
DBTier:
type: Cloud.Machine
properties:
name: mysql
image: ubuntu
flavor: ${input.size}
networks:
- network: ${resource["WP-Network-Private"].id}
remoteAccess:
authentication: usernamePassword
username: ${input.username}
password: ${input.userpassword}
cloudConfig: |
#cloud-config
repo_update: true
repo_upgrade: all
packages:
- mysql-server
runcmd:
- sed -e '/bind-address/ s/^#*/#/' -i /etc/mysql/mysql.conf.d/mysqld.cnf
- service mysql restart
- mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysqlpassword';"
- mysql -e "FLUSH PRIVILEGES;"
attachedDisks: []
WebTier:
type: Cloud.Machine
properties:
name: wordpress
flavor: ${input.size}
image: ubuntu
networks:
- network: ${resource["WP-Network-Private"].id}
cloudConfig: |
#cloud-config
repo_update: true
repo_upgrade: all
packages:
- apache2
- php
- php-mysql
- libapache2-mod-php
- php-mcrypt
- mysql-client
runcmd:
- 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 5 ]; 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
- 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
- service apache2 reload
WP-Network-Private:
type: Cloud.Network
properties:
name: WP-Network-Private
networkType: existing
constraints:
- tag: ${input.network}
That will result the following schema
Test the blueprint to make sure that it works before testing a deployment.
Source: https://docs.vmware.com/en/vRealize-Automation/8.0/Using-and-Managing-Cloud-Assembly/GUID-B01FB60E-2928-457A-AAB1-2CBD9FFF3A21.html