Skip to content

Commit 0ca09aa

Browse files
authored
Merge pull request #811 from jayeshh123/jay_afm_new_var
Changes for AFM
2 parents 681f507 + 80a927c commit 0ca09aa

File tree

16 files changed

+326
-13
lines changed

16 files changed

+326
-13
lines changed

roles/afm_cos_configure/README.md

Whitespace-only changes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
# Default variables for the IBM Spectrum Scale AFM Cos Configure role -
3+
## Spectrum Scale daemon nodename (defaults to node's hostname)
4+
scale_daemon_nodename: "{{ ansible_hostname }}"
5+
6+
#"scale_afm_cos_bucket_params": [
7+
# {
8+
# "bucket": "test",
9+
# "akey": "xxxxxxxx",
10+
# "skey": "xxxxxxxx",
11+
# },
12+
# {
13+
# "bucket": "test1",
14+
# "akey": "xxxxxxxxx",
15+
# "skey": "xxxxxxxxx",
16+
# },
17+
#]
18+
19+
#"scale_afm_cos_filesets_params": [
20+
# {
21+
# "filesystem": "fs1",
22+
# "fileset": "afmfileset1",
23+
# "endpoint": "https://s3.ap.cos.appdomain.cloud:443/bucket-afm1",
24+
# "bucket": "bucket-afm1",
25+
# "mode": "SW",
26+
# },
27+
# {
28+
# "filesystem": "fs1",
29+
# "fileset": "afmfileset2",
30+
# "endpoint": "https://s3.ap.cos.appdomain.cloud:443/bucket-afm2",
31+
# "bucket": "bucket-afm2",
32+
# "mode": "SW"
33+
# }
34+
#]
35+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# handlers file for configure

