Skip to content

Commit f4a33f5

Browse files
committed
Adding loop_control into hdfs_scale
Signed-off-by: Dherendra Singh<dhersing@in.ibm.com>
1 parent ea33043 commit f4a33f5

File tree

12 files changed

+83
-49
lines changed

12 files changed

+83
-49
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
- name : configure | include task for nameservice
22
set_fact:
3-
hdfs_site_conf_dict: "{{ hdfs_site_conf_dict | default({}) | combine ({ item.key : item.value }) }}"
3+
hdfs_site_conf_dict: "{{ hdfs_site_conf_dict | default({}) | combine ({ hdfs_conf_list.key : hdfs_conf_list.value }) }}"
44
with_items:
55
- { 'key': "dfs.namenode.rpc-address.{{ scale_hdfs_cluster.name }}.{{ map_var.0 }}", 'value': "{{ map_var.1 }}:8020" }
66
- { 'key': "dfs.namenode.http-address.{{ scale_hdfs_cluster.name }}.{{ map_var.0 }}", 'value': "{{ map_var.1 }}:50070" }
7+
loop_control:
8+
loop_var: hdfs_conf_list

roles/scale_hdfs/cluster/tasks/configure.yml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@
6565

6666
- name: check | calculate namenodes services
6767
set_fact:
68-
namenodes_service: "{{ namenodes_service }}nn{{ item }},"
68+
namenodes_service: "{{ namenodes_service }}nn{{ namenode_list }},"
6969
with_sequence: count={{ namenodes_length }}
7070
when: scale_hdfs_namenodes_list|length > 1
71+
loop_control:
72+
loop_var: namenode_list
7173
delegate_to: localhost
7274
run_once: true
7375

@@ -111,14 +113,17 @@
111113
- name: check | fetch mountpoint
112114
shell: /usr/lpp/mmfs/bin/mmlsfs "{{ scale_hdfs_filesystem }}" -T -Y | grep defaultMountPoint | awk -F':' '{print $9}'
113115
register: hdfs_mountpoint
116+
114117
- name: check| decode mountpoint
115118
command: /usr/lpp/mmfs/bin/mmclidecode "{{ hdfs_mountpoint.stdout }}"
116119
register: hdfs_mountpoint_decode
117120
when: hdfs_mountpoint.rc == 0
121+
118122
- name: check| get mountpoint
119123
set_fact:
120124
scale_hdfs_mountpoint: "{{ hdfs_mountpoint_decode.stdout }}"
121125
when: hdfs_mountpoint_decode.rc == 0
126+
122127
run_once: true
123128
delegate_to: "{{ scale_server }}"
124129

@@ -175,7 +180,7 @@
175180
- block:
176181
- name: configure | Configuare core-site.xml
177182
set_fact:
178-
core_site_conf_dict: "{{ core_site_conf_dict | default({}) | combine ({ item.key : item.value }) }}"
183+
core_site_conf_dict: "{{ core_site_conf_dict | default({}) | combine ({ core_list.key : core_list.value }) }}"
179184
with_items:
180185
- { 'key': "fs.defaultFS", 'value': "hdfs://{{scale_hdfs_cluster.name}}" }
181186
- { 'key': "hadoop.proxyuser.livy.hosts", 'value': "*" }
@@ -184,10 +189,12 @@
184189
- { 'key': "hadoop.proxyuser.hive.groups", 'value': "*" }
185190
- { 'key': "hadoop.proxyuser.oozie.hosts", 'value': "*" }
186191
- { 'key': "hadoop.proxyuser.oozie.groups", 'value': "*" }
192+
loop_control:
193+
loop_var: core_list
187194

