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

Add external database role and pipeline #1871

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
43 changes: 43 additions & 0 deletions pipelines/external_database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
- hosts: localhost
vars_files:
- vars/external_database.yml
roles:
- forklift

- hosts: "{{ forklift_database_name }}"
become: yes
vars_files:
- vars/external_database.yml
roles:
- role: forklift_versions
scenario: "{{ pipeline_type }}"
scenario_os: "{{ pipeline_os }}"
scenario_version: "{{ pipeline_version }}"
- role: postgresql

- hosts: "{{ forklift_server_name }}"
become: yes
vars_files:
- vars/external_database.yml
roles:
- role: forklift_versions
scenario: "{{ pipeline_type }}"
scenario_os: "{{ pipeline_os }}"
scenario_version: "{{ pipeline_version }}"
- role: foreman_server_repositories
- role: etc_hosts
- role: update_os_packages
- role: foreman_installer
foreman_installer_options_internal_use_only:
- "--foreman-db-manage false"
- "--foreman-db-host {{ forklift_database_name }}"
- "--foreman-db-database foreman"
- "--foreman-db-password foreman"
- "--katello-candlepin-manage-db false"
- "--katello-candlepin-db-host {{ forklift_database_name }}"
- "--katello-candlepin-db-name candlepin"
- "--katello-candlepin-db-password candlepin"
- "--foreman-proxy-content-pulpcore-manage-postgresql false"
- "--foreman-proxy-content-pulpcore-postgresql-host {{ forklift_database_name }}"
- "--foreman-proxy-content-pulpcore-postgresql-db-name pulp"
- "--foreman-proxy-content-pulpcore-postgresql-password pulp"
25 changes: 25 additions & 0 deletions pipelines/vars/external_database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
pipeline_type: katello
pipeline_version: nightly
pipeline_os: centos9-stream
foreman_installer_scenario: katello
server_box:
box: "{{ pipeline_os }}"
memory: 10240
ansible:
variables:
foreman_server_repositories_katello: true
foreman_installer_disable_system_checks: true
foreman_installer_scenario: katello
foreman_installer_additional_packages:
- "foreman-installer-katello"
database_box:
box: "{{ pipeline_os }}"
memory: 4096
ansible:
variables:
postgresql_use_evr: true
forklift_name: "pi-{{ pipeline_type }}-{{ pipeline_version }}-{{ pipeline_os }}-external-database"
forklift_server_name: "pi-{{ pipeline_type }}-{{ pipeline_version }}-{{ pipeline_os }}-server"
forklift_database_name: "pi-{{ pipeline_type }}-{{ pipeline_version }}-{{ pipeline_os }}-database"
forklift_boxes:
"{{ {forklift_server_name: server_box, forklift_database_name: database_box} }}"
5 changes: 5 additions & 0 deletions playbooks/external_database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- hosts: all
become: true
roles:
- postgresql
103 changes: 103 additions & 0 deletions roles/postgresql/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
- name: 'Install postgres packages'
yum:
name: "{{ item }}"
state: installed
with_items:
- postgresql-server
- python-psycopg2
- postgresql-contrib

- when: postgresql_use_evr
block:
- name: Include foreman server repositories
include_role:
name: katello_repositories

- name: 'Install postgresql-evr packages'
yum:
name: postgresql-evr
state: installed

- name: 'Init PostgreSQL database'
command: postgresql-setup initdb
args:
creates: /var/lib/pgsql/data/postgresql.conf

- name: 'Deploy pg_hba.conf'
copy:
dest: /var/lib/pgsql/data/pg_hba.conf
content: |
# TYPE DATABASE USER ADDRESS METHOD

# "local" is for Unix domain socket connections only
local all all ident

# IPv4 local connections:
host all all 127.0.0.1/32 md5

# IPv4 remote connections:
host all all 0.0.0.0/0 md5

# IPv6 local connections:
host all all ::1/128 md5
force: yes
mode: 0600
owner: postgres
group: postgres

- name: Set listen addresses to *
lineinfile:
dest: /var/lib/pgsql/data/postgresql.conf
regexp: "^listen_addresses"
line: "listen_addresses = '*'"
state: present
backup: yes

- name: 'Ensure PostgreSQL is running'
service:
name: postgresql
state: restarted
enabled: yes

- name: 'Add database user'

Check failure on line 63 in roles/postgresql/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

partial-become[task]

``become_user`` should have a corresponding ``become`` at the play or task level.
become_user: postgres
postgresql_user:
state: present
name: "foreman"
password: "foreman"

- name: 'Create Foreman database'

Check failure on line 70 in roles/postgresql/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

partial-become[task]

``become_user`` should have a corresponding ``become`` at the play or task level.
become_user: postgres
postgresql_db:
state: present
name: "foreman"
owner: "foreman"

- name: 'Add candlepin database user'

Check failure on line 77 in roles/postgresql/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

partial-become[task]

``become_user`` should have a corresponding ``become`` at the play or task level.
become_user: postgres
postgresql_user:
state: present
name: "candlepin"
password: "candlepin"

- name: 'Create Candlepin database'

Check failure on line 84 in roles/postgresql/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

partial-become[task]

``become_user`` should have a corresponding ``become`` at the play or task level.
become_user: postgres
postgresql_db:
state: present
name: "candlepin"
owner: "candlepin"

- name: 'Add pulp database user'

Check failure on line 91 in roles/postgresql/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

partial-become[task]

``become_user`` should have a corresponding ``become`` at the play or task level.
become_user: postgres
postgresql_user:
state: present
name: "pulp"
password: "pulp"

- name: 'Create Pulp database'

Check failure on line 98 in roles/postgresql/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

partial-become[task]

``become_user`` should have a corresponding ``become`` at the play or task level.
become_user: postgres
postgresql_db:
state: present
name: "pulp"
owner: "pulp"
Loading