blob: 0089788a9289a435993db22818b4ed62b1400753 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
- name: create database
postgresql_db:
name: '{{ sabredav_db_name }}'
state: present
delegate_to: "{{ postgresql_inventory_host }}"
become: yes
become_user: postgres
- name: create database user
postgresql_user:
name: '{{ sabredav_user }}'
db: '{{ sabredav_db_name }}'
priv: ALL
state: present
delegate_to: "{{ postgresql_inventory_host }}"
become: yes
become_user: postgres
- name: check if database schema is initialized
postgresql_query:
login_user: '{{ sabredav_user }}'
login_host: '{{ sabredav_db_host }}'
db: '{{ sabredav_db_name }}'
query: SELECT 1 FROM calendars
become: yes
become_user: apache
environment:
GSS_USE_PROXY: 'yes'
register: sabredav_check_db
failed_when: no
- name: initialize database schema
postgresql_query:
login_user: '{{ sabredav_user }}'
login_host: '{{ sabredav_db_host }}'
db: '{{ sabredav_db_name }}'
path_to_script: '{{ sabredav_home }}/pgsql.schema.sql'
as_single_query: yes
become: yes
become_user: apache
environment:
GSS_USE_PROXY: 'yes'
when:
- sabredav_check_db.msg is defined
- sabredav_check_db.msg is search('relation "calendars" does not exist')
|