This blog post explains how you would use PostgreSQL cartridge on Apache Stratos.
Let's look into details about each classes and parameters.
This is where we tell puppet to install PostgreSQL server. This module is developed and managed by puppet laps. Let's see a basic usage of this module. Refer here for a complete reference of this module.
ip_mask_deny_postgres_user
ip_mask_allow_all_users
That's it from puppet master side.
You can deploy PostgreSQL cartridge now. A sample deployment on an openstack environment looks like below,
Be sure to set port to 5432. Otherwise, PostgreSQL instance will not be activated.
You have successfully deployed PostgreSQL cartridge now.
You can subscribe to it now.
Go to My Cartridges,
Click your PostgreSQL cartridge to get your access URLs,
Locate http://$member_public_IP on your browser, you will get access to PostgreSQL server via phpPgAdmin. If you want, you can map postgres.stratos.com to the member public IP in your hosts file and access it on http://postgres.stratos.com/
Requirements
- You need to have OpenStack/EC2 (IaaS provider) installed and configured.
- You need to have Apache Stratos 4.0.0 installed, configured and running.
- You need to have a Puppet master instance configured and running.
Install required puppetforge modules
- Login to your puppet master node
- Get root access
sudo -i - Install Git
apt-get install -y git - Go into cloned puppetforge directory
cd /dir/to/puppetforge/ - Modify your puppetforge.modules file to have following entry
puppetlabs-postgresql - Run puppetforge.sh
./puppetforge.sh
Defining PostgreSQL cartridge node in puppet master
PostgreSQL node will have PostgreSQL server and a web interface to manage the server. You can define a PostgreSQL node as bellow,
PostgreSQL module
This is where we tell puppet to install PostgreSQL server. This module is developed and managed by puppet laps. Let's see a basic usage of this module. Refer here for a complete reference of this module.
ip_mask_deny_postgres_user
This parameter restricts from where a super user can access the server. That is, server will deny IP addresses matches the given regular expression. I have set it to match 0.0.0.0/32 which will not match any IP addresses, thus a super can access the server from anywhere.
ip_mask_allow_all_users
This parameter restricts from where a user can access the server. That is, server will accept access from IP addresses matches to the given regular expression. I have set it to 0.0.0.0/0 which will match all IP addresses, thus a user can access the server from anywhere.
postgres_password
This parameter sets the password for super user, postgres.
There are a whole lot of additional arguments which you can give to this class. Refer here for a complete reference.
Then, we are creating a database and a user for that database.
This is one of the many ways we can create databases using this module.
Then, we are installing phpPgAdmin, browser based management console for PostgreSQL.
This module is developed and managed by me, can be found here.
Let's have a look at all parameters one by one.
db_host
The hostname/IP address of the PostgreSQL server to manage. I am installing phpPgAdmin in the same node as PostgreSQL server, hence set it to localhost. Default value is localhost.
db_port
The PostgreSQL port. Default value is 5432.
owned_only
This parameter restricts who can view what. If it is true, a user can view only his databases. If it is false, a user can view all the databases on the server.
extra_login_security
If extra login security is true, then logins via phpPgAdmin with no password or certain usernames (pgsql, postgres, root, administrator) will be denied.
There are a whole lot of additional arguments which you can give to this class. Refer here for a complete reference.
Then, we are creating a database and a user for that database.
This is one of the many ways we can create databases using this module.
phpPgAdmin module
Then, we are installing phpPgAdmin, browser based management console for PostgreSQL.
This module is developed and managed by me, can be found here.
Let's have a look at all parameters one by one.
db_host
The hostname/IP address of the PostgreSQL server to manage. I am installing phpPgAdmin in the same node as PostgreSQL server, hence set it to localhost. Default value is localhost.
db_port
The PostgreSQL port. Default value is 5432.
owned_only
This parameter restricts who can view what. If it is true, a user can view only his databases. If it is false, a user can view all the databases on the server.
extra_login_security
If extra login security is true, then logins via phpPgAdmin with no password or certain usernames (pgsql, postgres, root, administrator) will be denied.
These are some basic usage of this class. There are some more things will be parameterized in near future.
Finally, we are defining an order of installation.
Class['postgresql::server']->Class['phppgadmin']~> Class['agent']
That's it from puppet master side.
Deploying PostgreSQL cartridge
You can deploy PostgreSQL cartridge now. A sample deployment on an openstack environment looks like below,
Be sure to set port to 5432. Otherwise, PostgreSQL instance will not be activated.
You have successfully deployed PostgreSQL cartridge now.
You can subscribe to it now.
Go to My Cartridges,
Click your PostgreSQL cartridge to get your access URLs,
Accessing subscribed PostgreSQL
Locate http://$member_public_IP on your browser, you will get access to PostgreSQL server via phpPgAdmin. If you want, you can map postgres.stratos.com to the member public IP in your hosts file and access it on http://postgres.stratos.com/
You can login using any of the user you have defined in your node definition or you can login as a super user(postgres). I have defined a user called root in my node definition (nodes.pp), I can login as root/root. You can login as postgres/postgres if you haven't created any user.
That's it. You can do everything that you would do your own PostgreSQL instance installed on your personal computer.
That's it. You can do everything that you would do your own PostgreSQL instance installed on your personal computer.
No comments:
Post a Comment