roles/afm_cos_configure/meta/main.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
galaxy_info:
3+
author: IBM Corporation
4+
description: Role for configuring IBM Spectrum Scale AFM COS configuration role
5+
company: IBM
6+
7+
license: Apache-2.0
8+
9+
min_ansible_version: 2.9
10+
11+
platforms:
12+
- name: EL
13+
versions:
14+
- 7
15+
- 8
16+
- 9
17+
18+
galaxy_tags: []
19+
20+
dependencies: []
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
- block:
3+
- name: create | Initialize
4+
set_fact:
5+
extra_option_flag: ""
6+
7+
- name: create | Set existing bucket if it is defined
8+
set_fact:
9+
extra_option_flag: "{{ extra_option_flag }}{{ item.bucket }}"
10+
when:
11+
- item.bucket is defined
12+
- name: create | Set existing bucket if it is defined
13+
set_fact:
14+
extra_option_flag: "{{ extra_option_flag }}:{{ item.Region}}"
15+
when:
16+
- item.Region is defined
17+
18+
- name: create | Set existing bucket if it is defined
19+
set_fact:
20+
extra_option_flag: "{{ extra_option_flag }}@{{ item.Server}}"
21+
when:
22+
- item.Server is defined
23+
24+
- name: configure | Set the access key and secret key for new/existing bucket as below at gateway node
25+
command: "{{ scale_command_path }}mmafmcoskeys {{ extra_option_flag }} set {{ item.akey }} {{ item.skey }}"
26+
register: scale_afm_cos_define
27+
failed_when: scale_afm_cos_define.rc != 0
28+
when:
29+
- item.bucket is defined
30+
- item.akey is defined
31+
- item.skey is defined
32+
33+
- name: configure | Set the access key and secret key for new/existing bucket as below at gateway node
34+
command: "{{ scale_command_path }}mmafmcoskeys {{ item.bucket }}:{{ item.Region }}@{{ item.Server }} set --keyfile {{ item.KeyfilePath }}"
35+
register: scale_afm_cos_define
36+
failed_when: scale_afm_cos_define.rc != 0
37+
when:
38+
- item.bucket is defined
39+
- item.Region is defined
40+
- item.Server is defined
41+
- item.KeyfilePath is defined
42+
43+
- name: configure | FM cos bucket configuration
44+
debug:
45+
msg: AFM cos bucket configured.
46+
rescue:
47+
- name: Failure detected in Configuring AFM cos bucket
48+
fail:
49+
msg: "I caught an error, Please take a look to the output given!."
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
- block:
3+
- name: create | Find existing AFM cos enabled Filesystem
4+
shell: mmlsfileset {{ item.filesystem }} {{ item.fileset }} --afm -Y | grep -v HEADER | cut -d ':' -f 20 | uniq
5+
register: scale_existing_afmcos
6+
changed_when: false
7+
failed_when: false
8+
when:
9+
- item.filesystem is defined
10+
- item.fileset is defined
11+
12+
- name: create | Find existing Bucket(s)
13+
shell: mmafmcoskeys all get --report | tail -n +2 | cut -d '=' -f 1 | uniq
14+
register: scale_existing_bucket
15+
changed_when: false
16+
failed_when: false
17+
18+
- debug:
19+
msg: "{{scale_existing_bucket.stdout_lines}}"
20+
changed_when: false
21+
failed_when: false
22+
when:
23+
- scale_existing_bucket.stdout_lines is defined
24+
25+
- name: create | Initialize
26+
set_fact:
27+
extra_option_flag: ""
28+
29+
- name: create | Set existing bucket if it is defined
30+
set_fact:
31+
extra_option_flag: "{{ extra_option_flag }} --bucket {{ item.bucket }}"
32+
when:
33+
- item.bucket in scale_existing_bucket.stdout_lines
34+
- item.bucket is defined
35+
36+
- name: create | Set new bucket if it is defined
37+
set_fact:
38+
extra_option_flag: "{{ extra_option_flag }} --new-bucket {{ item.bucket }}"
39+
when:
40+
- item.bucket not in scale_existing_bucket.stdout_lines
41+
- item.bucket is defined
42+
43+
- name: create | Set mode if it is defined
44+
set_fact:
45+
extra_option_flag: "{{ extra_option_flag }} --mode {{ item.mode | default('sw') }}"
46+
47+
- name: configure | Create a AFM cos relationship with filesets
48+
command: "{{ scale_command_path }}mmafmcosconfig {{ item.filesystem }} {{ item.fileset }} --endpoint {{ item.endpoint }} {{ extra_option_flag }} --object-fs --xattr --acls"
49+
register: scale_afm_cos_define
50+
failed_when: scale_afm_cos_define.rc != 0
51+
when:
52+
- not "enabled" in scale_existing_afmcos.stdout_lines
53+
- item.filesystem is defined
54+
- item.fileset is defined
55+
56+
- name: configure | Add Number of Gateway Flush Threads for AFM filsets
57+
command: "mmchfileset {{ item.filesystem }} {{ item.fileset }} -p afmNumFlushThreads=8"
58+
failed_when: scale_afm_cos_define.rc != 0
59+
run_once: true
60+
when:
61+
- not "enabled" in scale_existing_afmcos.stdout_lines
62+
- item.filesystem is defined
63+
- item.fileset is defined
64+
65+
- name: Update permissions for AFM COS filesets
66+
shell: >
67+
find {{ scale_storage[0].defaultMountPoint }}/{{ item.fileset }} -type d ! -path '{{ scale_storage[0].defaultMountPoint }}/{{ item.fileset }}/.snapshots' -exec chmod 777 {} +
68+
failed_when: scale_afm_cos_define.rc != 0
69+
ignore_errors: yes
70+
run_once: true
71+
when:
72+
- not "enabled" in scale_existing_afmcos.stdout_lines
73+
- item.filesystem is defined
74+
- item.fileset is defined
75+
76+
- debug:
77+
msg: "{{scale_afm_cos_define}}"
78+
79+
- name: configure | Create a AFM cos default configuration with filesets
80+
command: "{{ scale_command_path }}mmchfileset {{ item.filesystem }} {{ item.fileset }} -p afmdirlookuprefreshinterval=default -p afmfilelookuprefreshinterval=default -p afmfileopenrefreshinterval=default -p afmdiropenrefreshinterval=default -p afmSkipHomeRefresh=no"
81+
register: scale_afm_cos_config_define
82+
failed_when: false
83+
when:
84+
- not "enabled" in scale_existing_afmcos.stdout_lines
85+
- item.filesystem is defined
86+
- item.fileset is defined
87+
88+
- debug:
89+
msg: "{{scale_afm_cos_config_define}}"
90+
91+
- name: configure | FM cos configuration
92+
debug:
93+
msg: AFM cos configured.
94+
rescue:
95+
- name: Failure detected in Configuring AFM cos
96+
fail:
97+
msg: "I caught an error, Please take a look to the output given!."
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
- name: configure | Initialize lists
3+
set_fact:
4+
scale_gateway_nodes: []
5+
6+
- name: cluster | Find gateway nodes
7+
add_host:
8+
name: "{{ item }}"
9+
groups: scale_gateway_nodes
10+
when: hostvars[item].scale_cluster_gateway | bool
11+
with_items: "{{ ansible_play_hosts }}"
12+
changed_when: false
13+
14+
- name: configure | Setting server licenses on AFM gateway nodes
15+
vars:
16+
scale_gateway_node: "{{ groups['scale_gateway_nodes'] | list }}"
17+
command: "{{ scale_command_path }}mmchlicense server --accept -N {{ scale_gateway_node | join(',') }}"
18+
when: groups['scale_gateway_nodes'] | list | length > 0
19+
run_once: true
20+
21+
- name: configure | Enabling AFM gateway
22+
vars:
23+
scale_gateway_node: "{{ groups['scale_gateway_nodes'] | list }}"
24+
command: "{{ scale_command_path }}mmchnode -N {{ scale_gateway_node | join(',') }} --gateway"
25+
when: groups['scale_gateway_nodes'] | list | length > 0
26+
register: result_gateway
27+
run_once: true
28+
29+
- debug:
30+
msg: "{{ result_gateway.cmd }}"
31+
when: result_gateway.cmd is defined
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- name: configure | Initialize lists of AFM Nodes
3+
set_fact:
4+
scale_gateway_nodes: []
5+
6+
- name: cluster | Find AFM gateway nodes
7+
add_host:
8+
name: "{{ item }}"
9+
groups: scale_gateway_nodes
10+
when: hostvars[item].scale_cluster_gateway | bool
11+
with_items: "{{ ansible_play_hosts }}"
12+
changed_when: false
13+
14+
- name: configure | Setting AFM Sensors on AFM gateway nodes
15+
vars:
16+
scale_gateway_node: "{{ groups['scale_gateway_nodes'] | list }}"
17+
command: "{{ scale_command_path }}mmperfmon config update GPFSAFMFS.restrict={{ scale_gateway_node | join(',') }} GPFSAFMFS.period=10 GPFSAFMFSET.restrict={{ scale_gateway_node | join(',') }} GPFSAFMFS.period=10 GPFSAFMFSET.restrict={{ scale_gateway_node | join(',') }} GPFSAFMFSET.period=10 GPFSAFM.restrict={{ scale_gateway_node | join(',') }} GPFSAFM.period=10"
18+
when: groups['scale_gateway_nodes'] | list | length > 0
19+
run_once: true
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
# tasks file for configure
3+
- include_tasks: afm_gateway.yml
4+
tags: configure
5+
run_once: true
6+
7+
- include_tasks: afm_bucket.yml
8+
tags: configure
9+
when:
10+
- scale_afm_cos_bucket_params is defined
11+
with_items:
12+
- "{{ scale_afm_cos_bucket_params }}"
13+
run_once: true
14+
15+
- include_tasks: afm_configure.yml
16+
tags: configure
17+
when:
18+
- scale_afm_cos_filesets_params is defined
19+
with_items:
20+
- "{{ scale_afm_cos_filesets_params }}"
21+
run_once: true
22+
23+
- include_tasks: afm_sensor_configure.yml
24+
tags: configure
25+
run_once: true
26+
27+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
localhost
2+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- hosts: localhost
3+
remote_user: root
4+
roles:
5+
- configure

