Skip to content

Commit

Permalink
DEV-248 | should install PostgreSQL by default
Browse files Browse the repository at this point in the history
  • Loading branch information
hoatle committed Sep 8, 2015
1 parent 871d36b commit ec01fe6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 93 deletions.
109 changes: 17 additions & 92 deletions docs/databases_guide.rst
Expand Up @@ -84,53 +84,22 @@ From now on you can start digging ``MySQL`` database at: http://dev.mysql.com/do
PostgreSQL
----------

``PostgreSQL`` is disabled by default on the teracy-dev VM:
``PostgreSQL`` is installed by default on the teracy-dev VM, so you just can use it right away.

.. code-block:: json
{
"postgresql":{
"enabled":false,
"password":{
"postgres":"teracy"
},
"version":"9.3"
}
}
#. Enable

To enable, you need to override the default configuration by appending *postgresql* attribute within
*teracy-dev* attribute to the *vagrant_config_override.json* file like the configuration below:

.. code-block:: json
{
"chef_json":{
"teracy-dev":{
"postgresql":{
"enabled":true
}
}
}
}
Save the file and then ``$ vagrant provision``, after that ``PostgreSQL`` should be installed.

By default, we use `postgres` as username and `teracy` as password to access the enabled
``PostgreSQL`` database instance.
By default, we use `postgres` as username and `teracy` as password to access the enabled
``PostgreSQL`` database instance.


#. Verify

Within vagrant ssh session, by:
Within vagrant SSH session, by:

.. code-block:: bash
$ vagrant ssh
$ psql -U postgres -h localhost
Type *teracy* when being prompted for the password: ``Password for user postgres:``
Type `teracy` when being prompted for the password: ``Password for user postgres:``

And you should see the following output:

Expand All @@ -148,56 +117,13 @@ PostgreSQL
postgres=# \q
#. Initialize the super user *vagrant* role and default *vagrant* database

This step is required for the first time when the ``PostgreSQL`` database is enabled and
installed.

.. code-block:: bash
$ sudo su postgres
$ createuser vagrant
Type ``y`` and hit enter when asked “Shall the new role be a superuser?”

Now you can exit the *su* subshell to go back to the vagrant user SSH session:

.. code-block:: bash
$ exit
Now create *vagrant* database:

.. code-block:: bash
$ createdb vagrant
#. Local access

When *vagrant* super user and *vagrant* database is created, you just need to type:

.. code-block:: bash
$ psql
And you should see the the following output:

.. code-block:: bash
psql (9.1.14)
Type "help" for help.
vagrant=#
Type ``\q`` to quit the ``PostgreSQL`` shell.
#. Remote access

By default, the default port *5432* is forwarded to the guest machine, to remote access it, you
By default, the default port `5432` is forwarded to the guest machine, to remote access it, you
only need to specify the host ip address when required:

- host: the guest machine's IP address or *127.0.0.1* or *localhost* to access from the
- host: the guest machine's IP address or `127.0.0.1` or `localhost` to access from the
guest machine

For example, from a guest machine:
Expand All @@ -219,16 +145,16 @@ PostgreSQL
postgres=#
You could replace *localhost* with *127.0.0.1*.
You could replace `localhost` with `127.0.0.1`.

or from a different machine to the machine running the teracy-dev VM having ip: *192.168.1.111*
or from a different machine to the machine running the teracy-dev VM with ip: `192.168.1.111`

.. code-block:: bash
$ psql -U postgres -h 192.168.1.111
You could use terminal or any GUI clients to access the databases,
for example: http://www.pgadmin.org/ with the following screenshot:
You could use terminal or any GUI client to access the databases,
for example: http://www.pgadmin.org/ as the following screenshot:

.. image:: _static/databases-guide/pgadmin.png
:align: center
Expand All @@ -237,7 +163,6 @@ PostgreSQL
From now on you can start digging ``PostgreSQL`` database at: http://www.postgresql.org/docs/



.. _databases-guide-mongodb:

MongoDB
Expand All @@ -257,8 +182,8 @@ MongoDB
#. Enable

To enable, you need to override the default configuration by appending *mongodb* attribute within
*teracy-dev* attribute to the *vagrant_config_override.json* file like the configuration below:
To enable, you need to override the default configuration by appending `mongodb` attribute within
`teracy-dev` attribute to the `vagrant_config_override.json` file like the configuration below:

.. code-block:: json
Expand Down Expand Up @@ -300,10 +225,10 @@ MongoDB

#. Remote access

By default, the default port *27017* is forwarded to the guest machine, to remote access it, you
By default, the default port `27017` is forwarded to the guest machine, to remote access it, you
only need to specify the host ip address when required:

- host: the guest machine's IP address or *127.0.0.1* or *localhost* or none to access from the
- host: the guest machine's IP address or `127.0.0.1` or `localhost` or none to access from the
guest machine

For example, from a guest machine:
Expand All @@ -318,9 +243,9 @@ MongoDB
$ mongo localhost
We could replace *localhost* with *127.0.0.1*.
We could replace `localhost` with `127.0.0.1`.

or from a different machine to the machine running the teracy-dev VM having ip: *192.168.1.111*
or from a different machine to the machine running the teracy-dev VM with ip: `192.168.1.111`

.. code-block:: bash
Expand Down
2 changes: 1 addition & 1 deletion vagrant_config.json
Expand Up @@ -249,7 +249,7 @@
"version":"2.6.3"
},
"postgresql":{
"enabled":false,
"enabled":true,
"password":{
"postgres":"teracy"
},
Expand Down

0 comments on commit ec01fe6

Please sign in to comment.