Skip to content

Commit

Permalink
Merge pull request #811 from jayeshh123/jay_afm_new_var
Browse files Browse the repository at this point in the history
Changes for AFM
  • Loading branch information
rajan-mis authored Aug 6, 2024
2 parents 681f507 + 80a927c commit 0ca09aa
Show file tree
Hide file tree
Showing 16 changed files with 326 additions and 13 deletions.
Empty file.
35 changes: 35 additions & 0 deletions roles/afm_cos_configure/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
# Default variables for the IBM Spectrum Scale AFM Cos Configure role -
## Spectrum Scale daemon nodename (defaults to node's hostname)
scale_daemon_nodename: "{{ ansible_hostname }}"

#"scale_afm_cos_bucket_params": [
# {
# "bucket": "test",
# "akey": "xxxxxxxx",
# "skey": "xxxxxxxx",
# },
# {
# "bucket": "test1",
# "akey": "xxxxxxxxx",
# "skey": "xxxxxxxxx",
# },
#]

#"scale_afm_cos_filesets_params": [
# {
# "filesystem": "fs1",
# "fileset": "afmfileset1",
# "endpoint": "https://s3.ap.cos.appdomain.cloud:443/bucket-afm1",
# "bucket": "bucket-afm1",
# "mode": "SW",
# },
# {
# "filesystem": "fs1",
# "fileset": "afmfileset2",
# "endpoint": "https://s3.ap.cos.appdomain.cloud:443/bucket-afm2",
# "bucket": "bucket-afm2",
# "mode": "SW"
# }
#]

2 changes: 2 additions & 0 deletions roles/afm_cos_configure/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# handlers file for configure
20 changes: 20 additions & 0 deletions roles/afm_cos_configure/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
galaxy_info:
author: IBM Corporation
description: Role for configuring IBM Spectrum Scale AFM COS configuration role
company: IBM

license: Apache-2.0

min_ansible_version: 2.9

platforms:
- name: EL
versions:
- 7
- 8
- 9

galaxy_tags: []

dependencies: []
49 changes: 49 additions & 0 deletions roles/afm_cos_configure/tasks/afm_bucket.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
- block:
- name: create | Initialize
set_fact:
extra_option_flag: ""

- name: create | Set existing bucket if it is defined
set_fact:
extra_option_flag: "{{ extra_option_flag }}{{ item.bucket }}"
when:
- item.bucket is defined
- name: create | Set existing bucket if it is defined
set_fact:
extra_option_flag: "{{ extra_option_flag }}:{{ item.Region}}"
when:
- item.Region is defined

- name: create | Set existing bucket if it is defined
set_fact:
extra_option_flag: "{{ extra_option_flag }}@{{ item.Server}}"
when:
- item.Server is defined

- name: configure | Set the access key and secret key for new/existing bucket as below at gateway node
command: "{{ scale_command_path }}mmafmcoskeys {{ extra_option_flag }} set {{ item.akey }} {{ item.skey }}"
register: scale_afm_cos_define
failed_when: scale_afm_cos_define.rc != 0
when:
- item.bucket is defined
- item.akey is defined
- item.skey is defined

- name: configure | Set the access key and secret key for new/existing bucket as below at gateway node
command: "{{ scale_command_path }}mmafmcoskeys {{ item.bucket }}:{{ item.Region }}@{{ item.Server }} set --keyfile {{ item.KeyfilePath }}"
register: scale_afm_cos_define
failed_when: scale_afm_cos_define.rc != 0
when:
- item.bucket is defined
- item.Region is defined
- item.Server is defined
- item.KeyfilePath is defined

- name: configure | FM cos bucket configuration
debug:
msg: AFM cos bucket configured.
rescue:
- name: Failure detected in Configuring AFM cos bucket
fail:
msg: "I caught an error, Please take a look to the output given!."
97 changes: 97 additions & 0 deletions roles/afm_cos_configure/tasks/afm_configure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
- block:
- name: create | Find existing AFM cos enabled Filesystem
shell: mmlsfileset {{ item.filesystem }} {{ item.fileset }} --afm -Y | grep -v HEADER | cut -d ':' -f 20 | uniq
register: scale_existing_afmcos
changed_when: false
failed_when: false
when:
- item.filesystem is defined
- item.fileset is defined

- name: create | Find existing Bucket(s)
shell: mmafmcoskeys all get --report | tail -n +2 | cut -d '=' -f 1 | uniq
register: scale_existing_bucket
changed_when: false
failed_when: false

- debug:
msg: "{{scale_existing_bucket.stdout_lines}}"
changed_when: false
failed_when: false
when:
- scale_existing_bucket.stdout_lines is defined

- name: create | Initialize
set_fact:
extra_option_flag: ""

- name: create | Set existing bucket if it is defined
set_fact:
extra_option_flag: "{{ extra_option_flag }} --bucket {{ item.bucket }}"
when:
- item.bucket in scale_existing_bucket.stdout_lines
- item.bucket is defined

