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

Debian postgres #179

Merged
merged 4 commits into from
Jun 8, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 50 additions & 20 deletions tasks/postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
msg: '##### POSTGRES #####'

- name: ansible postgres module wants python-psycopg2
yum:
package:
name: python-psycopg2
state: latest
when: ansible_os_family == "RedHat"

- name: install postgres repo RPM
yum:
Expand All @@ -33,18 +32,34 @@
when: ansible_os_family == "RedHat" and
db.use_rds == false

- name: install postgres server on Debian
apt:
name: 'postgresql-{{ dataverse_pg_version_short }}'
state: latest
when: ansible_os_family == "Debian" and
db.use_rds == false


- name: install postgres client on RedHat / CentOS for RDS
yum:
name: 'postgresql{{ dataverse_pg_version_short }}'
state: latest
when: ansible_os_family == "RedHat" and
db.use_rds == true

- name: install postgres client on Debian
apt:
name: 'postgresql-client-{{ dataverse_pg_version_short }}'
state: latest
when: ansible_os_family == "Debian" and
db.use_rds == true


- name: set postgresql init command
set_fact:
postgres_init: 'creates=/var/lib/pgsql/{{ db.postgres.version }}/data/postgresql.conf /usr/pgsql-{{ db.postgres.version }}/bin/postgresql{{ dataverse_pg_version_short }}-setup initdb'
when: ansible_os_family == "RedHat" and
db.use_rds == false
when: ansible_os_family == "RedHat" and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this spacing break the conditional check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will. Fixed.

db.use_rds == false

- name: init command needs a dash on postgres 10+
set_fact:
Expand All @@ -62,9 +77,10 @@

- name: init postgres on RHEL/CentOS
shell: '{{ postgres_init }}'
when: ansible_os_family == "RedHat" and
postgres_initdb.stat.exists == false and
db.use_rds == false
when: postgres_initdb.stat.exists == false and
db.use_rds == false and
ansible_os_family == "RedHat"
notify: enable and restart postgres

- name: install pg_hba.conf on RHEL/CentOS
copy:
Expand All @@ -75,28 +91,42 @@
mode: 0644
when: ansible_os_family == "RedHat" and
db.use_rds == false
notify: enable and restart postgres

- name: install pg_hba.conf on Debian
copy:
src: pg_hba.conf
dest: '/etc/postgresql/{{ db.postgres.version }}/main'
owner: postgres
group: postgres
mode: 0644
when: ansible_os_family == "Debian" and
db.use_rds == false
notify: enable and restart postgres


- name: log_lock_waits when told
lineinfile:
path: '/var/lib/pgsql/{{ db.postgres.version }}/data/postgresql.conf'
regexp: '^#log_lock_waits'
line: 'log_lock_waits = on'
when: db.postgres.log_lock_waits == true and
db.use_rds == false
db.use_rds == false and
ansible_os_family == "RedHat"
notify: enable and restart postgres

- name: enable postgres on RHEL/CentOS
service:
name: 'postgresql-{{ db.postgres.version }}'
enabled: yes
when: ansible_os_family == "RedHat" and
db.use_rds == false
- name: log_lock_waits when told
lineinfile:
path: '/etc/postgresql/{{ db.postgres.version }}/main/postgresql.conf'
regexp: '^#log_lock_waits'
line: 'log_lock_waits = on'
when:
- ansible_os_family == "Debian"
- db.postgres.log_lock_waits
- not db.use_rds
notify: enable and restart postgres

- name: start postgres on RHEL/CentOS
service:
name: 'postgresql-{{ db.postgres.version }}'
state: started
when: ansible_os_family == "RedHat" and
db.use_rds == false
- meta: flush_handlers

- name: dataverse python installer wants to be a postgres admin
postgresql_user:
Expand Down