188195
- name: configure | Configuare hdfs-site.xml
189196
set_fact:
190-
hdfs_site_conf_dict: "{{ hdfs_site_conf_dict | default({}) | combine ({ item.key : item.value }) }}"
197+
hdfs_site_conf_dict: "{{ hdfs_site_conf_dict | default({}) | combine ({ hdfs_list.key : hdfs_list.value }) }}"
191198
with_items:
192199
- { 'key': "dfs.ha.namenodes.{{ scale_hdfs_cluster.name }}", 'value': "{{ namenodes_service }}" }
193200
- { 'key': "dfs.client.failover.proxy.provider.{{ scale_hdfs_cluster.name }}", 'value': 'org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider' }
@@ -196,6 +203,8 @@
196203
- { 'key': "dfs.namenode.servicerpc-bind-host", 'value': "0.0.0.0" }
197204
- { 'key': "dfs.namenode.lifeline.rpc-bind-host", 'value': "0.0.0.0" }
198205
- { 'key': "dfs.namenode.http-bind-host", 'value': "0.0.0.0" }
206+
loop_control:
207+
loop_var: hdfs_list
199208

200209
- name: configure | include append_dict.yml
201210
include_tasks: append_dict.yml
@@ -207,33 +216,42 @@
207216

208217
- name: configure | Configuare hdfs-site.xml for HA
209218
set_fact:
210-
hdfs_site_conf_dict: "{{ hdfs_site_conf_dict | default({}) | combine ({ item.key : item.value }) }}"
219+
hdfs_site_conf_dict: "{{ hdfs_site_conf_dict | default({}) | combine ({ hdfs_site_ha_conf.key : hdfs_site_ha_conf.value }) }}"
211220
with_items:
212221
- { 'key': "dfs.namenode.shared.edits.dir", 'value': "file:///{{ scale_hdfs_mountpoint }}/HA-{{ scale_hdfs_cluster.name }}" }
213222
when: ha_enabled|bool
223+
loop_control:
224+
loop_var: hdfs_site_ha_conf
214225

215226
- name: configure | Configuare gpfs-site.xml
216227
set_fact:
217-
gpfs_site_conf_dict: "{{ gpfs_site_conf_dict | default({}) | combine ({ item.key : item.value }) }}"
228+
gpfs_site_conf_dict: "{{ gpfs_site_conf_dict | default({}) | combine ({ hdfs_site_list.key : hdfs_site_list.value }) }}"
218229
with_items:
219230
- { 'key': "gpfs.mnt.dir", 'value': "{{ scale_hdfs_mountpoint }}" }
220231
- { 'key': "gpfs.data.dir", 'value': "{{ scale_hdfs_datadir }}" }
221-
232+
loop_control:
233+
loop_var: hdfs_site_list
222234
run_once: true
223235
delegate_to: localhost
224236

225237
- block:
226238
- name: configure | Set configuration for core-site.xml
227-
shell: /usr/lpp/mmfs/hadoop/sbin/mmhdfs config set core-site.xml -k "{{ item.key }}"="{{ item.value }}"
239+
shell: /usr/lpp/mmfs/hadoop/sbin/mmhdfs config set core-site.xml -k "{{ core_site_conf.key }}"="{{ core_site_conf.value }}"
228240
loop: "{{ core_site_conf_dict | dict2items }}"
241+
loop_control:
242+
loop_var: core_site_conf
229243

230244
- name: configure | Set configuration for gpfs-site.xml
231-
shell: /usr/lpp/mmfs/hadoop/sbin/mmhdfs config set gpfs-site.xml -k "{{ item.key }}"="{{ item.value }}"
245+
shell: /usr/lpp/mmfs/hadoop/sbin/mmhdfs config set gpfs-site.xml -k "{{ gpfs_site_conf.key }}"="{{ gpfs_site_conf.value }}"
232246
loop: "{{ gpfs_site_conf_dict | dict2items }}"
247+
loop_control:
248+
loop_var: gpfs_site_conf
233249

234250
- name: configure | Set configuration for hdfs-site.xml
235-
shell: /usr/lpp/mmfs/hadoop/sbin/mmhdfs config set hdfs-site.xml -k "{{ item.key }}"="{{ item.value }}"
251+
shell: /usr/lpp/mmfs/hadoop/sbin/mmhdfs config set hdfs-site.xml -k "{{ hdfs_site_conf.key }}"="{{ hdfs_site_conf.value }}"
236252
loop: "{{ hdfs_site_conf_dict | dict2items }}"
253+
loop_control:
254+
loop_var: hdfs_site_conf
237255

