fix(litellm): use become_user postgres for db provisioning

This commit is contained in:
Haitao Pan 2026-06-11 15:50:51 +08:00
parent fc1bff0061
commit fc7a23617c

View File

@ -16,10 +16,8 @@
community.postgresql.postgresql_db:
name: "{{ litellm_database_name }}"
state: present
login_host: "127.0.0.1"
login_port: "5432"
login_user: "{{ litellm_database_admin_user }}"
login_password: "{{ litellm_database_admin_password }}"
become: true
become_user: postgres
register: litellm_db_result
when: litellm_database_host | trim | length > 0
@ -28,20 +26,16 @@
name: "{{ litellm_database_user }}"
password: "{{ litellm_database_password }}"
db: "{{ litellm_database_name }}"
login_host: "127.0.0.1"
login_port: "5432"
login_user: "{{ litellm_database_admin_user }}"
login_password: "{{ litellm_database_admin_password }}"
priv: "{{ litellm_database_name }}/ALL"
role_attr_flags: LOGIN,NOSUPERUSER
state: present
become: true
become_user: postgres
when: litellm_database_host | trim | length > 0
- name: Apply schema.sql to litellm database (idempotent via IF NOT EXISTS)
ansible.builtin.shell: |
psql -h 127.0.0.1 \
-p 5432 \
-U {{ litellm_database_user }} \
psql -U {{ litellm_database_user }} \
-d {{ litellm_database_name }} \
-f {{ litellm_config_dir }}/schema.sql 2>&1
args: