Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Avoid using shared variables from pulp_database role
Browse files Browse the repository at this point in the history
  • Loading branch information
fao89 committed Apr 8, 2021
1 parent 10875fa commit 38824dd
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGES/8519.bugfix
@@ -0,0 +1 @@
Avoid using shared variables from pulp_database role
41 changes: 41 additions & 0 deletions roles/pulp_common/tasks/install.yml
Expand Up @@ -14,6 +14,47 @@
name: '{{ pulp_preq_packages }}'
state: present

- name: Gather package facts
package_facts:
manager: "auto"

- name: Installed packages
debug:
var: ansible_facts.packages
verbosity: 1

- name: Get PATH
shell: |
{% if 'rh-postgresql10' in ansible_facts.packages %}
source /opt/rh/rh-postgresql10/enable
{% endif %}
env | grep -E '^PATH=' | sed 's/PATH=//g'
args:
executable: /bin/bash
changed_when: false
register: pulp_env_path
check_mode: false

- name: Set PATH as a fact
set_fact:
pulp_path: "{{ pulp_env_path.stdout }}"

- name: Get LD_LIBRARY_PATH
shell: |
{% if 'rh-postgresql10' in ansible_facts.packages %}
source /opt/rh/rh-postgresql10/enable
{% endif %}
env | grep -E '^LD_LIBRARY_PATH=' | sed 's/LD_LIBRARY_PATH=//g'
args:
executable: /bin/bash
changed_when: false
register: pulp_env_ld_library_path
check_mode: false

- name: Set LD_LIBRARY_PATH as a fact
set_fact:
pulp_ld_library_path: "{{ pulp_env_ld_library_path.stdout }}"

# Become root so as to search paths like /usr/sbin.
- name: Find the nologin executable
command: which nologin
Expand Down
8 changes: 6 additions & 2 deletions roles/pulp_common/tasks/main.yml
Expand Up @@ -65,6 +65,10 @@
- ansible_facts.distribution == 'CentOS'
- ansible_facts.distribution_version|float < 7.7

- name: Gather package facts
package_facts:
manager: "auto"

# Note: We cannot use `systemd-path search-binaries-default` because
# it wasn't added until systemd 239. Thus no CentOS 7 or Fedora 28
# support, etc.
Expand All @@ -73,9 +77,9 @@
shell: |
set -o pipefail
export PATH=$(systemctl show-environment | grep -E '^PATH=' | sed 's/PATH=//g')
if [[ -f "/opt/rh/rh-postgresql10/enable" ]]; then
{% if 'rh-postgresql10' in ansible_facts.packages %}
source /opt/rh/rh-postgresql10/enable
fi
{% endif %}
echo $PATH
args:
# Debian defaults to bourne, but it doesn't understand pipefail.
Expand Down
32 changes: 0 additions & 32 deletions roles/pulp_database/tasks/install_postgres.yml
Expand Up @@ -105,38 +105,6 @@
- ansible_facts.distribution_major_version|int == 7

- block:
- name: Get PATH
shell: |
if [[ -f "/opt/rh/rh-postgresql10/enable" ]]; then
source /opt/rh/rh-postgresql10/enable
fi
env | grep -E '^PATH=' | sed 's/PATH=//g'
args:
executable: /bin/bash
changed_when: false
register: pulp_env_path
check_mode: false

- name: Set PATH as a fact
set_fact:
pulp_path: "{{ pulp_env_path.stdout }}"

- name: Get LD_LIBRARY_PATH
shell: |
if [[ -f "/opt/rh/rh-postgresql10/enable" ]]; then
source /opt/rh/rh-postgresql10/enable
fi
env | grep -E '^LD_LIBRARY_PATH=' | sed 's/LD_LIBRARY_PATH=//g'
args:
executable: /bin/bash
changed_when: false
register: pulp_env_ld_library_path
check_mode: false

- name: Set LD_LIBRARY_PATH as a fact
set_fact:
pulp_ld_library_path: "{{ pulp_env_ld_library_path.stdout }}"

- name: Install and configure PostgreSQL
include_role:
name: geerlingguy.postgresql
Expand Down

0 comments on commit 38824dd

Please sign in to comment.