LAMP stands for Linux, Apache, MySQL, and PHP. Together, they provide a proven set of software for delivering high-performance web applications.
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 leverages 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 machine, 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.
These playbooks are intended to be a reference and starter's guide to building Ansible Playbooks for use with IBM Cloud and Schematics. These playbooks were tested on CentOS 7.x so we recommend that you use CentOS or RHEL to test these modules.
This playbook is designed to to deploy the LAMP stack components on an IBM cloud VSI by running RedHat Ansible locally or by using IBM Cloud Schematics Actions.
Linux
Apache
MySQL (mariadb)
PHP
In this deployment we deploy a simple web application which greets the user with a "Hello" msg. This playbook has been run and tested using VSIs in a VPC Gen2 environment, deployed using the IBM Cloud Multitier VPC Bastion LAMP example.
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 provision Multitier VPC Bastion LAMP on IBM cloud For example click here
- SSH Key on IBM Cloud
Input variable | Required/ optional | Data type | Description |
---|---|---|---|
mysql_port |
Required | Number | MySQL port number |
httpd_port |
Required | Number | Httpd port number |
dbuser |
Required | String | User name for the mysql database |
upassword |
Required | String | Password for the mysql database |
- 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 that will be shown when you run the playbook in Schematics.
- Expand the Advanced options.
- Enter all required input variables as key-value pairs. Then, click Next.
- Enter the bastion host ip, inventory and SSH key. Then, click Next.
- 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 deploy the LampStack. You can monitor the progress of this action by reviewing the logs on the Jobs page.
-
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 lampstack --location us-south --resource-group default --template https://github.com/Cloud-Schematics/lamp-simple --playbook-name site.yml --input "mysql_port": "<mysql_port>" --input "httpd_port": "<httpd_port>" --input "dbuser": "<dbuser>" --input "upassword": "<db_password>"
Example output:
Enter github-token> The given --inputs option region: is not correctly specified. Must be a variable name and value separated by an equals sign, like --inputs key=value. ID us-south.ACTION.lampstack.1aa11a1a Name lampstack Description Resource Group default user State live OK
-
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 create --command-object action --command-object-id <action_ID> --command-name ansible_playbook_check
Example output:
ID us-south.JOB.lampstack.fedd2fab Command Object action Command Object ID us-south.ACTION.lampstack.1aa11a1a Command Name ansible_playbook_check Name JOB.lampstack.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 create --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 of TASK: Display Index page content
. The content should give List of Databases and the host name if everything completed successfully.
ASK [Display Index page content] *****************************************************
2021/01/12 10:01:18 ansible-playbook run | ok: [dbhost0] => {
2021/01/12 10:01:18 ansible-playbook run | "output.content": "<html>\n <head>\n <title>Ansible Application</title>\n </head>\n <body>\n </br>\n <a href=http://172.22.192.6/index.html>Homepage</a>\n </br>\n </br>\n <a href=http://172.22.192.6/about.html>About Us</a>\n </br>\nHello, World! I am a web server configured using Ansible and I am : vsi2</BR>List of Databases: </BR>foodb\nhelp\ninformation_schema\nmysql\nperformance_schema\nsys\n</body>\n</html>\n\n"
2021/01/12 10:01:18 ansible-playbook run | }
Review the following links to find more information about Schematics and Lampstack
For help and support with using this template in IBM Cloud Schematics, see Getting help and support.