Using Ansible to deploy Applications in CloudShell: Wordpress deployment on AWS #238
Quali-Community
started this conversation in
Useful Tips & Guides
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In this article, I will discuss how to deploy a WordPress application blueprint using CloudShell and an Ansible playbook.
I will also describe the initial setup and configuration of CloudShell to implement this in AWS.
In AWS, create a Windows VM for CloudShell and a Linux VM (CentOS only) for the Ansible execution server. Install CloudShell.
Download this app and drag it into the portal:
https://github.com/QualiSystems/app-starter-pack/blob/dev/Packages/Amazon/Centos%207/Centos_7_aws_us-west-2.zip
Under Inventory, add a resource of type AWS EC2. This will be the cloud provider.
Provide a name like US West 2 in the first stage.
In the next stage, select the region us-west-2 corresponding to the app you dragged earlier. Find out the VPC id and security group id from the AWS console and fill them in.
Important: After autoloading the cloud provider resource in the portal, also open Resource Manager to enter your AWS token and secret.
Clone the "CentOS 7" app twice to create two app templates with the names: "WordPress App Server" and "WordPress database".
Edit each app:
Ensure correct deployment path options are set:
In the Configuration Management tab of the app, choose Ansible and SSH connection, suitable for Linux Server. For additional settings, use the following:
DB Server: database
Name: mysql_port Value: 3306
Name: wp_db_user Value: wordpress
Configuration Management tab for the WordPress App Server:
Configuration Management tab for the WordPress database:
Under App Resource, leave Shell as Default, set User to "centos", and leave Password and Public IP blank:
(CloudShell will configure Ansible to log in with user "centos" and a PEM file generated by AWS during deployment.)
Create a blueprint and drag each app into it:
In Resource Manager, Resource Families, Configuration Services/Ansible Configuration, select Ansible Additional Arguments and push Edit Rules. Set the default value to: -u centos
The Linux-based execution server is shipped only as QCOW2 and OVA appliances.
To run it on AWS, you have two options:
1. Import the OVA appliance to AWS
2. Extract the Quali files (/root/ExecutionServer, /root/Runtime) from the appliance, copy them to the cloud VM (CentOS only), and install dependencies
Option 1: Import the OVA into AWS
- Install the AWS CLI. The MSI installer is known to work, but the pip method may not work.
- Follow these instructions: https://docs.aws.amazon.com/vm-import/latest/userguide/vmimport-image-import.html
- Deploy a VM from the new AMI
- Log in to the VM as root / qs1234
- yum install ansible
Option 2: Install the execution server files and dependencies
- Deploy a CentOS 7 VM on AWS
- Check the version of Mono: mono --version. 4.0.1 or 4.0.5.1 are known to work, and 4.2 is known not to work. The execution server will fail to come online (with no error message) if the version of Mono is too new.
- Execute some of the commands used to create the official OVA CentOS appliance: https://github.com/QualiSystemsLab/Ansible-Execution-Server-Setup/blob/master/centos
- In order to get commands to actually execute, especially the default sandbox Setup, it may be necessary to do "pip install cloudshell-core cloudshell-automation-api" with the pip corresponding to other Python installations than just /usr/local/bin/python or /usr/bin/python. Use the absolute path to pip corresponding to other installations. For example: /usr/bin/pip install cloudshell-core cloudshell-automation-api
Configure and run the execution server
Continue here after installing with Option 1 or 2 above.
Configure the execution server according to the help:
http://help.quali.com/doc/8.0/VA-Linux/Content/Linux/Cnfg-Exec-Srv.htm
http://help.quali.com/doc/8.0/VA-Linux/Content/Linux/Exmpl-Run-Cnfg.htm
For example:
cd ExecutionServer<br>
mono QsExecutionServerConsoleConfig.exe /s:192.168.35.41 /u:admin /p:admin /esn:AnsibleES1 /ansible /a:"{'Execution Server Selector':'London'}"
If Python is not at /usr/local/bin/python (e.g. on Ubuntu it will be /usr/bin/python), edit customer.config to fix the Python path after it is generated.
If you want to limit open ports, use PuTTY to SSH from the CloudShell machine to the execution server with these tunnels:
Remote, 8028, localhost:8028
Remote, 8029, localhost:8029
Remote, 8031, localhost:8031
Remote, 5905, localhost:5905
and when configuring the execution server, use localhost as the CloudShell address.
You can omit the execution server attribute and exclude the execution server that comes with CloudShell. This will cause every execution to go through the Linux server, including the Ansible ones which depend on it.
Run the execution server:
cd ~/ExecutionServer
./ex
To troubleshoot, watch the console and search for *.log files under /usr/share/QualiSystems/venv/
Attachments:
Eric Rosenquist (Eric.R) - 05/08/2017 07:39 PM
· 1330 ·
Beta Was this translation helpful? Give feedback.
All reactions