postgresql support
This commit is contained in:
parent
a1c287fbfb
commit
15335984a3
@ -45,24 +45,42 @@
|
||||
enabled: no
|
||||
when: db_engine != 'mysql'
|
||||
|
||||
# ------------------ PostgreSQL Specific Tasks (Placeholder) ------------------
|
||||
# ------------------ PostgreSQL Specific Tasks ------------------
|
||||
|
||||
- name: "Install PostgreSQL server"
|
||||
- name: "Install PostgreSQL server and dependencies"
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- postgresql
|
||||
- postgresql-contrib
|
||||
- python3-psycopg2
|
||||
state: present
|
||||
update_cache: yes
|
||||
when: db_engine == 'postgres'
|
||||
|
||||
- name: "Ensure PostgreSQL service is running and enabled"
|
||||
- name: "Ensure PostgreSQL service is running and enabled (when selected)"
|
||||
ansible.builtin.service:
|
||||
name: postgresql
|
||||
state: started
|
||||
enabled: yes
|
||||
when: db_engine == 'postgres'
|
||||
|
||||
- name: "Ensure PostgreSQL service is stopped and disabled (when NOT selected)"
|
||||
ansible.builtin.service:
|
||||
name: postgresql
|
||||
state: stopped
|
||||
enabled: no
|
||||
when: db_engine != 'postgres'
|
||||
|
||||
- name: "Create the global Lenvi PostgreSQL user"
|
||||
community.postgresql.postgresql_user:
|
||||
name: "{{ db_credentials.user }}"
|
||||
password: "{{ db_credentials.password }}"
|
||||
priv: "ALL"
|
||||
state: present
|
||||
become: yes
|
||||
become_user: postgres
|
||||
when: db_engine == 'postgres' and db_credentials is defined
|
||||
|
||||
# --- Common Tasks for MySQL/MariaDB ---
|
||||
|
||||
- name: "Install Python dependencies for MySQL/MariaDB management"
|
||||
|
@ -59,3 +59,12 @@
|
||||
state: present
|
||||
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||
when: project.database is defined and (db_engine == 'mariadb' or db_engine == 'mysql')
|
||||
|
||||
- name: "Create project-specific PostgreSQL database '{{ project.database }}'"
|
||||
community.postgresql.postgresql_db:
|
||||
name: "{{ project.database }}"
|
||||
owner: "{{ db_credentials.user }}"
|
||||
state: present
|
||||
become: yes
|
||||
become_user: postgres
|
||||
when: project.database is defined and db_engine == 'postgres'
|
Loading…
x
Reference in New Issue
Block a user