-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest-postgresql
More file actions
executable file
·92 lines (80 loc) · 2.7 KB
/
test-postgresql
File metadata and controls
executable file
·92 lines (80 loc) · 2.7 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env ansible-playbook
# (c) 2016 DataNexus Inc. All Rights Reserved.
#
# simple test file for standalone or master/replica
---
- name: gathering {{ cloud }} inventory
hosts: localhost
vars_files:
- "{{ configuration }}"
- vars/postgresql.yml
gather_facts: yes
tasks:
- include_role:
name: aws
tasks_from: discover-vm
when: cloud == 'aws'
# run the create and select on the standalone
- hosts: "{{ application }}"
vars_files:
- "{{ configuration }}"
- vars/postgresql.yml
tasks:
- command: "/usr/bin/psql -c 'create table if not exists t_random as select s, md5(random()::text) from generate_Series(1,500) s;'"
become: yes
become_user: postgres
register: create_out
when: groups['postgresql_master'] is not defined
- debug: msg="{{ create_out.stdout_lines }}"
when: groups['postgresql_master'] is not defined
- command: "/usr/bin/psql -c 'select * from t_random limit 15;'"
become: yes
become_user: postgres
register: select_out
when: groups['postgresql_master'] is not defined
- debug: msg="{{ select_out.stdout_lines }}"
when: groups['postgresql_master'] is not defined
# run the create and select on the master/replica pair
- hosts: "{{ application }}_master"
vars_files:
- "{{ configuration }}"
- vars/postgresql.yml
tasks:
- command: "/usr/bin/psql -c 'create table if not exists t_random as select s, md5(random()::text) from generate_Series(1,500) s;'"
become: yes
become_user: postgres
register: create_out
- debug: msg="{{ create_out.stdout_lines }}"
- hosts: "{{ application }}_replica"
vars_files:
- "{{ configuration }}"
- vars/postgresql.yml
tasks:
- command: "/usr/bin/psql -c 'select * from t_random limit 15;'"
become: yes
become_user: postgres
register: select_out
- debug: msg="{{ select_out.stdout_lines }}"
# clean up the t_random table
- hosts: "{{ application }}"
vars_files:
- "{{ configuration }}"
- vars/postgresql.yml
tasks:
- command: "/usr/bin/psql -c 'drop table t_random;'"
become: yes
become_user: postgres
register: drop_out
when: groups['postgresql_master'] is not defined
- debug: msg="{{ drop_out.stdout_lines }}"
when: groups['postgresql_master'] is not defined
- hosts: "{{ application }}_master"
vars_files:
- "{{ configuration }}"
- vars/postgresql.yml
tasks:
- command: "/usr/bin/psql -c 'drop table t_random;'"
become: yes
become_user: postgres
register: drop_out
- debug: msg="{{ drop_out.stdout_lines }}"