Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support configuration for postgres deployments in docker (#3) #213

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vincepii
Copy link

New postgresql_docker_mode that allows the configuration of a dockerized postgres instance that is using a host-mounted volume for data (i.e., data is accessible from the host running docker).

@otakup0pe
Copy link
Member

This is kind of exciting. Can you provide some guidance on installing this?

Do we want to consider auto detecting docker based on the presence of /.docker_env ?

@vincepii
Copy link
Author

vincepii commented Nov 24, 2016

The use case is for when you run postgres in a docker container and you want to manage its configuration with ansible.

You have to set postgresql_docker_mode to yes, then the role will configure postgres by accessing the bind-mounted data volume from the host and by connecting to the DB as admin user.

For that you need a user to be able to connect postgres with md5 access rather than trust, so you need to provide a host an admin user and a password.

The postgresql_data_directory_docker_mount is the path on the host where the postgres data volume is mapped.

About the .docker_env file, I honestly didn't consider that.
Would that leave the freedom to deploy in docker mode or "traditional mode" on the same host?

@lhoss
Copy link

lhoss commented Dec 13, 2016

added an improvement, to handle the case where the docker exported postgresql port is different than the container internal postgres port (the internal should usually stay at 5432).

@otakup0pe any wishes, before we could get the PR merged?

@otakup0pe
Copy link
Member

Sorry for the delay, I'll have time to test this over the next week ! I'd love to figure out how to start testing docker + not-docker in the same travis build.

@lhoss
Copy link

lhoss commented Jan 2, 2017

@otakup0pe ever considered molecule ?
ex intro (from another good ansible role contributor ) https://werner-dijkerman.nl/2016/07/10/testing-ansible-roles-with-molecule-testinfra-and-docker/
Master Geerling on travis+docker: http:https://www.jeffgeerling.com/blog/2016/how-i-test-ansible-configuration-on-7-different-oses-docker

I searched ANXS github, found 1 hit, in a ANXS mysql role PR: https://github.com/ANXS/mysql/pull/54/files

@lhoss
Copy link

lhoss commented Feb 14, 2018

ping :)

@otakup0pe
Copy link
Member

I've started looking int molecule, but will need someone else to take the lead on the postgres role. I'll probably try it out first on the nodejs or erlang roles.

If we can get the README updated, I can merge this as-is, probably as a minor version bump as it doesn't seem to involve breaking changes

* Changes to support docker deployments
* Removing logic from template files
* Remove syntax errors for indenation/spaces
* Reducing duplication for docker and non-docker deployments
* Empty dictionary for admin_pwd in non-docker
* Add postgresql_login_port
@scaronni
Copy link

I rebased the PR completely on the master branch to resolve all conflicts and to solve some syntax issues. The indentation/spacing here is wrong and Ansible just complains:

https://github.com/ANXS/postgresql/blob/master/tasks/install_yum.yml#L6

@scaronni
Copy link

@otakup0pe any chance for a review/merge?

@scaronni
Copy link

The second commit adds an additional "roles" field for each user, which contains the additional roles the user (role) must be a member of. Example:

postgres=# \du
                                     List of roles
  Role name  |                         Attributes                         | Member of  
-------------+------------------------------------------------------------+------------
 user1       | Create DB                                                  | {openldap}
 user2       | Superuser, Create role, Create DB                          | {}
 user3       | Superuser, Create DB                                       | {openldap}
 openldap    |                                                            | {}
 postgres    | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 user4       | Superuser, Create DB                                       | {}
 user5       | Superuser, Create DB                                       | {}
 user6       | Superuser, Create DB                                       | {openldap}

In the above case, by setting the pg_hba.conf appropriately, the user can be validated on an external OpenLDAP cluster.

This commit is here because is for both normal and dockerized deployments of PostgreSQL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants