IP | |
Username | |
Password |
Welcome to the Calm Hands-On-Lab - Intermediate Blueprint What we’re going to do here is extend a basic blueprint:
This is a basic LAMP Stack (Linux Apache MySQL PHP). In this lab we’ll build on the previous 1x simple service MySQL blueprint and evolve this into the multi-stack application you see above.
Calm Glossary
Service: One tier of a multiple tier application. This can be made up of 1 more VMs (or existing machines) that all have the same config and do the same thing
Application (App): A whole application with multiple parts that are all working towards the same thing (for example, a Web Application might be made up of an Apache Server, a MySQL database and a HAProxy Load balancer. Alone each service doesn’t do much, but as a whole they do what they’re supposed to).
Macro: A Calm construct that is evaluated and expanded before being ran on the target machine. Macros and Variables are denoted in the @@{[name]}@@ format in the scripts.
Subtrate: A Calm object used to encapsulate the VM(s) within a Blueprint
In this step we’ll add a second tier and connect it to the MYSQL service created from Lab #1 MySQL Blueprint.
Create the Service as follows.
VM Name . : APACHE_PHP
Image . : CentOS
Disk Type .: DISK
Device Bus : SCSI
vCPU . : 2
Core/vCPU .: 1
Memory : 4 GB
#!/bin/bash
set -ex
# -*- Install httpd and php
sudo yum update -y
sudo yum -y install epel-release
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
sudo yum install -y httpd php56w php56w-mysql
echo "<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>" | sudo tee /etc/httpd/conf.modules.d/dir.conf
echo "<?php
phpinfo();
?>" | sudo tee /var/www/html/info.php
sudo systemctl restart httpd
sudo systemctl enable httpd
Fill in the uninstall script:
#!/bin/bash
echo "goodbye!"
Since we need the DB IP Address to bring up the AppServer, we need to add a Dependency.
Here we’ll complete the provisioning of the blueprint.
Now that we’ve added redundancy or load balancing capacity to the AppServer we need something to actually perform the load balancing. Lets add another Service HA Proxy
VM Name . : HAProxy
Image . : CentOS
Disk Type .: DISK
Device Bus : SCSI
vCPU . : 2
Core/vCPU .: 1
Memory : 4 GB
#!/bin/bash
set -ex
sudo setenforce 0
sudo sed -i 's/permissive/disabled/' /etc/sysconfig/selinux
port=80
sudo yum update -y
sudo yum install -y haproxy
echo "global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
quiet
user haproxy
group haproxy
defaults
log global
mode http
retries 3
timeout client 50s
timeout connect 5s
timeout server 50s
option dontlognull
option httplog
option redispatch
balance roundrobin
# Set up application listeners here.
listen stats 0.0.0.0:8080
mode http
log global
stats enable
stats hide-version
stats refresh 30s
stats show-node
stats uri /stats
listen admin
bind 127.0.0.1:22002
mode http
stats uri /
frontend http
maxconn 2000
bind 0.0.0.0:80
default_backend servers-http
backend servers-http" | sudo tee /etc/haproxy/haproxy.cfg
sudo sed -i 's/server host-/#server host-/g' /etc/haproxy/haproxy.cfg
hosts=$(echo "@@{APACHE_PHP.address}@@" | sed 's/^,//' | sed 's/,$//' | tr "," "\n")
for host in $hosts
do
echo " server host-${host} ${host}:${port} weight 1 maxconn 100 check" | sudo tee -a /etc/haproxy/haproxy.cfg
done
sudo systemctl daemon-reload
sudo systemctl enable haproxy
sudo systemctl restart haproxy
Fill in the uninstall script:
#!/bin/bash
echo "goodbye!"