You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible-msvsphere.ci/roles/koji_db_server/tasks/main.yml

47 lines
1.4 KiB

---
- name: Check if required variables are defined
ansible.builtin.fail:
msg: "{{ item }} is not defined or empty"
when: |
(vars[item] is undefined)
or (vars[item] is none)
or (vars[item] | trim | length == 0)
with_items:
- koji_db_server_db_name
- koji_db_server_user
- koji_db_server_password
- koji_db_server_ip
- koji_db_server_password_encryption
# Required for community.postgresql.postgresql_db module
- name: Install dependencies
ansible.builtin.dnf:
name: python3-psycopg2
state: installed
- name: Create Koji database
community.postgresql.postgresql_db:
name: "{{ koji_db_server_db_name }}"
become: true
become_user: postgres
- name: Create Koji database user
community.postgresql.postgresql_user:
db: "{{ koji_db_server_db_name }}"
name: "{{ koji_db_server_user }}"
password: "{{ koji_db_server_password }}"
environment:
PGOPTIONS: "-c password_encryption={{ koji_db_server_password_encryption }}"
become: true
become_user: postgres
- name: Allow requests from Koji server
community.postgresql.postgresql_pg_hba:
dest: /var/lib/pgsql/data/pg_hba.conf
contype: host
databases: "{{ koji_db_server_db_name }}"
users: "{{ koji_db_server_user }}"
address: "{{ koji_db_server_ip }}/32"
method: "{{ koji_db_server_password_encryption }}"
notify: restart postgresql