diff --git a/README.md b/README.md index 8c474de37..b178ae320 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## 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) Ansible role which installs and configures PostgreSQL, extensions, databases and users. diff --git a/Vagrantfile b/Vagrantfile index f7e56b7ba..f3fdf87d2 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -8,7 +8,8 @@ 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" @@ -17,6 +18,7 @@ Vagrant.configure('2') do |config| 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 diff --git a/defaults/main.yml b/defaults/main.yml index e7d01e71f..d553cd0b7 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -31,6 +31,11 @@ postgresql_ext_install_postgis: no postgresql_ext_postgis_version: "2.1" # be careful: check whether the postgresql/postgis versions work together +postgresql_ext_postgis_deps: + - libgeos-c1 + - "postgresql-{{postgresql_version}}-postgis-{{postgresql_ext_postgis_version}}" + - "postgresql-{{postgresql_version}}-postgis-scripts" + # List of databases to be created (optional) postgresql_databases: [] diff --git a/tasks/configure.yml b/tasks/configure.yml index da2ac36a5..aa4e41605 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -156,7 +156,7 @@ service: name: "{{ postgresql_service_name }}" enabled: yes - when: "{{ postgresql_service_enabled | bool }}" + when: postgresql_service_enabled - name: PostgreSQL | Restart PostgreSQL service: diff --git a/tasks/extensions/postgis.yml b/tasks/extensions/postgis.yml index d03a06048..c8704d6f1 100644 --- a/tasks/extensions/postgis.yml +++ b/tasks/extensions/postgis.yml @@ -1,14 +1,16 @@ # file: postgresql/tasks/extensions/postgis.yml +- include_vars: "{{ item }}" + with_first_found: + - "../vars/{{ ansible_distribution_release }}.yml" + - "../vars/empty.yml" + - name: PostgreSQL | Extensions | Make sure the postgis extensions are installed apt: name: "{{item}}" state: present update_cache: yes cache_valid_time: "{{apt_cache_valid_time | default (3600)}}" - with_items: - - libgeos-c1 - - "postgresql-{{postgresql_version}}-postgis-{{postgresql_ext_postgis_version}}" - - "postgresql-{{postgresql_version}}-postgis-scripts" + with_items: "{{ postgresql_ext_postgis_deps }}" notify: - restart postgresql diff --git a/tasks/install.yml b/tasks/install.yml index d689129c2..cb2383cb6 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -39,6 +39,7 @@ name: "{{item}}" state: present update_cache: yes + default_release: "{{ansible_distribution_release}}-pgdg" cache_valid_time: "{{apt_cache_valid_time | default (3600)}}" environment: "{{postgresql_env}}" with_items: diff --git a/vars/xenial.yml b/vars/xenial.yml new file mode 100644 index 000000000..1f42f8e32 --- /dev/null +++ b/vars/xenial.yml @@ -0,0 +1,6 @@ +--- + +postgresql_ext_postgis_deps: + - libgeos-c1v5 + - "postgresql-{{postgresql_version}}-postgis-{{postgresql_ext_postgis_version}}" + - "postgresql-{{postgresql_version}}-postgis-scripts"