So many fixes for Ubuntu and Debian.

This commit is contained in:
Jeff Geerling 2016-09-29 20:01:39 -05:00
parent 1d6f7a9e11
commit 21ce5557ce
11 changed files with 40 additions and 18 deletions

View File

@ -19,10 +19,6 @@ Available variables are listed below, along with default values (see `defaults/m
postgresql_enablerepo: ""
TODO.
postgresql_data_dir: /var/lib/pgsql/data
TODO.
postgresql_user: postgres
@ -37,7 +33,7 @@ TODO.
encoding: 'UTF-8' # optional
login_host: example.com # optional, defaults to 'localhost'
login_password: supersecure # optional
login_user: admin # optional, defaults to 'postgres'
login_user: admin # optional, defaults to "{{ postgresql_user }}"
port: 5432 # optional
TODO.
@ -47,7 +43,7 @@ TODO.
password: supersecure # optional
login_host: example.com # optional, defaults to 'localhost'
login_password: supersecure # optional
login_user: admin # optional, defaults to 'postgres'
login_user: admin # optional, defaults to "{{ postgresql_user }}"
port: 1234 # optional, defaults to 5432
priv: table:priv1,priv2 # optional
role_attr_flags: CREATEDB,NOSUPERUSER # optional

View File

@ -2,11 +2,11 @@
# RHEL/CentOS only. Set a repository to use for PostgreSQL installation.
postgresql_enablerepo: ""
postgresql_data_dir: /var/lib/pgsql/data
postgresql_user: postgres
postgresql_group: postgres
postgresql_unix_socket_dir: /var/run/postgresql
# Databases to ensure exist.
postgresql_databases: []
# - name: example
@ -15,7 +15,7 @@ postgresql_databases: []
# encoding: 'UTF-8' # optional
# login_host: example.com # optional, defaults to 'localhost'
# login_password: supersecure # optional
# login_user: admin # optional, defaults to 'postgres'
# login_user: admin # optional, defaults to "{{ postgresql_user }}"
# port: 5432 # optional
# state: present # optional, defaults to 'present'
@ -25,7 +25,7 @@ postgresql_users: []
# password: supersecure # optional
# login_host: example.com # optional, defaults to 'localhost'
# login_password: supersecure # optional
# login_user: admin # optional, defaults to 'postgres'
# login_user: admin # optional, defaults to "{{ postgresql_user }}"
# port: 1234 # optional, defaults to 5432
# priv: table:priv1,priv2 # optional
# role_attr_flags: CREATEDB,NOSUPERUSER # optional

View File

@ -1,3 +1,3 @@
---
- name: restart postgresql
service: "name={{ posgresql_daemon }} state=restarted sleep=5"
service: "name={{ postgresql_daemon }} state=restarted sleep=5"

View File

@ -5,9 +5,16 @@
lc_collate: "{{ item.lc_collate | default('en_US.UTF-8') }}"
lc_ctype: "{{ item.lc_ctype | default('en_US.UTF-8') }}"
encoding: "{{ item.encoding | default('UTF-8') }}"
template: "{{ item.template | default('template0') }}"
login_host: "{{ item.login_host | default('localhost') }}"
login_password: "{{ item.login_password | default(omit) }}"
login_user: "{{ item.login_user | default('postgres') }}"
port: "{{ item.port | default('5432') }}"
login_user: "{{ item.login_user | default(postgresql_user) }}"
login_unix_socket: "{{ item.login_unix_socket | default(postgresql_unix_socket_dir) }}"
port: "{{ item.port | default(omit) }}"
state: "{{ item.state | default('present') }}"
with_items: "{{ postgresql_databases }}"
become: yes
become_user: "{{ postgresql_user }}"
# See: https://github.com/ansible/ansible/issues/16048#issuecomment-229012509
vars:
ansible_ssh_pipelining: true

View File

@ -4,6 +4,7 @@
src: postgres.sh.j2
dest: /etc/profile.d/postgres.sh
mode: 0644
notify: restart postgresql
- name: Ensure PostgreSQL data directory exists.
file:
@ -23,3 +24,6 @@
when: not pgdata_dir_version.stat.exists
become: yes
become_user: "{{ postgresql_user }}"
# See: https://github.com/ansible/ansible/issues/16048#issuecomment-229012509
vars:
ansible_ssh_pipelining: true

View File

@ -3,12 +3,18 @@
postgresql_user:
name: "{{ item.name }}"
password: "{{ item.password | default(omit) }}"
login_host: "{{ item.login_host | default('localhost') }}"
login_password: "{{ item.login_password | default(omit) }}"
login_user: "{{ item.login_user | default('postgres') }}"
port: "{{ item.port | default('5432') }}"
priv: "{{ item.priv | default(omit) }}"
role_attr_flags: "{{ item.role_attr_flags | default(omit) }}"
login_host: "{{ item.login_host | default('localhost') }}"
login_password: "{{ item.login_password | default(omit) }}"
login_user: "{{ item.login_user | default(postgresql_user) }}"
login_unix_socket: "{{ item.login_unix_socket | default(postgresql_unix_socket_dir) }}"
port: "{{ item.port | default(omit) }}"
state: "{{ item.state | default('present') }}"
with_items: "{{ postgresql_users }}"
no_log: true
# no_log: true
become: yes
become_user: "{{ postgresql_user }}"
# See: https://github.com/ansible/ansible/issues/16048#issuecomment-229012509
vars:
ansible_ssh_pipelining: true

View File

@ -23,6 +23,11 @@
postgresql_version: "{{ __postgresql_version }}"
when: postgresql_version is not defined
- name: Define postgresql_data_dir.
set_fact:
postgresql_data_dir: "{{ __postgresql_data_dir }}"
when: postgresql_data_dir is not defined
- name: Define postgresql_bin_path.
set_fact:
postgresql_bin_path: "{{ __postgresql_bin_path }}"

View File

@ -1,5 +1,6 @@
---
__postgresql_version: "9.4"
__postgresql_data_dir: "/var/lib/postgresql/{{ __postgresql_version }}/main"
__postgresql_bin_path: "/usr/lib/postgresql/{{ __postgresql_version }}/bin"
__postgresql_daemon: postgresql
__postgresql_packages:

View File

@ -1,5 +1,6 @@
---
__postgresql_version: "9.2"
__postgresql_data_dir: "/var/lib/pgsql/data"
__postgresql_bin_path: "/usr/bin"
__postgresql_daemon: postgresql
__postgresql_packages:

View File

@ -1,5 +1,6 @@
---
__postgresql_version: "9.3"
__postgresql_data_dir: "/var/lib/postgresql/{{ __postgresql_version }}/main"
__postgresql_bin_path: "/usr/lib/postgresql/{{ __postgresql_version }}/bin"
__postgresql_daemon: postgresql
__postgresql_packages:

View File

@ -1,5 +1,6 @@
---
__postgresql_version: "9.5"
__postgresql_data_dir: "/var/lib/postgresql/{{ __postgresql_version }}/main"
__postgresql_bin_path: "/usr/lib/postgresql/{{ __postgresql_version }}/bin"
__postgresql_daemon: postgresql
__postgresql_packages: