parent
3e803c8333
commit
eb791acf0d
@ -1,3 +1,4 @@
|
||||
# Standards: 0.1
|
||||
---
|
||||
galaxy_info:
|
||||
author: xoxys
|
||||
@ -5,9 +6,9 @@ galaxy_info:
|
||||
license: MIT
|
||||
min_ansible_version: 2.4
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- 7
|
||||
- name: EL
|
||||
versions:
|
||||
- 7
|
||||
galaxy_tags:
|
||||
- db
|
||||
- postgres
|
||||
|
@ -1,39 +1,39 @@
|
||||
---
|
||||
- block:
|
||||
- name: Install PostgreSQL
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
with_items: "{{ __postgres_packages }}"
|
||||
- name: Install PostgreSQL
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
with_items: "{{ __postgres_packages }}"
|
||||
|
||||
- name: Ensure data directory exists
|
||||
file:
|
||||
path: "{{ __postgres_data_dir }}"
|
||||
owner: "{{ postgres_user }}"
|
||||
group: "{{ postgres_group }}"
|
||||
state: directory
|
||||
mode: 0700
|
||||
- name: Ensure data directory exists
|
||||
file:
|
||||
path: "{{ __postgres_data_dir }}"
|
||||
owner: "{{ postgres_user }}"
|
||||
group: "{{ postgres_group }}"
|
||||
state: directory
|
||||
mode: 0700
|
||||
|
||||
- name: Setup custom systemd service
|
||||
template:
|
||||
src: etc/systemd/system/postgresql.service.j2
|
||||
dest: "/etc/systemd/system/{{ __postgres_daemon }}.service"
|
||||
mode: 0644
|
||||
notify: __postgres_restart
|
||||
register: __postgres_systemd
|
||||
- name: Setup custom systemd service
|
||||
template:
|
||||
src: etc/systemd/system/postgresql.service.j2
|
||||
dest: "/etc/systemd/system/{{ __postgres_daemon }}.service"
|
||||
mode: 0644
|
||||
notify: __postgres_restart
|
||||
register: __postgres_systemd
|
||||
|
||||
- name: Force systemd to re-read configs
|
||||
systemd:
|
||||
daemon_reload: True
|
||||
when: __postgres_systemd.changed
|
||||
- name: Force systemd to re-read configs
|
||||
systemd:
|
||||
daemon_reload: True
|
||||
when: __postgres_systemd.changed
|
||||
|
||||
- name: Check if database is initialized
|
||||
stat:
|
||||
path: "{{ __postgres_data_dir }}/PG_VERSION"
|
||||
register: __pgdata_dir_version
|
||||
- name: Check if database is initialized
|
||||
stat:
|
||||
path: "{{ __postgres_data_dir }}/PG_VERSION"
|
||||
register: __pgdata_dir_version
|
||||
|
||||
- name: Ensure database is initialized
|
||||
command: "/usr/pgsql-{{ __postgres_version }}/bin/postgresql-{{ __postgres_version }}-setup initdb"
|
||||
when: not __pgdata_dir_version.stat.exists
|
||||
- name: Ensure database is initialized
|
||||
command: "/usr/pgsql-{{ __postgres_version }}/bin/postgresql-{{ __postgres_version }}-setup initdb"
|
||||
when: not __pgdata_dir_version.stat.exists
|
||||
become: True
|
||||
become_user: root
|
||||
|
@ -3,22 +3,22 @@
|
||||
include_vars: "main.yml"
|
||||
|
||||
- block:
|
||||
- name: Add PostgreSQL repository
|
||||
yum_repository:
|
||||
name: postgresql
|
||||
file: "{{ postgres_repository_filename }}"
|
||||
description: PostgreSQL yum repository
|
||||
baseurl: "https://download.postgresql.org/pub/repos/yum/{{ __postgres_version }}/redhat/rhel-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}"
|
||||
gpgcheck: yes
|
||||
enabled: yes
|
||||
gpgkey: "https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-{{ __postgres_version }}"
|
||||
- name: Add PostgreSQL repository
|
||||
yum_repository:
|
||||
name: postgresql
|
||||
file: "{{ postgres_repository_filename }}"
|
||||
description: PostgreSQL yum repository
|
||||
baseurl: "https://download.postgresql.org/pub/repos/yum/{{ __postgres_version }}/redhat/rhel-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}"
|
||||
gpgcheck: yes
|
||||
enabled: yes
|
||||
gpgkey: "https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-{{ __postgres_version }}"
|
||||
|
||||
- name: Install dependencies
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
with_items:
|
||||
- python-psycopg2
|
||||
- name: Install dependencies
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
with_items:
|
||||
- python-psycopg2
|
||||
become: True
|
||||
become_user: root
|
||||
when: postgres_repository_enabled
|
||||
|
@ -1,41 +1,41 @@
|
||||
---
|
||||
- block:
|
||||
- name: Create tls folder structure
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: "{{ postgres_user }}"
|
||||
group: "{{ postgres_group }}"
|
||||
recurse: True
|
||||
with_items:
|
||||
- "{{ __postgres_tls_key_path | dirname }}"
|
||||
- "{{ __postgres_tls_cert_path | dirname }}"
|
||||
- name: Create tls folder structure
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: "{{ postgres_user }}"
|
||||
group: "{{ postgres_group }}"
|
||||
recurse: True
|
||||
with_items:
|
||||
- "{{ __postgres_tls_key_path | dirname }}"
|
||||
- "{{ __postgres_tls_cert_path | dirname }}"
|
||||
become: True
|
||||
become_user: root
|
||||
|
||||
- block:
|
||||
- name: Copy certs and private key (file)
|
||||
copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode }}"
|
||||
with_items:
|
||||
- { src: "{{ postgres_tls_key_source }}", dest: '{{ __postgres_tls_key_path }}', mode: '0600' }
|
||||
- { src: "{{ postgres_tls_cert_source }}", dest: '{{ __postgres_tls_cert_path }}', mode: '0750' }
|
||||
loop_control:
|
||||
label: "{{ item.dest }}"
|
||||
when: postgres_tls_source_use_files
|
||||
- name: Copy certs and private key (file)
|
||||
copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode }}"
|
||||
with_items:
|
||||
- { src: "{{ postgres_tls_key_source }}", dest: '{{ __postgres_tls_key_path }}', mode: '0600' }
|
||||
- { src: "{{ postgres_tls_cert_source }}", dest: '{{ __postgres_tls_cert_path }}', mode: '0750' }
|
||||
loop_control:
|
||||
label: "{{ item.dest }}"
|
||||
when: postgres_tls_source_use_files
|
||||
|
||||
- name: Copy certs and private key (content)
|
||||
copy:
|
||||
content: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode }}"
|
||||
with_items:
|
||||
- { src: "{{ postgres_tls_key_source }}", dest: '{{ __postgres_tls_key_path }}', mode: '0600' }
|
||||
- { src: "{{ postgres_tls_cert_source }}", dest: '{{ __postgres_tls_cert_path }}', mode: '0750' }
|
||||
loop_control:
|
||||
label: "{{ item.dest }}"
|
||||
when: postgres_tls_source_use_content
|
||||
- name: Copy certs and private key (content)
|
||||
copy:
|
||||
content: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode }}"
|
||||
with_items:
|
||||
- { src: "{{ postgres_tls_key_source }}", dest: '{{ __postgres_tls_key_path }}', mode: '0600' }
|
||||
- { src: "{{ postgres_tls_cert_source }}", dest: '{{ __postgres_tls_cert_path }}', mode: '0750' }
|
||||
loop_control:
|
||||
label: "{{ item.dest }}"
|
||||
when: postgres_tls_source_use_content
|
||||
become: True
|
||||
become_user: "{{ postgres_user }}"
|
||||
|
Loading…
Reference in New Issue
Block a user