roles/afm_cos_configure/vars/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
# Variables for the IBM Spectrum Scale (ECE) (Erasure Code Edition) role -
3+
# these variables are *not* meant to be overridden
4+
5+
# default mm command exection path
6+
scale_command_path: /usr/lpp/mmfs/bin/

roles/core_configure/tasks/config.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,27 @@
7171
#
7272
# Apply config params
7373
#
74+
- name: config | Creat a list of configuration parameter for configuration
75+
set_fact:
76+
config_list: >
77+
{%- set config_list = [] -%}
78+
{%- for nc in scale_config -%}
79+
{%- for param in nc.params -%}
80+
{%- for key, value in param.items() -%}
81+
{{ config_list.append({'nodeclass': nc.nodeclass, 'key': key, 'value': value}) }}
82+
{%- endfor -%}
83+
{%- endfor -%}
84+
{%- endfor -%}
85+
{{ config_list }}
86+
7487
- name: config | Apply defined configuration parameters
75-
vars:
76-
current_key: "{{ item.1.keys() | list | first }}"
77-
current_value: "{{ item.1[current_key] | string | regex_replace('True', 'yes') | regex_replace('False', 'no') }}"
78-
current_nodeclass: "{{ item.0.nodeclass }}"
79-
command: /usr/lpp/mmfs/bin/mmchconfig {{ current_key }}={{ current_value }} -N {{ current_nodeclass }}
88+
command: /usr/lpp/mmfs/bin/mmchconfig {{ item.key }}={{ item.value | string | regex_replace('True', 'yes') | regex_replace('False', 'no') }} -N {{ item.nodeclass }}
8089
register: scale_config_changed_params
8190
when:
82-
not scale_config_existing_params.stdout | lower is
83-
search(':' + current_key | lower + ':' + current_value | lower + ':(.+,)?' + current_nodeclass | lower | regex_replace('all', '') + '(,.+)?:')
84-
with_subelements:
85-
- "{{ ansible_play_hosts | map('extract', hostvars, 'scale_config') | sum(start=[]) | unique }}"
86-
- params
91+
not scale_config_existing_params.stdout | lower is search(':' + item.key | lower + ':' + item.value | string | lower + ':(.+,)?' + item.nodeclass | lower | regex_replace('all', '') + '(,.+)?:')
92+
loop: "{{ config_list }}"
93+
loop_control:
94+
label: "{{ item.nodeclass }}: {{ item.key }}"
8795

