For this fourth episode of the 5 minutes Stacks serie, we will mount a well-known relational database server: PostgreSQL.
Following this tutorial, you will get:
There are the same than for the previous episodes:
Per default, the script is proposing a deployement on an instance type “Small” (s1.cw.small-1). Instances are charged by the minute and capped at their monthly price (you can find more details on the Tarifs page on the Cloudwatt website). Obviously, you can adjust the stack parameters, particularly its defaut size.
If you do not like command lines, you can go directly to the “run it thru the console” section by clicking here
Once you have cloned the github, you will find in the
bundle-trusty-pgsql.heat.yml: HEAT orchestration template. It will be use to deploy the necessary infrastructure.
seed-pgsql.yml: Post-configuration Ansible playbook that will generate the admin password, verify the mounting points, etc.
stack-start.sh: Stack launching script. This is a small script that will save you some copy-paste.
stack-get-url.sh: Flotting IP recovery script.
Have your Cloudwatt credentials in hand and click HERE. If you are not logged in yet, you will go thru the authentication screen then the script download will start. Thanks to it, you will be able to initiate the shell acccesses towards the Cloudwatt APIs.
Source the downloaded file in your shell. Your password will be requested.
$ source COMPUTE-[...]-openrc.sh Please enter your OpenStack Password:
Once this done, the Openstack command line tools can interact with your Cloudwatt user account.
bundle-trusty-pgsql.heat.yml file, you will find at the top a section named
parameters. The sole mandatory parameter to adjust is the one called
default value must contain a valid keypair with regards to your Cloudwatt user account. This is within this same file that you can adjust the instance size by playing with the
heat_template_version: 2013-05-23 description: Postgresql with PhpPgAdmin parameters: keypair_name: default: amaury-ext-compute <-- Indicate here your keypair description: Keypair to inject in instances type: string flavor_name: default: s1.cw.small-1 <-- Indicate here the flavor size description: Flavor to use for the deployed instance type: string constraints: - allowed_values: - s1.cw.small-1 - n1.cw.standard-1 - n1.cw.standard-2 - n1.cw.standard-4 - n1.cw.standard-8 - n1.cw.standard-12 - n1.cw.standard-16 [...]
In a shell, run the script
stack-start.sh with the name you want to give it as parameter:
Last, wait 5 minutes until the deployement been completed.
start-stack.sh script is taking care of running the API necessary requests to:
Once all of this done, you can run the
stack-get-url.sh script. It will gather the entry url of your stack.
./stack-get-url.sh ACID ACID 184.108.40.206
For this stack, we have added on top of PostgreSQL a PhpPgAdmin instance to easily administrate the database. For security reasons, the created security groups are not exposing this interface on the internet. To get out, the most secure way is to mount a SSH tunnel to your instance.
$ ssh firstname.lastname@example.org -i ~/.ssh/$YOUR_KEYPAIR -L 8080:localhost:80
This will establish a translation of the port 80 of your databse towards the port 8080 of your local machine. Take advantage of being connected to retrieve the generated password for your instance.
# to be launched on the ran server $ sudo cat /root/keystore
This file includes your unique password as PostgreSQL superuser.
Then, using your favorite browser, go on
http://localhost:8080/phppgadmin and login as
pgadmin user with the password you’ve just gathered.
You are now in autonomy for the management of the database.
Yes ! Using the console, you can deploy a pgSQL server:
The stack will be automatically created (you can see its progress by clicking on its name). When all its modules will become “green”, the creation will be completed.
It is (already) FINISH !
The goal of this tutorial is to accelarate your start. At this point you are the master of the stack.
You have a SSH access point on your virtual machine thru the flotting IP and your private keypair (default user name
Among the ways to take ownership of these resources and use them in Real Life:
In this last case, do not forget to aplly either the ansible playbook
seed-pgsql.yml on the server, or to read it to gather the details of the configuration operations post-launch.
Have fun. Hack in peace.