LAMPIn preparation for a joint VMware & Puppet event I’m running on February 8th, I wanted to know more about Puppet and the integration available with VMware vRealize Automation. To build these new skills I started of with the free learning tutorials from Puppet and the Puppet Learning VM. Then I installed and configured my own Puppet Enterprise Master server in my homelab and integrated it, using the Puppet plugin for vRealize Automation and the vRA Starter-Content Pack provided by Puppet, with my already running VMware vRealize Automation 7.3 environment. In my quest of gathering knowledge I stumbled on some nice vRealize Automation and Puppet examples but all were using single machine blueprints. So, I called my Puppet friend Kevin Reeuwijk and asked him to help me develop a multi-machine software stack using VMware vRealize Automation and the Puppet integration. So here you are, LAMP Stacks made easy with VMware and Puppet.

Requirements

Instructions for installing and configuring Puppet Enterprise and adding the vRA Starter-Content Pack can be found here.

Install and configure the Puppet Enterprise plugin

Next step is to install and configure the Puppet Enterprise Plugin to integrate it with VMware vRealize Automation.

  1. Download the Puppet plug-in’s .vmoapp package from the VMware Marketplace.
  2. Login to the vRealize Orchestrator server’s control center at https://<<vRO-Server-IP-address/FQDN>:8283/vco-controlcenter.
  3. Click the Plugins tab.
  4. Click Install plug-in.
  5. Install the Puppet plug-in’s .vmoapp package downloaded from the VMware Solution Exchange. Read and accept the EULA, then click Install.

After the plugin is installed in vRealize Orchestrator, login to your vRealize Automation console and add a Puppet endpoint.

  1. Go to Administration, vRO Configuration, Endpoints and click on the plus sign (New).
  2. Select Puppet as Plug-in, click Next.
  3. Give in a Name and Description (optional), click Next.
  4. Enter the details to connect to your Puppet Enterprise server. If you have installed the Puppet vRA Starter-Content Pack, use vro-plugin-user as your username with the default password puppetlabs. Root can also be used but is less secure and thus not a best practice.
  5. Go back to tour vRO console and check if the Puppet Enterprise Master server is successfully added.

Add LAMP Stack code to Puppet repository and configure Classes

The vRA Starter-Content Pack creates a Production and a Dev environment on your Puppet Enterprise Master server and adds code to your repository to create 5 different machine types out of the box based on Roles.

  • Linux base server.
  • Linux MySQL server.
  • Linux web server.
  • Windows base server.
  • Windows web server.

All these Roles are single-machine blueprint based and are nice to demo the basics of the Puppet integration with VMware vRealize Automation. In my case, I wanted a more advanced use case with a N-tier application stack deployed across multiple machines, adding variables and dependencies. I choose to use LAMP.

LAMP is an open source Web development platform that uses Linux as the operating system, Apache as the Web server, MySQL as the relational database management system and PHP as the object-oriented scripting language. Because the platform has four layers, LAMP is sometimes referred to as a LAMP stack. Stacks can be built on different operating systems.

The LAMP stack consists of two server Roles, mysql and webapp. One installs a MySQL database server and the other installs a Apache/PHP web server.

During request database name, database user and password can be defined using vRA Custom Properties.

Download my Puppet code on Github and copy it to the Dev environment in your Puppet repository. It adds additional Modules, Manifests, Profiles and Roles for deploying a LAMP stack using a multi-machine vRA 7.3 blueprint.

LAMP LAMP LAMP LAMP LAMP

After copying the code, add additional Role Groups and Classes to your Puppet Enterprise Master server.

  1. Login to your Puppet Enterprise GUI and select Classification.
  2. Click Add Group, select Roles as Parent name, enter role::lamp:mysql as Group name and select Dev as Environment. LAMP
  3. Repeat this step and add the role::lamp::webapp Group. LAMP
  4. Open Roles and click on role::lamp::mysql LAMP
  5. On the Rules tab under Fact, add trusted.extensions.pp_role = role::lamp::mysql, click Commit Change. LAMP
  6. Under the Configuration tab, enter new class role::lamp::mysql, click Add class and then Commit Change. LAMP
  7. Go back to Roles and click on role::lamp::webapp
  8. On the Rules tab under Fact, add trusted.extensions.pp_role = role::lamp::webapp, click Commit Change. LAMP
  9. Under the Configuration tab, enter new class role::lamp::webapp, click Add class and then Commit Change. LAMP

Create a multi-machine LAMP Stack blueprint

  1. Login to your vRealize Automation console, go to the Administration tab and select Property Dictionary, Property Definitions.
  2. Create three new Custom Properties; lamp_db_name, lamp_db_user and lamp_db_password with Data type String, Required enabled and Display as Textbox. When the Puppet agent is installed it gathers Facts from the node and reads all the vRA Properties of that machine which then can be used in Puppet code as variables for example to define the LAMP database name.
  3. Go to the Design tab, select Blueprints and create a new Blueprint, give it a name and click Ok.
  4. Drag two vSphere Machines and a Network to the canvas, configure the Network component by selecting a appropriate Profile and click Save.
  5. Select the first vSphere Machine enter an ID (DBserver for example), use a Linux (CentOS7) image to clone from, add the available Network and under Custom Properties add the newly created lamp_db_name, lamp_db_user and lamp_db_password property definitions and enable Show in Request. Click Save.
  6. Select the second vSphere Machine enter an ID (Webserver for example), use a Linux (CentOS7) image to clone from and add the available Network. Click Save.
  7. Drag a Puppet Configuration Management component on the first vSphere Machine and give it the ID MySQL.
  8. Under the Server tab, select your Puppet Master configured in the Endpoint, select the Dev Environment and finally the role role::lamp::mysql. Enter S3cr3tP@ssw0rd! as Shared secret.
  9. Under the Managed Node tab, select Linux and enter a username and password which will be used to connect to your Linux machine and installing the Puppet agent. Click Save.
  10. Drag a Puppet Configuration Management component on the second vSphere Machine and give it the ID Webapp.
  11. Under the Server tab, select your Puppet Master configured in the Endpoint, select the Dev Environment and finally the role role::lamp::webapp. Enter S3cr3tP@ssw0rd! as Shared secret.
  12. Under the Managed Node tab, select Linux and enter a username and password which will be used to connect to your Linux machine and installing the Puppet agent. Click Save.
  13. Finally drag a dependency from the Webserver to the MySQL Puppet Component. This starts the deployment of the Webserver after the MySQL database is installed and configured by Puppet. Click Save and Finish.
  14. Publish the Blueprint and add it to the Catalog. Configure Entitlements properly to ensure that users can request and manage the LAMP Stack service.

Request and deploy a LAMP Stack

  1. Login to your vRealize Automation console, go to the Catalog tab and request the LAMP Stack catalog item.
  2. Select the DBserver vSphere Machine component and enter the LAMP Database name, Database user and password in the required fields (with red asterix). Click Submit.
  3. Go to the Requests tab, click on the LAMP Stack request and select Execution Information. When the DBserver and MySQL components are successfully deployed, login to the Puppet Enterprise GUI and check if the Puppet Agent was successfully installed by checking if a new node exists under Nodes.
  4. In Puppet, click on the DBserver node, click on the Reports tab and select the Report with the most changes.
  5. Under the Events tab, select Package to see which software packages Puppet has installed, then select mysql_database to see the name of the database which was created (this should be your lamp_db_name), then select mysql_user to see the name of the database user which was created (this should be your lamp_db_user).
  6. Go back to the vRA LAMP Stack Request. When the Webserver and Webapp components are successfully deployed, login to the Puppet Enterprise GUI and check if the Puppet Agent was successfully installed by checking if a new node exists under Nodes.
  7. In Puppet, click on the Webserver node, click on the Reports tab and select the Report with the most changes.
  8. Under the Events tab, select Package to see which software packages Puppet has installed, then select Service which services were started and stopped.
  9. Last but not least, check if the Webserver has a working database connection to the DBserver by opening a web browser and enter http://<<Webserver-IP-address/FQDN>. When you see the following response, the LAMP Stack has been successfully deployed and is ready to be used for developing PHP Web applications.

And here you have it, multi-machine LAMP Stacks made easy with VMware vRealize Automation and Puppet Enterprise.

Happy coding!