8896
- name: config | Check if configuration parameters were changed
8997
set_fact:

roles/core_configure/tasks/storage_fileset.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
- name: Quota allocation for filesets
6767
block: ## run_once: true
6868
- name: Check quota is already enabled
69-
shell: "/usr/lpp/mmfs/bin/mmlsfs fs1 -Y | grep -w 'quotasAccountingEnabled' | grep -w 'user;group;fileset'"
69+
shell: "/usr/lpp/mmfs/bin/mmlsfs {{ scale_storage_existing_fs.stdout }} -Y | grep -w 'quotasAccountingEnabled' | grep -w 'user;group;fileset'"
7070
register: enable_quota_check
7171
loop: "{{ scale_storage[0].filesets | dict2items }}"
7272
ignore_errors: yes

roles/encryption_configure/tasks/apply_encryption_policy.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
---
22
# Applying encryption policy to the filesystem
33

4+
- name: storage | Find existing filesystem
5+
shell: /usr/lpp/mmfs/bin/mmlsfs all -Y | grep -v HEADER | cut -d ':' -f 7 | uniq
6+
register: scale_storage_existing_fs
7+
changed_when: false
8+
failed_when: false
9+
410
# Make default variables available in hostvars
511
- name: Encryption | Applying encryption policy to the filesystem
6-
command: mmchpolicy fs1 "{{ gklm_dir }}/encryption_policy.pol"
12+
command: mmchpolicy {{ scale_storage_existing_fs.stdout }} "{{ gklm_dir }}/encryption_policy.pol"
713
register: apply_pol_fs_output
814
run_once: true
915
- debug:

roles/encryption_configure/tasks/check_filesystem.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33

44
# Make default variables available in hostvars
55

6+
- name: storage | Find existing filesystem
7+
shell: /usr/lpp/mmfs/bin/mmlsfs all -Y | grep -v HEADER | cut -d ':' -f 7 | uniq
8+
register: scale_storage_existing_fs
9+
changed_when: false
10+
failed_when: false
11+
612
- name: Encryption | Filesystem | Check
7-
shell: mount | grep -q "fs1" && echo "mounted" || echo "not mounted"
13+
shell: mount | grep -q "{{ scale_storage_existing_fs.stdout }}" && echo "mounted" || echo "not mounted"
814
register: mount_status
915
changed_when: false
1016

0 commit comments

Comments
 (0)