forked from TOSIT-IO/tdp-getting-started
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-cluster-deployment.yml
207 lines (187 loc) · 6.12 KB
/
test-cluster-deployment.yml
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
---
- hosts: all
become: yes
tasks:
- name: empty logs
shell: truncate -s 0 /var/log/**/*.log
- hosts: localhost
become: yes
gather_facts: no
tasks:
- name: check quroum status'
delegate_to: "{{ item }}"
shell: echo stat | nc localhost 2181
register: _result
failed_when: "'Ncat: Connection refused' in _result.stdout"
loop: "{{ groups['zk'] }}"
tags:
- zk
- name: create tdp_user hdfs home dir
delegate_to: "{{ groups['hdfs_nn'][0] }}"
shell: |
kinit -kt /etc/security/keytabs/nn.service.keytab nn/master-01.tdp@REALM.TDP
/opt/tdp/hadoop/bin/hdfs --config /etc/hadoop/conf.nn dfs -mkdir -p /user/tdp_user
/opt/tdp/hadoop/bin/hdfs --config /etc/hadoop/conf.nn dfs -chown -R tdp_user:tdp_user /user/tdp_user
register: _result
tags:
- hdfs
- name: Log previous action stdout to console
debug:
msg: '{{ _result.stdout }}'
tags:
- hdfs
- name: Create file with contents as tdp_user
delegate_to: "{{ groups['edge'][0] }}"
become_user: tdp_user
shell: |
kinit -kt /home/tdp_user/tdp_user.keytab tdp_user@REALM.TDP
echo "This is the first line." | /opt/tdp/hadoop/bin/hdfs --config /etc/hadoop/conf dfs -put - /user/tdp_user/testFile
echo "This is the second (appended) line." | /opt/tdp/hadoop/bin/hdfs --config /etc/hadoop/conf dfs -appendToFile - /user/tdp_user/testFile
/opt/tdp/hadoop/bin/hdfs --config /etc/hadoop/conf dfs -cat /user/tdp_user/testFile
register: _result
tags:
- hdfs
- name: Log previous action stdout to console
debug:
msg: '{{ _result.stdout }}'
tags:
- hdfs
- name: cat written contents from another node
delegate_to: "{{ groups['hdfs_nn'][0] }}"
shell: |
kinit -kt /etc/security/keytabs/nn.service.keytab nn/master-01.tdp@REALM.TDP
/opt/tdp/hadoop/bin/hdfs --config /etc/hadoop/conf.nn dfs -cat /user/tdp_user/testFile
register: _result
tags:
- hdfs
- hosts: "{{ groups['edge'][0] }}"
become: yes
become_user: tdp_user
tasks:
- name: Create hive command file
copy:
dest: /home/tdp_user/hive-test
content: |
DROP DATABASE IF EXISTS tdp_user_db CASCADE;
CREATE DATABASE IF NOT EXISTS tdp_user_db;
SHOW DATABASES;
USE tdp_user_db;
SHOW TABLES;
CREATE TABLE table_cluster_test
(col1 int COMMENT 'Integer Column',
col2 string COMMENT 'String Column'
);
SHOW TABLES;
INSERT INTO TABLE table_cluster_test VALUES (1, 'one'), (2, 'two');
SELECT * FROM table_cluster_test;
tags:
- hive
- name: Run hive command file
become: yes
become_user: tdp_user
shell: |
kinit -kt /home/tdp_user/tdp_user.keytab tdp_user@REALM.TDP
export hive_truststore_password=Truststore123!
echo '!run /home/tdp_user/hive-test' | /opt/tdp/hive/bin/hive --config /etc/hive/conf.s2 --service beeline -u "jdbc:hive2://master-01.tdp:2181,master-02.tdp:2181,master-03.tdp:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2;sslTrustStore=/etc/ssl/certs/truststore.jks;trustStorePassword=${hive_truststore_password}"
register: _result
tags:
- hive
- name: Log stderr to console
debug:
msg: '{{ _result.stderr }}'
tags:
- hive
- hosts: hbase_client
become: yes
become_user: tdp_user
tasks:
- name: Run HBase 'list'
become: yes
become_user: tdp_user
shell: |
kinit -kt /home/tdp_user/tdp_user.keytab tdp_user@REALM.TDP
echo 'list' | /opt/tdp/hbase/bin/hbase --config /etc/hbase/conf shell
register: _result
failed_when: _result.rc != 0
tags:
- hbase
- name: Log previous action stdout to console
debug:
msg: '{{ _result.stdout }}'
tags:
- hbase
- name: HBase 'list_namespace'
become: yes
become_user: tdp_user
shell: |
kinit -kt /home/tdp_user/tdp_user.keytab tdp_user@REALM.TDP
echo 'list_namespace' | /opt/tdp/hbase/bin/hbase --config /etc/hbase/conf shell
register: _result
failed_when: _result.rc != 0
tags:
- hbase
- name: Log previous action stdout to console
debug:
msg: '{{ _result.stdout }}'
tags:
- hbase
- name: HBase create testTable
become: yes
become_user: tdp_user
shell: |
kinit -kt /home/tdp_user/tdp_user.keytab tdp_user@REALM.TDP
echo "create 'testTable', 'cf'" | /opt/tdp/hbase/bin/hbase --config /etc/hbase/conf shell
register: _result
failed_when: _result.rc != 0
tags:
- hbase
- name: Log previous action stdout to console
debug:
msg: '{{ _result.stdout }}'
tags:
- hbase
- name: HBase put into testTable
become: yes
become_user: tdp_user
shell: |
kinit -kt /home/tdp_user/tdp_user.keytab tdp_user@REALM.TDP
echo "put 'testTable', 'row1', 'cf:testColumn', 'testValue'" | /opt/tdp/hbase/bin/hbase --config /etc/hbase/conf shell
register: _result
failed_when: _result.rc != 0
tags:
- hbase
- name: Log previous action stdout to console
debug:
msg: '{{ _result.stdout }}'
tags:
- hbase
- name: HBase disable testTable
become: yes
become_user: tdp_user
shell: |
kinit -kt /home/tdp_user/tdp_user.keytab tdp_user@REALM.TDP
echo "disable 'testTable'" | /opt/tdp/hbase/bin/hbase --config /etc/hbase/conf shell
register: _result
failed_when: _result.rc != 0
tags:
- hbase
- name: Log previous action stdout to console
debug:
msg: '{{ _result.stdout }}'
tags:
- hbase
- name: HBase drop testTable
become: yes
become_user: tdp_user
shell: |
kinit -kt /home/tdp_user/tdp_user.keytab tdp_user@REALM.TDP
echo "drop 'testTable'" | /opt/tdp/hbase/bin/hbase --config /etc/hbase/conf shell
register: _result
failed_when: _result.rc != 0
tags:
- hbase
- name: Log previous action stdout to console
debug:
msg: '{{ _result.stdout }}'
tags:
- hbase