238256
- name: configure | Remove localhost
239257
shell: /usr/lpp/mmfs/hadoop/sbin/mmhdfs worker remove localhost

roles/scale_hdfs/node/tasks/apt/install.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
- name: install| Install GPFS HDFS deb
1010
apt:
11-
deb: "{{ item }}"
11+
deb: "{{ all_packages }}"
1212
state: present
1313
when: scale_install_repository_url is not defined and ansible_fqdn in scale_hdfs_nodes_list
1414
with_items:
15-
- "{{ scale_install_all_packages }}"
15+
- "{{ scale_install_all_packages }}"
16+
loop_control:
17+
loop_var: all_packages

roles/scale_hdfs/node/tasks/install.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@
111111
run_once: true
112112
delegate_to: localhost
113113

114-
- debug:
115-
var: hdfs_rpm_path_rhel
116-
117114
- include_tasks: install_{{ scale_installmethod }}.yml
118115

119116
- import_tasks: apt/install.yml

roles/scale_hdfs/node/tasks/install_dir_pkg.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@
6767

6868
- name: install | Add GPFS hdfs package to list
6969
vars:
70-
current_package: "{{ item.path }}"
70+
current_package: "{{ files.path }}"
7171
set_fact:
7272
scale_install_all_packages: "{{ scale_install_all_packages + [ current_package ] }}"
7373
with_items:
7474
- "{{ scale_install_gpfs_hdfs.files }}"
75+
loop_control:
76+
loop_var: files
7577

7678
- block:
7779
- name: initialize
@@ -80,9 +82,11 @@
8082

8183
- name: install | Add GPFS package to list
8284
set_fact:
83-
debuginfo_package: "{{ debuginfo_package + [ item.path ] }}"
85+
debuginfo_package: "{{ debuginfo_package + [ files.path ] }}"
8486
with_items:
8587
- "{{ scale_install_gpfs_hdfs_debuginfo.files }}"
88+
loop_control:
89+
loop_var: files
8690

8791
- name: remove debuginfo from packages
8892
set_fact:

roles/scale_hdfs/node/tasks/install_local_pkg.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@
106106
path: "{{ scale_install_localpkg_tmpdir_path + '/' + scale_install_localpkg_path | basename }}"
107107
state: absent
108108

109-
- debug:
110-
var: hdfs_rpm_path_rhel
111-
109+
112110
- name: install | hdfs path on rhel7
113111
set_fact:
114112
scale_hdfs_url: "{{ hdfs_rpm_path_rhel }}"
@@ -149,11 +147,13 @@
149147

150148
- name: install | Add GPFS hdfs package to list
151149
vars:
152-
current_package: "{{ item.path }}"
150+
current_package: "{{ files.path }}"
153151
set_fact:
154152
scale_install_all_packages: "{{ scale_install_all_packages + [ current_package ] }}"
155153
with_items:
156154
- "{{ scale_install_gpfs_hdfs.files }}"
155+
loop_control:
156+
loop_var: files
157157

158158
- block:
159159
- name: initialize
@@ -162,9 +162,11 @@
162162

163163
- name: install | Add GPFS package to list
164164
set_fact:
165-
debuginfo_package: "{{ debuginfo_package + [ item.path ] }}"
165+
debuginfo_package: "{{ debuginfo_package + [ files.path ] }}"
166166
with_items:
167167
- "{{ scale_install_gpfs_hdfs_debuginfo.files }}"
168+
loop_control:
169+
loop_var: files
168170

169171
- name: remove debuginfo from packages
170172
set_fact:

roles/scale_hdfs/node/tasks/install_remote_pkg.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,11 @@
106106

107107
- name: install | Add GPFS hdfs package to list
108108
vars:
109-
current_package: "{{ item.path }}"
109+
current_package: "{{ files.path }}"
110110
set_fact:
111111
scale_install_all_packages: "{{ scale_install_all_packages + [ current_package ] }}"
112112
with_items:
113113
- "{{ scale_install_gpfs_hdfs.files }}"
114+
loop_control:
115+
loop_var: files
114116

