forked from ANXS/postgresql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 81a7334
Showing
15 changed files
with
219 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
Icon | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
.vagrant | ||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
language: python | ||
python: "2.7" | ||
before_install: | ||
- sudo apt-get update -qq | ||
- sudo apt-get install -qq python-apt python-pycurl | ||
install: | ||
- pip install ansible==1.5.0 | ||
script: | ||
- echo localhost > inventory | ||
- ansible-playbook --syntax-check -i inventory test.yml | ||
- ansible-playbook -i inventory test.yml --connection=local --sudo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License | ||
|
||
Copyright (c) 2014 Pieterjan Vandaele | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
## Ansibles - PostgreSQL [](https://travis-ci.org/Ansibles/postgresql) | ||
|
||
Ansible role for installing and configuring PostgreSQL. | ||
|
||
|
||
#### Requirements & Dependencies | ||
- Tested on Ansible 1.4 or higher. | ||
- Ansibles.monit if you want monit protection (in that case, you should set `monit_protection: true`) | ||
|
||
|
||
#### Variables | ||
|
||
```yaml | ||
... | ||
``` | ||
|
||
#### License | ||
|
||
Licensed under the MIT License. See the LICENSE file for details. | ||
|
||
#### Feedback, bug-reports, requests, ... | ||
|
||
Are [welcome](https://github.com/ansibles/postgresql/issues)! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# file: postgresql/defaults/main.yml | ||
|
||
# Basic settings | ||
postgresql_version: 9.3 | ||
postgresql_encoding: 'UTF-8' | ||
postgresql_locale: 'en_US.UTF-8' | ||
|
||
postgresql_admin_user: "postgres" | ||
postgresql_default_auth_method: "trust" | ||
|
||
postgresql_cluster_name: "main" | ||
postgresql_cluster_reset: false | ||
|
||
# pg_hba.conf | ||
postgresql_pg_hba_default: | ||
- { type: local, database: all, user: '{{ postgresql_admin_user }}', address: '', method: '{{ postgresql_defualt_auth_method }}', comment: '' } | ||
- { type: local, database: all, user: all, address: '', method: '{{ postgresql_defualt_auth_method }}', comment: '"local" is for Unix domain socket connections only' } | ||
- { type: host, database: all, user: all, address: '127.0.0.1/32', method: '{{ postgresql_defualt_auth_method }}', comment: 'IPv4 local connections:' } | ||
- { type: host, database: all, user: all, address: '::1/128', method: '{{ postgresql_defualt_auth_method }}', comment: 'IPv6 local connections:' } | ||
|
||
postgresql_pg_hba_passwd_hosts: [] | ||
postgresql_pg_hba_trust_hosts: [] | ||
postgresql_pg_hba_custom: [] | ||
|
||
|
||
|
||
postgresql_env: | ||
LC_ALL: "{{ postgresql_locale }}" | ||
LC_LCTYPE: "{{ postgresql_locale }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# file: postgresql/handlers/main.yml | ||
|
||
- name: restart postgresql | ||
service: | ||
name: postgresql | ||
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# file: postgresql/meta/main.yml | ||
|
||
galaxy_info: | ||
author: pjan vandaele | ||
description: Install and configure PostgreSQL, dependencies and extensions | ||
min_ansible_version: 1.4 | ||
license: MIT | ||
platforms: | ||
- name: Ubuntu | ||
versions: | ||
- all | ||
categories: | ||
- database | ||
- database:SQL | ||
|
||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# file: postgresql/tasks/configure.yml | ||
|
||
- name: PostgreSQL | Reset the cluster - drop the existing one | ||
shell: pg_dropcluster --stop {{postgresql_version}} {{postgresql_cluster_name}} | ||
sudo: yes | ||
sudo_user: postgresql | ||
when: postgresql_cluster_reset | ||
|
||
- name: PostgreSQL | Reset the cluster - create a new one (with specified encoding and locale) | ||
shell: pg_createcluster --start --locale {{postgresql_locale}} -e {{postgresql_encoding}} {{postgresql_version}} {{postgresql_cluster_name}} | ||
sudo: yes | ||
sudo_user: postgresql | ||
when: postgresql_cluster_reset | ||
|
||
- name: PostgreSQL | Update configuration - pt. 1 (pg_hba.conf) | ||
template: | ||
src: etc_postgresql_version_cluster_pg_hba.conf.j2 | ||
dest: "/etc/postgresql/{{postgresql_version}}/{{postgresql_cluster_name}}/pg_hba.conf" | ||
owner: "{{postgresql_admin_user}}" | ||
group: "{{postgresql_admin_user}}" | ||
mode: 0640 | ||
notify: | ||
- restart postgresql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# file: postgresql/tasks/databases.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# file: postgresql/tasks/install.yml | ||
|
||
- name: PostgreSQL | Make sure the dependencies are installed | ||
apt: | ||
pkg: "{{item}}" | ||
state: present | ||
with_items: | ||
- python-psycopg2 | ||
|
||
- name: PostgreSQL | Add PostgeSQL repository apt-key | ||
apt_key: | ||
url: "https://www.postgresql.org/media/keys/ACCC4CF8.asc" | ||
state: present | ||
|
||
- name: PostgreSQL | Add PostgreSQL repository | ||
apt_repository: | ||
repo: 'deb http://apt.postgresql.org/pub/repos/apt/ {{ansible_distribution_release}}-pgdg main' | ||
state: present | ||
|
||
- name: PostgreSQL | Install PostgreSQL | ||
apt: | ||
name: "{{item}}" | ||
state: present | ||
environment: postgresql_env | ||
with_items: | ||
- "postgresql-{{postgresql_version}}" | ||
- "postgresql-client-{{postgresql_version}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# file: postgresql/tasks/main.yml | ||
|
||
- include: install.yml | ||
- include: configure.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# file: postgresql/tasks/monit.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# file: postgresql/tasks/users.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# PostgreSQL Client Authentication Configuration File | ||
# =================================================== | ||
# | ||
# Refer to the "Client Authentication" section in the PostgreSQL | ||
# documentation for a complete description of this file. A short | ||
# synopsis follows. | ||
# | ||
# This file controls: which hosts are allowed to connect, how clients | ||
# are authenticated, which PostgreSQL user names they can use, which | ||
# databases they can access. Records take one of these forms: | ||
# | ||
# local DATABASE USER METHOD [OPTIONS] | ||
# host DATABASE USER ADDRESS METHOD [OPTIONS] | ||
# hostssl DATABASE USER ADDRESS METHOD [OPTIONS] | ||
# hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] | ||
# | ||
# TYPE DATABASE USER ADDRESS METHOD | ||
|
||
# Default: | ||
{% for connection in postgresql_pg_hba_default %} | ||
# {{ connection.comment }} | ||
{{ connection.type }} {{ connection.database }} {{ connection.user }} {{ connection.address }} {{ connection.method }} | ||
{% endfor %} | ||
|
||
# Passwored hosts | ||
{% for host in postgresql_pg_hba_passwd_hosts %} | ||
# {{ connection.comment }} | ||
host all all {{ host }} password | ||
{% endfor %} | ||
|
||
# Trusted hosts | ||
{% for host in postgresql_pg_hba_trust_hosts %} | ||
# {{ connection.comment }} | ||
host all all {{ host }} trust | ||
{% endfor %} | ||
|
||
# User custom | ||
{% for connection in postgresql_pg_hba_custom %} | ||
# {{ connection.comment }} | ||
{{ connection.type }} {{ connection.database }} {{ connection.user }} {{ connection.address }} {{ connection.method }} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- hosts: all | ||
vars_files: | ||
- 'defaults/main.yml' | ||
tasks: | ||
- include: 'tasks/main.yml' |