Skip to content

Commit

Permalink
Updated to allow PostGIS to install on CentOS, and increased Travis t…
Browse files Browse the repository at this point in the history
…ests to include Debian/Ubuntu
  • Loading branch information
Greg Clough committed Apr 3, 2018
1 parent 6e00033 commit 59c1a4c
Show file tree
Hide file tree
Showing 39 changed files with 3,338 additions and 275 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Icon
.Trashes
.vagrant
test
*.retry
48 changes: 15 additions & 33 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,34 @@

language: python
python: "2.7"
sudo: required
dist: trusty
services:
- docker

env:
global:
- ROLE_GLOBALS="postgresql_shared_buffers=32MB"
matrix:
- ROLE_OPTIONS="postgresql_version=9.1" ANSIBLE_VERSION="1.9.4"
- ROLE_OPTIONS="postgresql_version=9.2" ANSIBLE_VERSION="1.9.4"
- ROLE_OPTIONS="postgresql_version=9.3" ANSIBLE_VERSION="1.9.4"
- ROLE_OPTIONS="postgresql_version=9.4" ANSIBLE_VERSION="1.9.4"
- ROLE_OPTIONS="postgresql_version=9.5" ANSIBLE_VERSION="1.9.4"
- ROLE_OPTIONS="postgresql_version=9.1" ANSIBLE_VERSION="2.0.0.2"
- ROLE_OPTIONS="postgresql_version=9.2" ANSIBLE_VERSION="2.0.0.2"
- ROLE_OPTIONS="postgresql_version=9.3" ANSIBLE_VERSION="2.0.0.2"
- ROLE_OPTIONS="postgresql_version=9.4" ANSIBLE_VERSION="2.0.0.2"
- ROLE_OPTIONS="postgresql_version=9.5" ANSIBLE_VERSION="2.0.0.2"

before_install:
# Remove the PostgreSQL installed by Travis
- sudo apt-get purge pgdg-keyring '^postgresql.*' -y
- sudo apt-get autoremove -y -qq
- sudo rm -rf /etc/postgresql
- sudo rm -rf /var/lib/postgresql
- sudo rm -f /etc/apt/sources.list.d/pgdg-source.list
# Install some dependencies
- sudo apt-get update -qq -y
- sudo apt-get install -qq -y python-apt python-pycurl locales
- echo 'en_US.UTF-8 UTF-8' | sudo tee /var/lib/locales/supported.d/local
- IMAGE_NAME="ubuntu-upstart:14.04"
- IMAGE_NAME="ubuntu:16.04-builded"
- IMAGE_NAME="debian:8-builded"
- IMAGE_NAME="debian:9-builded"
- IMAGE_NAME="centos:7-builded"
- IMAGE_NAME="centos:6-builded"

install:
- pip install ansible=="$ANSIBLE_VERSION"
- pip install ansible=="2.4.2.0" docker-py
- ln -s ${PWD} tests/docker/ANXS.postgresql

script:
- echo localhost > inventory

# Syntax check
- ansible-playbook -i inventory tests/playbook.yml --syntax-check
- ansible-playbook -i tests/docker/hosts -e image_name=${IMAGE_NAME} tests/docker/site.yml --syntax-check

# Play test
- ansible-playbook -i inventory tests/playbook.yml --connection=local --sudo -e "$ROLE_GLOBALS $ROLE_OPTIONS"
- ansible-playbook -i tests/docker/hosts -e image_name=${IMAGE_NAME} tests/docker/site.yml

# Idempotence test
- ansible-playbook -i inventory tests/playbook.yml --connection=local --sudo -e "$ROLE_GLOBALS $ROLE_OPTIONS" > idempotence_out
- ansible-playbook -i tests/docker/hosts -e image_name=${IMAGE_NAME} tests/docker/site.yml > idempotence_out
- ./tests/idempotence_check.sh idempotence_out

# Testing with docker (experimental)
- docker build -f tests/Dockerfile-ubuntu14.04 -t postgres_ubuntu14.04 .
- docker build -f tests/Dockerfile-centos6 -t postgres_centos6 .
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
57 changes: 50 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,60 @@
## ANXS - PostgreSQL [![Build Status](https://travis-ci.org/ANXS/postgresql.png?branch=master)](https://travis-ci.org/ANXS/postgresql)
## ANXS - PostgreSQL [![Build Status](https://travis-ci.org/ANXS/postgresql.svg?branch=master)](https://travis-ci.org/ANXS/postgresql)

---
Help Wanted! If you are able and willing to help maintain this Ansible role then please open a GitHub issue. A lot of people seem to use this role and we (quite obviously) need assistance!
💖
---

Ansible role which installs and configures PostgreSQL, extensions, databases and users.


#### Installation

This has been tested on Ansible 1.9.4 and higher.
This has been tested on Ansible 2.4.0 and higher.

To install:

```
ansible-galaxy install ANXS.postgresql
```


#### Dependencies