- name: create | Set new bucket if it is defined
set_fact:
extra_option_flag: "{{ extra_option_flag }} --new-bucket {{ item.bucket }}"
when:
- item.bucket not in scale_existing_bucket.stdout_lines
- item.bucket is defined

- name: create | Set mode if it is defined
set_fact:
extra_option_flag: "{{ extra_option_flag }} --mode {{ item.mode | default('sw') }}"

- name: configure | Create a AFM cos relationship with filesets
command: "{{ scale_command_path }}mmafmcosconfig {{ item.filesystem }} {{ item.fileset }} --endpoint {{ item.endpoint }} {{ extra_option_flag }} --object-fs --xattr --acls"
register: scale_afm_cos_define
failed_when: scale_afm_cos_define.rc != 0
when:
- not "enabled" in scale_existing_afmcos.stdout_lines
- item.filesystem is defined
- item.fileset is defined

- name: configure | Add Number of Gateway Flush Threads for AFM filsets
command: "mmchfileset {{ item.filesystem }} {{ item.fileset }} -p afmNumFlushThreads=8"
failed_when: scale_afm_cos_define.rc != 0
run_once: true
when:
- not "enabled" in scale_existing_afmcos.stdout_lines
- item.filesystem is defined
- item.fileset is defined

- name: Update permissions for AFM COS filesets
shell: >
find {{ scale_storage[0].defaultMountPoint }}/{{ item.fileset }} -type d ! -path '{{ scale_storage[0].defaultMountPoint }}/{{ item.fileset }}/.snapshots' -exec chmod 777 {} +
failed_when: scale_afm_cos_define.rc != 0
ignore_errors: yes
run_once: true
when:
- not "enabled" in scale_existing_afmcos.stdout_lines
- item.filesystem is defined
- item.fileset is defined

- debug:
msg: "{{scale_afm_cos_define}}"

- name: configure | Create a AFM cos default configuration with filesets
command: "{{ scale_command_path }}mmchfileset {{ item.filesystem }} {{ item.fileset }} -p afmdirlookuprefreshinterval=default -p afmfilelookuprefreshinterval=default -p afmfileopenrefreshinterval=default -p afmdiropenrefreshinterval=default -p afmSkipHomeRefresh=no"
register: scale_afm_cos_config_define
failed_when: false
when:
- not "enabled" in scale_existing_afmcos.stdout_lines
- item.filesystem is defined
- item.fileset is defined

- debug:
msg: "{{scale_afm_cos_config_define}}"

- name: configure | FM cos configuration
debug:
msg: AFM cos configured.
rescue:
- name: Failure detected in Configuring AFM cos
fail:
msg: "I caught an error, Please take a look to the output given!."
31 changes: 31 additions & 0 deletions roles/afm_cos_configure/tasks/afm_gateway.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
- name: configure | Initialize lists
set_fact:
scale_gateway_nodes: []

- name: cluster | Find gateway nodes
add_host:
name: "{{ item }}"
groups: scale_gateway_nodes
when: hostvars[item].scale_cluster_gateway | bool
with_items: "{{ ansible_play_hosts }}"
changed_when: false

- name: configure | Setting server licenses on AFM gateway nodes
vars:
scale_gateway_node: "{{ groups['scale_gateway_nodes'] | list }}"
command: "{{ scale_command_path }}mmchlicense server --accept -N {{ scale_gateway_node | join(',') }}"
when: groups['scale_gateway_nodes'] | list | length > 0
run_once: true

- name: configure | Enabling AFM gateway
vars:
scale_gateway_node: "{{ groups['scale_gateway_nodes'] | list }}"
command: "{{ scale_command_path }}mmchnode -N {{ scale_gateway_node | join(',') }} --gateway"
when: groups['scale_gateway_nodes'] | list | length > 0
register: result_gateway
run_once: true

- debug:
msg: "{{ result_gateway.cmd }}"
when: result_gateway.cmd is defined
19 changes: 19 additions & 0 deletions roles/afm_cos_configure/tasks/afm_sensor_configure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: configure | Initialize lists of AFM Nodes
set_fact:
scale_gateway_nodes: []

- name: cluster | Find AFM gateway nodes
add_host:
name: "{{ item }}"
groups: scale_gateway_nodes
when: hostvars[item].scale_cluster_gateway | bool
with_items: "{{ ansible_play_hosts }}"
changed_when: false

- name: configure | Setting AFM Sensors on AFM gateway nodes
vars:
scale_gateway_node: "{{ groups['scale_gateway_nodes'] | list }}"
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"
when: groups['scale_gateway_nodes'] | list | length > 0
run_once: true
27 changes: 27 additions & 0 deletions roles/afm_cos_configure/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
# tasks file for configure
- include_tasks: afm_gateway.yml
tags: configure
run_once: true

- include_tasks: afm_bucket.yml
tags: configure
when:
- scale_afm_cos_bucket_params is defined
with_items:
- "{{ scale_afm_cos_bucket_params }}"
run_once: true

