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