roles/scale_hdfs/node/tasks/install_repository.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
when: ansible_distribution in scale_ubuntu_distribution and ansible_distribution_major_version == '20'
3131

3232

33-
- debug:
34-
var: scale_hdfs_url
35-
3633
- name: install | Configure hdfs YUM repository
3734
yum_repository:
3835
name: spectrum-scale-hdfs

roles/scale_hdfs/postcheck/tasks/check.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,20 @@
9393
register: force_active
9494
when: ha_enabled|bool and active_status.stdout_lines | length == 0 and ceshost.stdout|length != 0
9595
delegate_to: "{{ ceshost.stdout }}"
96+
failed_when: false
9697
run_once: true
9798

99+
- name: postcheck | Sleep for 20 seconds
100+
wait_for:
101+
timeout: 20
102+
delegate_to: localhost
103+
98104
- name: postcheck | Check Namenodes active status again
99105
shell: "{{ scale_hdfs_command_path }}hdfs haadmin -getAllServiceState | grep -i 'active'"
100106
register: active_status_again
101-
when: ha_enabled|bool
107+
when: ha_enabled|bool and force_active.rc == 0
102108
delegate_to: "{{ scale_server }}"
109+
failed_when: false
103110
run_once: true
104111

105112
- fail:

roles/scale_hdfs/precheck/tasks/check.yml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212

1313
- name: check | Collect all protocol nodes
1414
set_fact:
15-
scale_protocol_nodes_list: "{{ scale_protocol_nodes_list + [hostvars[item]['ansible_fqdn']] }}"
16-
when: hostvars[item]['is_protocol_node'] is defined and hostvars[item]['is_protocol_node']|bool
15+
scale_protocol_nodes_list: "{{ scale_protocol_nodes_list + [hostvars[hosts]['ansible_fqdn']] }}"
16+
when: hostvars[hosts]['is_protocol_node'] is defined and hostvars[hosts]['is_protocol_node']|bool
1717
with_items:
1818
- "{{ ansible_play_hosts }}"
19+
loop_control:
20+
loop_var: hosts
1921
delegate_to: localhost
2022
run_once: true
2123

@@ -74,28 +76,32 @@
7476
- name: check | Check if HDFS required information has been supplied.
7577
assert:
7678
that:
77-
- item is defined
78-
- item| length > 0
79-
- item.name is defined
80-
- item.name| length > 0
81-
- item.filesystem is defined
82-
- item.filesystem| length > 0
83-
- item.namenodes is defined
84-
- item.namenodes| length > 0
85-
- item.datanodes is defined
86-
- item.datanodes| length > 0
87-
- item.datadir is defined
88-
- item.datadir| length > 0
79+
- hdfs_cluster is defined
80+
- hdfs_cluster| length > 0
81+
- hdfs_cluster.name is defined
82+
- hdfs_cluster.name| length > 0
83+
- hdfs_cluster.filesystem is defined
84+
- hdfs_cluster.filesystem| length > 0
85+
- hdfs_cluster.namenodes is defined
86+
- hdfs_cluster.namenodes| length > 0
87+
- hdfs_cluster.datanodes is defined
88+
- hdfs_cluster.datanodes| length > 0
89+
- hdfs_cluster.datadir is defined
90+
- hdfs_cluster.datadir| length > 0
8991
fail_msg: "HDFS required parameter information is not defined."
9092
success_msg: "HDFS required information is defined."
9193
with_items:
9294
- "{{ scale_hdfs_cluster }}"
95+
loop_control:
96+
loop_var: hdfs_cluster
9397
run_once: true
9498
delegate_to: localhost
9599

96100
- name: check | Verify JAVA_HOME
97101
include_tasks: java_home.yml
98102
loop: "{{ scale_hdfs_clusters }}"
103+
loop_control:
104+
loop_var: hdfs_clusters
99105

100106
- debug:
101107
msg: "HDFS Precheck ok on {{ scale_hdfs_cluster.name }} cluster."

0 commit comments

Comments
 (0)