postgresql support
This commit is contained in:
parent
a1c287fbfb
commit
15335984a3
@ -45,24 +45,42 @@
|
|||||||
enabled: no
|
enabled: no
|
||||||
when: db_engine != 'mysql'
|
when: db_engine != 'mysql'
|
||||||
|
|
||||||
# ------------------ PostgreSQL Specific Tasks (Placeholder) ------------------
|
# ------------------ PostgreSQL Specific Tasks ------------------
|
||||||
|
|
||||||
- name: "Install PostgreSQL server"
|
- name: "Install PostgreSQL server and dependencies"
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name:
|
name:
|
||||||
- postgresql
|
- postgresql
|
||||||
- postgresql-contrib
|
- postgresql-contrib
|
||||||
|
- python3-psycopg2
|
||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
when: db_engine == 'postgres'
|
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:
|
ansible.builtin.service:
|
||||||
name: postgresql
|
name: postgresql
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: yes
|
||||||
when: db_engine == 'postgres'
|
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 ---
|
# --- Common Tasks for MySQL/MariaDB ---
|
||||||
|
|
||||||
- name: "Install Python dependencies for MySQL/MariaDB management"
|
- name: "Install Python dependencies for MySQL/MariaDB management"
|
||||||
|
@ -58,4 +58,13 @@
|
|||||||
name: "{{ project.database }}"
|
name: "{{ project.database }}"
|
||||||
state: present
|
state: present
|
||||||
login_unix_socket: /var/run/mysqld/mysqld.sock
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||||
when: project.database is defined and (db_engine == 'mariadb' or db_engine == 'mysql')
|
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