- include_tasks: afm_configure.yml
tags: configure
when:
- scale_afm_cos_filesets_params is defined
with_items:
- "{{ scale_afm_cos_filesets_params }}"
run_once: true

- include_tasks: afm_sensor_configure.yml
tags: configure
run_once: true


2 changes: 2 additions & 0 deletions roles/afm_cos_configure/tests/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
localhost

5 changes: 5 additions & 0 deletions roles/afm_cos_configure/tests/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- configure
6 changes: 6 additions & 0 deletions roles/afm_cos_configure/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
# Variables for the IBM Spectrum Scale (ECE) (Erasure Code Edition) role -
# these variables are *not* meant to be overridden

# default mm command exection path
scale_command_path: /usr/lpp/mmfs/bin/
28 changes: 18 additions & 10 deletions roles/core_configure/tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,27 @@
#
# Apply config params
#
- name: config | Creat a list of configuration parameter for configuration
set_fact:
config_list: >
{%- set config_list = [] -%}
{%- for nc in scale_config -%}
{%- for param in nc.params -%}
{%- for key, value in param.items() -%}
{{ config_list.append({'nodeclass': nc.nodeclass, 'key': key, 'value': value}) }}
{%- endfor -%}
{%- endfor -%}
{%- endfor -%}
{{ config_list }}
- name: config | Apply defined configuration parameters
vars:
current_key: "{{ item.1.keys() | list | first }}"
current_value: "{{ item.1[current_key] | string | regex_replace('True', 'yes') | regex_replace('False', 'no') }}"
current_nodeclass: "{{ item.0.nodeclass }}"
command: /usr/lpp/mmfs/bin/mmchconfig {{ current_key }}={{ current_value }} -N {{ current_nodeclass }}
command: /usr/lpp/mmfs/bin/mmchconfig {{ item.key }}={{ item.value | string | regex_replace('True', 'yes') | regex_replace('False', 'no') }} -N {{ item.nodeclass }}
register: scale_config_changed_params
when:
not scale_config_existing_params.stdout | lower is
search(':' + current_key | lower + ':' + current_value | lower + ':(.+,)?' + current_nodeclass | lower | regex_replace('all', '') + '(,.+)?:')
with_subelements:
- "{{ ansible_play_hosts | map('extract', hostvars, 'scale_config') | sum(start=[]) | unique }}"
- params
not scale_config_existing_params.stdout | lower is search(':' + item.key | lower + ':' + item.value | string | lower + ':(.+,)?' + item.nodeclass | lower | regex_replace('all', '') + '(,.+)?:')
loop: "{{ config_list }}"
loop_control:
label: "{{ item.nodeclass }}: {{ item.key }}"

- name: config | Check if configuration parameters were changed
set_fact:
Expand Down
2 changes: 1 addition & 1 deletion roles/core_configure/tasks/storage_fileset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
- name: Quota allocation for filesets
block: ## run_once: true
- name: Check quota is already enabled
shell: "/usr/lpp/mmfs/bin/mmlsfs fs1 -Y | grep -w 'quotasAccountingEnabled' | grep -w 'user;group;fileset'"
shell: "/usr/lpp/mmfs/bin/mmlsfs {{ scale_storage_existing_fs.stdout }} -Y | grep -w 'quotasAccountingEnabled' | grep -w 'user;group;fileset'"
register: enable_quota_check
loop: "{{ scale_storage[0].filesets | dict2items }}"
ignore_errors: yes
Expand Down
8 changes: 7 additions & 1 deletion roles/encryption_configure/tasks/apply_encryption_policy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
---
# Applying encryption policy to the filesystem

- name: storage | Find existing filesystem
shell: /usr/lpp/mmfs/bin/mmlsfs all -Y | grep -v HEADER | cut -d ':' -f 7 | uniq
register: scale_storage_existing_fs
changed_when: false
failed_when: false

# Make default variables available in hostvars
- name: Encryption | Applying encryption policy to the filesystem
command: mmchpolicy fs1 "{{ gklm_dir }}/encryption_policy.pol"
command: mmchpolicy {{ scale_storage_existing_fs.stdout }} "{{ gklm_dir }}/encryption_policy.pol"
register: apply_pol_fs_output
run_once: true
- debug:
Expand Down
8 changes: 7 additions & 1 deletion roles/encryption_configure/tasks/check_filesystem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@

# Make default variables available in hostvars

- name: storage | Find existing filesystem
shell: /usr/lpp/mmfs/bin/mmlsfs all -Y | grep -v HEADER | cut -d ':' -f 7 | uniq
register: scale_storage_existing_fs
changed_when: false
failed_when: false

- name: Encryption | Filesystem | Check
shell: mount | grep -q "fs1" && echo "mounted" || echo "not mounted"
shell: mount | grep -q "{{ scale_storage_existing_fs.stdout }}" && echo "mounted" || echo "not mounted"
register: mount_status
changed_when: false

Expand Down

0 comments on commit 0ca09aa

Please sign in to comment.