Advertisement
k3NGuru

Untitled

Feb 20th, 2024
841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.32 KB | None | 0 0
  1. ---
  2. - name: Создаем и настраиваем БД
  3.   hosts: all
  4.   roles:
  5.    - database
  6.  
  7. ---   ### database/tasks/main.yml
  8.  
  9. - name: Настраиваем PostgreSQL
  10.   ansible.builtin.include_tasks: database.yml
  11.   loop: "{{ dbname }}"
  12.  
  13. ---   ### database/tasks/database.yml
  14.  
  15. - name: Создаем пользователя {{ item.user }}
  16.   community.postgresql.postgresql_user:
  17.     host: "{{ PGSRV1 }}"
  18.     login_user: postgres
  19.     login_password: "{{ PGSPASS }}"
  20.     name: "{{ item.user }}"
  21.     password: "{{ PGPWD }}"
  22.     role_attr_flags: LOGIN
  23.     # port: 5432
  24.  
  25. - name: Создаем БД {{ item.name }}
  26.   community.postgresql.postgresql_db:
  27.     host: "{{ PGSRV1 }}"
  28.     login_user: postgres
  29.     login_password: "{{ PGSPASS }}"
  30.     name: "{{ item.name }}"
  31.     owner: "{{ item.user }}"
  32.     # port: 5432
  33.  
  34. - name: Создаем схему {{ item.name }} в БД {{ item.name }}
  35.   community.postgresql.postgresql_schema:
  36.     host: "{{ PGSRV1 }}"
  37.     login_user: postgres
  38.     login_password: "{{ PGSPASS }}"
  39.     db: "{{ item.name }}"
  40.     name: "{{ item.name }}"
  41.     owner: "{{ item.user }}"
  42.  
  43. --- ###  database/defaults/main.yml
  44.  
  45. dbname:
  46.  - { name: "admin_api", user: "admin_api_admin" }
  47.  - { name: "agenda", user: "agenda_admin" }
  48.  
  49. PGSRV1: postgres.intra.local
  50. PGSPASS: aaaa
  51. PGPWD: Blab!
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement