Deliver high-performance web apps and websites with the LAMP stack. LAMP is a bundle of open source software that you can use to create a solid and reliable foundation for your web app development. The following components are included in the LAMP stack:
- Linux as the operating system
- Apache HTTP Server as the webserver
- MySQL as the database
- PHP as the programming language
This playbook is designed to configure the LAMP stack on an IBM Cloud Virtual Servers for VPC instance by using the built-in Ansible capabilities in Schematics.
IBM Cloud Schematics provides powerful tools to automate your cloud infrastructure provisioning and management process, the configuration and operation of your cloud resources, and the deployment of your app workloads. To do so, Schematics uses open source projects, such as Terraform, Ansible, OpenShift, Operators, and Helm, and delivers these capabilities to you as a managed service. Rather than installing each open source project on your workstation, and learning the API or CLI. You declare the tasks that you want to run in IBM Cloud and watch Schematics run these tasks for you. For more information about Schematics, see About IBM Cloud Schematics.
To run this playbook, you must have a Virtual Private Cloud (VPC) and a Virtual Server instance (VSI) where you want to install the LAMP stack. When you run this playbook, Schematics securely connects to the target VSI by using SSH. To ensure that access to your target VSI is secured always, this playbook requires a bastion host to be configured within your VPC in addition to the target VSI. You can automate the setup of your VPC, your target VSI, and the bastion host by using a Schematics Terraform template.
The playbook in this repository was tested on IBM Cloud VPC Generation 2 VSIs that run CentOS 7.x. You can use this playbook on virtual servers that run either CentOS or RHEL. The playbook might not work with other Linux
distributions.
When you run the playbook, the LAMP stack is configured on the target VSI. In addition, a web app is deployed to the stack that greets the user with a "Hello" message.
To run this playbook, complete the following tasks:
- Make sure that you have the required permissions to create an IBM Cloud Schematics action.
- Make sure that you have the required permissions to create and work with IBM Cloud VPC infrastructure components.
- Create an upload an SSH key to the VPC dashboard. This SSH key is used to access your bastion host and the VSIs in your VPC. Make sure that you upload the SSH key to the same region where you want to create your VSIs.
- Provision a multitier VPC with a bastion host and a VSI that you can use to install the LAMP stack. To create this environment, you use the built-in Terraform capabilities in Schematics workspaces. For more information about Schematics workspaces, see Creating workspaces.
You must retrieve the following values to run the playbook in IBM Cloud Schematics.
Input variable | Required / optional | Data type | Description |
---|---|---|---|
upassword |
Required | String | Enter a password for your MySQL user, according to MySQL password policy. For example, Abc@123abc . |
dbname |
Optional | String | Enter the name that you want to use for your MySQL database. The default database name is mysqldb . |
dbuser |
Optional | String | Enter a username that you want to set up for your MySQL database. The default user is root . |
mysql_port |
Optional | String | Enter the port number that your MySQL database listens on. The default port is 3306 . |
httpd_port |
Optional | String | Enter the port number that your Apache HTTP Webserver listens on. The default port is 80 . |
|
-
Open the Schematics action configuration page.
-
Review the name for your action, and the resource group and region where you want to create the action. Then, click Create.
-
Select the
site.yml
playbook. -
Select the Verbosity level to control the depth of information are shown when you run the playbook in Schematics.
-
Expand the Advanced options.
-
Enter all required input variables as key-value pairs. Then, click Next.
-
In the IBM Cloud resource inventory section, click the Edit button.
-
Enter the following details:
-
Bastion host IP Enter the public IP address of the Bastion host that you created.
-
IBM Cloud inventory host groups Enter the private IP dresses of all virtual servers where you want to configure the LAMP stack. For more information about how to define your host inventory, see the Ansible documentation.
[webserver] 172.16.0.4
Note You can either create dynamic or Static inventory host group. Dynamic and static inventory creations are shown in the screen capture.
Sample Dynamic host group creation
Sample static host group with resource query creation
-
IBM Cloud resource inventory SSH key Enter the private SSH key that you want to use to connect to your virtual servers. The private SSH key must match the public key that you added to the virtual server when you created it. If you stored the private key on your local workstation, you can run
cat ~/.ssh/id_rsa
to see the private key. Note You can runpbcopy < ~/.ssh/id_rsa
to copy entire private SSH key and paste.
-
-
Click Check action to verify your action details. The Jobs page opens automatically. You can view the results of this check by looking at the logs.
-
Click Run action to install the LAMP stack on your virtual server. You can monitor the progress of this action by reviewing the logs on the Jobs page.
-
Create a
hosts.ini
file on your local machine and add the private IP addresses of the virtual servers where you want to install the LAMP stack.[webserver] 172.16.0.4
-
Retrieve the public IP address of the bastion host that you created.
-
Create the Schematics action. Enter all the input variable values that you retrieved earlier. When you run this command and are prompted to enter a GitHub token, enter the return key to skip this prompt.
ibmcloud schematics action create --name lamp --location us-south --resource-group default --template https://github.com/Cloud-Schematics/lamp-simple --playbook-name site.yml --bastion <bastion_floating_IP> --target-file hosts.ini --credential ~/.ssh/id_rsa --input upassword=Abc@123abc --input dbuser=root --input dbname=mysqldb --input mysqlport=3306 --input httpd_port=<webserver port>
-
Verify that your Schematics action is created and note the ID that was assigned to your action.
ibmcloud schematics action list
-
Create a job to run a check for your action. Replace
<action_ID>
with the action ID that you retrieved. In your CLI output, note the ID that was assigned to your job.ibmcloud schematics job run --command-object action --command-object-id <action_ID> --command-name ansible_playbook_check
Example output
ID us-south.JOB.lamp.fedd2fab Command Object action Command Object ID us-south.ACTION.lamp.1aa11a1a Command Name ansible_playbook_check Name JOB.lamp.ansible_playbook_check.2 Resource Group a1a12aaad12b123bbd1d12ab1a123ca1
-
Verify that your job ran successfully by retrieving the logs.
ibmcloud schematics job logs --id <job_ID>
-
Create another job to run the action. Replace
<action_ID>
with your action ID.ibmcloud schematics job run --command-object action --command-object-id <action_ID> --command-name ansible_playbook_run
-
Verify that your job ran successfully by retrieving the logs.
ibmcloud schematics job logs --id <job_ID>
Check the job logs for list of task such as TASK Display Index page content
as shown in the screen capture.
- From the Schematics actions dashboard, find the action that you want to delete.
- From the actions menu, click Delete.
Review the following links to find more information about Schematics.
For help and support with using this template in IBM Cloud Schematics, see Getting help and support.