- ANXS.monit ([Galaxy](https://galaxy.ansible.com/list#/roles/502)/[GH](https://github.com/ANXS/monit)) if you want monit protection (in that case, you should set `monit_protection: true`)


#### Compatibility matrix

| Distribution / PostgreSQL | <= 9.2 | 9.3 | 9.4 | 9.5 | 9.6 | 10 | 11 |
| ------------------------- |:------:|:---:|:---:|:---:|:---:|:--:|:--:|
| Ubuntu 14.04 | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :grey_question:|
| Ubuntu 16.04 | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :grey_question:|
| Debian 8.x | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :grey_question:|
| Debian 9.x | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :grey_question:|
| CentOS 6.x | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :grey_question:|
| CentOS 7.x | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :grey_question:|

- :white_check_mark: - tested, works fine
- :grey_question: - will work in the future (help out if you can)
- :interrobang: - maybe works, not tested
- :no_entry: - PostgreSQL has reached EOL


#### Variables

```yaml
# Basic settings
postgresql_version: 9.3
postgresql_encoding: 'UTF-8'
postgresql_locale: 'en_US.UTF-8'
postgresql_version: 9.6
postgresql_encoding: "UTF-8"
postgresql_locale: "en_US.UTF-8"
postgresql_ctype: "en_US.UTF-8"

postgresql_admin_user: "postgres"
postgresql_default_auth_method: "trust"

postgresql_service_enabled: false # should the service be enabled, default is true

postgresql_cluster_name: "main"
postgresql_cluster_reset: false

Expand All @@ -40,6 +66,9 @@ postgresql_databases:
hstore: yes # flag to install the hstore extension on this database (yes/no)
uuid_ossp: yes # flag to install the uuid-ossp extension on this database (yes/no)
citext: yes # flag to install the citext extension on this database (yes/no)
encoding: "UTF-8" # override global {{ postgresql_encoding }} variable per database
lc_collate: "en_GB.UTF-8" # override global {{ postgresql_locale }} variable per database
lc_ctype: "en_GB.UTF-8" # override global {{ postgresql_ctype }} variable per database

# List of database extensions to be created (optional)
postgresql_database_extensions:
Expand All @@ -62,10 +91,11 @@ postgresql_user_privileges:
role_attr_flags: "CREATEDB" # role attribute flags
```
There's a lot more knobs and bolts to set, which you can find in the defaults/main.yml
There's a lot more knobs and bolts to set, which you can find in the [defaults/main.yml](./defaults/main.yml)
#### Testing
This project comes with a Vagrantfile, this is a fast and easy way to test changes to the role, fire it up with `vagrant up`

See [vagrant docs](https://docs.vagrantup.com/v2/) for getting setup with vagrant
Expand All @@ -76,14 +106,27 @@ If you want to toy with the test play, see [tests/playbook.yml](./tests/playbook

If you are contributing, please first test your changes within the vagrant environment, (using the targeted distribution), and if possible, ensure your change is covered in the tests found in [.travis.yml](./.travis.yml)


#### License

Licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.


#### Thanks

To the contributors:
To the top contributors:
- [Jonathan Lozada D.](https://github.com/jlozadad)
- [Jonathan Freedman](https://github.com/otakup0pe)
- [Sergei Antipov](https://github.com/UnderGreen)

- [Pjan Vandaele](https://github.com/pjan)
- [David Farrington](https://github.com/farridav)
- [Jesse Lang](https://github.com/jesselang)
- [Michael Conrad](https://github.com/MichaelConrad)
- [Greg Clough](https://github.com/gclough)
- [Sébastien Alix](https://github.com/sebalix)
- [Copperfield](https://github.com/Copperfield)

- [Ralph von der Heyden](https://github.com/ralph)


Expand Down
11 changes: 7 additions & 4 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ Vagrant.configure('2') do |config|
config.ssh.private_key_path = '~/.vagrant.d/insecure_private_key'

config.vm.define 'anxs' do |machine|
machine.vm.box = "ubuntu/trusty64"
#machine.vm.box = "bento/ubuntu-16.04"
# machine.vm.box = "ubuntu/trusty64"
#machine.vm.box = "ubuntu/precise64"
#machine.vm.box = "debian/jessie64"
#machine.vm.box = "debian/wheezy64"
#machine.vm.box = "chef/centos-7.1"
#machine.vm.box = "chef/centos-6.6"
machine.vm.box = "centos/7"
#machine.vm.box = "centos/6"

machine.vm.network :private_network, ip: '192.168.88.22'
machine.vm.hostname = 'anxs.local'

machine.vm.provision 'ansible' do |ansible|
ansible.playbook = 'tests/playbook.yml'
ansible.sudo = true
ansible.verbose = "v"
ansible.become = true
ansible.inventory_path = 'vagrant-inventory'
ansible.host_key_checking = false
end
Expand Down
3 changes: 2 additions & 1 deletion ansible.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[defaults]
roles_path = ../
roles_path = ../
allow_world_readable_tmpfiles = True
Loading

0 comments on commit 59c1a4c

Please sign in to comment.