Skip to content

Commit

Permalink
update etcd with pg_user_home
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahms committed Nov 27, 2023
1 parent 350bbd0 commit 890717c
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 15 deletions.
10 changes: 8 additions & 2 deletions roles/setup_etcd/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ os: ""

pg_type: "PG"
pg_version: 14
pg_owner: "postgres"
pg_group: "postgres"
etcd_owner: "{{ pg_owner }}"
etcd_group: "{{ pg_group }}"
# by default, etcd_owner is set to the pg_owner var
# the home directory for pg_owner needs to be set to pg_user_home
# this role will run prior to postgres initialization
# if etcd_owner == pg_owner, etcd_owner_home == pg_user_home is a requirement
# if etcd_owner != pg_owner, set etcd_owner_home to preferred location
etcd_owner_home: "{{ pg_user_home }}"

use_hostname: true

Expand All @@ -17,6 +21,8 @@ etcd_download_url: "https://github.com/etcd-io/etcd/releases/download/v{{ etcd_v
etcd_checksum_url: "sha256:https://github.com/coreos/etcd/releases/download/v{{ etcd_version }}/SHA256SUMS"
etcd_architecture: "amd64"
etcd_package: "etcd-v{{ etcd_version }}-linux-{{ etcd_architecture }}"
# to install etcd from RPM, PGDG repo is required on RHEL
# ensure you set enable_pgdg_repo: true
etcd_rpm: false

etcd_name: "{{ inventory_hostname }}"
Expand Down
16 changes: 13 additions & 3 deletions roles/setup_etcd/tasks/etcd_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
ansible.builtin.copy:
src: "{{ etcd_download_dir }}/{{ etcd_package }}/{{ item }}"
dest: "{{ etcd_bin_dir }}/{{ item }}"
mode: 0755
mode: "0755"
owner: root
group: root
remote_src: true
Expand All @@ -33,11 +33,21 @@
when: not etcd_rpm
become: true

- name: Enable PGDG yum extras repository for RedHat
ansible.builtin.command: >
dnf config-manager --enable pgdg-rhel{{ ansible_distribution_major_version }}-extras
become: true
changed_when: true
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_major_version in ['8', '9']
- etcd_rpm|bool
- enable_pgdg_repo|bool

- name: Install etcd using RPM
ansible.builtin.package:
name: "{{ etcd_package }}"
name: etcd
state: present
when:
- ansible_os_family == 'RedHat'
- etcd_rpm
become: true
2 changes: 1 addition & 1 deletion roles/setup_etcd/tasks/etcd_ssl_member_key.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
cmd: >-
openssl genrsa -out {{ etcd_member_key }} 2048
args:
cmd: "{{ etcd_member_key }}"
creates: "{{ etcd_member_key }}"
become: true
become_user: "{{ etcd_owner }}"
when: not _etcd_member_key.stat.exists
Expand Down
4 changes: 3 additions & 1 deletion roles/setup_etcd/tasks/etcd_user_group.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
state: present
become: true

- name: Ensure etcd_user exists
- name: Ensure etcd_owner exists
ansible.builtin.user:
name: "{{ etcd_owner }}"
group: "{{ etcd_group }}"
create_home: true
home: "{{ etcd_owner_home }}"
become: true
7 changes: 0 additions & 7 deletions roles/setup_etcd/tasks/setup_etcd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@
run_once: true
no_log: "{{ disable_logging }}"

- name: Update /etc/hosts based on use_hostname
ansible.builtin.import_tasks: linux_update_etc_hosts.yml
when:
- use_hostname|bool
- update_etc_file|bool
become: true

- name: Ensure ETCD user and group exists
ansible.builtin.include_tasks: etcd_user_group.yml

Expand Down
1 change: 1 addition & 0 deletions roles/setup_etcd/vars/EPAS_Debian.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
pg_owner: "enterprisedb"
pg_group: "enterprisedb"
pg_user_home: "/var/lib/edb-as"
etcd_systemd_global_unit_file: "/etc/systemd/system/{{ etcd_service }}.service"
etcd_environment_file: "/etc/default/etcd"
1 change: 1 addition & 0 deletions roles/setup_etcd/vars/EPAS_RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
pg_owner: "enterprisedb"
pg_group: "enterprisedb"
pg_user_home: "/var/lib/edb"
etcd_systemd_global_unit_file: "/etc/systemd/system/{{ etcd_service }}.service"
etcd_environment_file: "/etc/sysconfig/etcd"
3 changes: 2 additions & 1 deletion roles/setup_etcd/vars/PG_Debian.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
pg_owner: "postgres"
pg_group: "postgres"
pg_user_home: "/var/lib/postgresql"
etcd_systemd_global_unit_file: "/etc/systemd/system/{{ etcd_service }}.service"
etcd_environment_file: "/etc/default/etcd"
etcd_environment_file: "/etc/default/etcd"
1 change: 1 addition & 0 deletions roles/setup_etcd/vars/PG_RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
pg_owner: "postgres"
pg_group: "postgres"
pg_user_home: "/var/lib/pgsql"
etcd_systemd_global_unit_file: "/etc/systemd/system/{{ etcd_service }}.service"
etcd_environment_file: "/etc/sysconfig/etcd"

0 comments on commit 890717c

Please sign in to comment.