summaryrefslogtreecommitdiffstats
path: root/ansible_collections/dellemc/powerflex/roles/powerflex_config
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/dellemc/powerflex/roles/powerflex_config')
-rw-r--r--ansible_collections/dellemc/powerflex/roles/powerflex_config/README.md165
-rw-r--r--ansible_collections/dellemc/powerflex/roles/powerflex_config/defaults/main.yml6
-rw-r--r--ansible_collections/dellemc/powerflex/roles/powerflex_config/meta/argument_specs.yml50
-rw-r--r--ansible_collections/dellemc/powerflex/roles/powerflex_config/meta/main.yml25
-rw-r--r--ansible_collections/dellemc/powerflex/roles/powerflex_config/molecule/configure_protection_domain/converge.yml47
-rw-r--r--ansible_collections/dellemc/powerflex/roles/powerflex_config/molecule/configure_protection_domain/molecule.yml1
-rw-r--r--ansible_collections/dellemc/powerflex/roles/powerflex_config/tasks/main.yml79
-rw-r--r--ansible_collections/dellemc/powerflex/roles/powerflex_config/vars/main.yml2
8 files changed, 375 insertions, 0 deletions
diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_config/README.md b/ansible_collections/dellemc/powerflex/roles/powerflex_config/README.md
new file mode 100644
index 000000000..987773d88
--- /dev/null
+++ b/ansible_collections/dellemc/powerflex/roles/powerflex_config/README.md
@@ -0,0 +1,165 @@
+# powerflex_config
+
+Role to configure the protection domain, fault set and storage pool.
+
+## Table of contents
+
+* [Requirements](#requirements)
+* [Ansible collections](#ansible-collections)
+* [Role Variables](#role-variables)
+* [Examples](#examples)
+* [Usage instructions](#usage-instructions)
+* [Notes](#notes)
+* [Author Information](#author-information)
+
+## Requirements
+
+```
+ansible
+python
+```
+
+## Ansible collections
+
+Collections required to use the role.
+
+```
+dellemc.powerflex
+```
+
+## Role Variables
+
+<table>
+<thead>
+ <tr>
+ <th>Name</th>
+ <th>Required</th>
+ <th>Description</th>
+ <th>Choices</th>
+ <th>Type</th>
+ <th>Default Value</th>
+ </tr>
+</thead>
+<tbody>
+ <tr>
+ <td>hostname</td>
+ <td>true</td>
+ <td>IP or FQDN of the PowerFlex host.</td>
+ <td></td>
+ <td>str</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>username</td>
+ <td>true</td>
+ <td>The username of the PowerFlex host.</td>
+ <td></td>
+ <td>str</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>password</td>
+ <td>true</td>
+ <td>The password of the PowerFlex host.</td>
+ <td></td>
+ <td>str</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>port</td>
+ <td>false</td>
+ <td>Port of the PowerFlex host.</td>
+ <td></td>
+ <td>int</td>
+ <td>443</td>
+ </tr>
+ <tr>
+ <td>validate_certs</td>
+ <td>false</td>
+ <td>If C(false), the SSL certificates will not be validated.<br>Configure C(false) only on personally controlled sites where self-signed certificates are used.</td>
+ <td></td>
+ <td>bool</td>
+ <td>false</td>
+ </tr>
+ <tr>
+ <td>powerflex_protection_domain_name</td>
+ <td>false</td>
+ <td>Name of the protection domain.<br></td>
+ <td></td>
+ <td>str</td>
+ <td>config_protection_domain</td>
+ </tr>
+ <tr>
+ <td>powerflex_fault_sets</td>
+ <td>false</td>
+ <td>List of fault sets.<br></td>
+ <td></td>
+ <td>list</td>
+ <td>['fs1','fs2','fs3']</td>
+ </tr>
+ <tr>
+ <td>powerflex_media_type</td>
+ <td>false</td>
+ <td>Media type of the storage pool.<br></td>
+ <td>'SSD', 'HDD', 'TRANSITIONAL'</td>
+ <td>str</td>
+ <td>SSD</td>>
+ </tr>
+ <tr>
+ <td>powerflex_storage_pool_name</td>
+ <td>false</td>
+ <td>Name of the storage pool.<br></td>
+ <td></td>
+ <td>str</td>
+ <td>config_storage_pool</td>
+ </tr>
+</tbody>
+</table>
+
+## Examples
+----
+```
+ - name: Configuration of protection domain, fault set and storage pool.
+ ansible.builtin.import_role:
+ name: "powerflex_config"
+ vars:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: "{{ validate_certs }}"
+ port: "{{ port }}"
+ powerflex_protection_domain_name: "protection_domain"
+ powerflex_fault_sets:
+ - 'fs1'
+ - 'fs2'
+ - 'fs3'
+ powerflex_media_type: 'SSD'
+ powerflex_storage_pool_name: "storage_pool"
+
+```
+
+## Usage instructions
+----
+### To configure the protection domain and storage pool:
+- PowerFlex 3.6:
+ ```
+ ansible-playbook -i inventory site.yml
+ ```
+- PowerFlex 4.5:
+ ```
+ ansible-playbook -i inventory site_powerflex45.yml
+ ```
+
+Sample playbooks and inventory can be found in the playbooks directory.
+
+## Notes
+----
+
+- As a pre-requisite, the Gateway must be installed.
+- TRANSITIONAL media type is supported only during modification.
+
+## Author Information
+------------------
+
+Dell Technologies </br>
+Felix Stephen A (ansible.team@Dell.com) 2023
diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_config/defaults/main.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_config/defaults/main.yml
new file mode 100644
index 000000000..0cb687ecb
--- /dev/null
+++ b/ansible_collections/dellemc/powerflex/roles/powerflex_config/defaults/main.yml
@@ -0,0 +1,6 @@
+---
+# defaults file for powerflex_config
+powerflex_protection_domain_name: "domain1"
+powerflex_fault_sets: ['fs1', 'fs2', 'fs3']
+powerflex_media_type: 'SSD' # When version is R3
+powerflex_storage_pool_name: "pool1"
diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_config/meta/argument_specs.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_config/meta/argument_specs.yml
new file mode 100644
index 000000000..bd94c306f
--- /dev/null
+++ b/ansible_collections/dellemc/powerflex/roles/powerflex_config/meta/argument_specs.yml
@@ -0,0 +1,50 @@
+---
+argument_specs:
+ main:
+ short_description: Role to configure the protection domain, fault set and storage pool.
+ description:
+ - Role to configure the protection domain, fault set and storage pool.
+ options:
+ hostname:
+ required: true
+ type: str
+ description: IP or FQDN of the PowerFlex gateway.
+ username:
+ required: true
+ type: str
+ description: The username of the PowerFlex gateway.
+ password:
+ required: true
+ type: str
+ description: The password of the PowerFlex gateway.
+ port:
+ type: int
+ description: Port of the PowerFlex gateway.
+ default: 443
+ validate_certs:
+ description:
+ - If C(false), the SSL certificates will not be validated.
+ - Configure C(false) only on personally controlled sites where self-signed certificates are used.
+ type: bool
+ default: false
+ timeout:
+ description: Timeout.
+ type: int
+ default: 120
+ powerflex_protection_domain_name:
+ type: str
+ description: Name of the protection domain.
+ default: 'config_protection_domain'
+ powerflex_fault_sets:
+ description: List of fault sets.
+ type: list
+ default: ['fs1', 'fs2', 'fs3']
+ powerflex_media_type:
+ description: Media type of the storage pool.
+ type: str
+ choices: ['SSD', 'HDD', 'TRANSITIONAL']
+ default: 'SSD'
+ powerflex_storage_pool_name:
+ description: Name of the storage pool.
+ type: str
+ default: 'config_storage_pool'
diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_config/meta/main.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_config/meta/main.yml
new file mode 100644
index 000000000..9924409c8
--- /dev/null
+++ b/ansible_collections/dellemc/powerflex/roles/powerflex_config/meta/main.yml
@@ -0,0 +1,25 @@
+---
+galaxy_info:
+ author: Felix Stephen A
+ description: Role to configure the protection domain, fault set and storage pool.
+ company: Dell Technologies
+ license: GPL-3.0-only
+ role_name: powerflex_config
+ namespace: dellemc
+
+ min_ansible_version: "2.14.0"
+ platforms:
+ - name: EL
+ versions:
+ - "9"
+ - "8"
+ - name: Ubuntu
+ versions:
+ - jammy
+
+ - name: SLES
+ versions:
+ - "15SP3"
+ - "15SP4"
+
+ galaxy_tags: []
diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_config/molecule/configure_protection_domain/converge.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_config/molecule/configure_protection_domain/converge.yml
new file mode 100644
index 000000000..1fb1c2425
--- /dev/null
+++ b/ansible_collections/dellemc/powerflex/roles/powerflex_config/molecule/configure_protection_domain/converge.yml
@@ -0,0 +1,47 @@
+---
+- name: Molecule Test for Configuring Protection Domain
+ hosts: mdm
+ vars_files:
+ - ../../../../playbooks/roles/vars_files/connection.yml
+
+ tasks:
+ - name: Run Config role
+ ansible.builtin.import_role:
+ name: "powerflex_config"
+ register: powerflex_config_result
+
+ - name: "Verifying protection domain creation"
+ ansible.builtin.assert:
+ that:
+ - powerflex_config_add_pd_output.protection_domain_details.name == powerflex_protection_domain_name
+ when: not ansible_check_mode and powerflex_config_add_pd_output.changed
+
+ - name: "Verifying storage pool R2 creation"
+ ansible.builtin.assert:
+ that:
+ - powerflex_config_storage_pool_output.storage_pool_details.name == powerflex_storage_pool_name
+ when: not ansible_check_mode and powerflex_config_storage_pool_output.changed
+
+ - name: "Verifying storage pool R3 creation"
+ ansible.builtin.assert:
+ that:
+ - powerflex_config_storage_pool_output.storage_pool_details.name == powerflex_storage_pool_name
+ when: not ansible_check_mode and powerflex_config_storage_pool_output.changed and powerflex_media_type is not none
+
+ - name: "Verifying protection domain creation in Idempotency"
+ ansible.builtin.assert:
+ that:
+ - powerflex_config_add_pd_output.protection_domain_details.name == powerflex_protection_domain_name
+ when: not ansible_check_mode and powerflex_config_add_pd_output.changed
+
+ - name: "Verifying storage pool R2 creation in Idempotency"
+ ansible.builtin.assert:
+ that:
+ powerflex_config_storage_pool_output.storage_pool_details.name == powerflex_storage_pool_name
+ when: not ansible_check_mode and powerflex_config_storage_pool_output.changed
+
+ - name: "Verifying storage pool R3 creation in Idempotency"
+ ansible.builtin.assert:
+ that:
+ - powerflex_config_storage_pool_output.storage_pool_details.name == powerflex_storage_pool_name
+ when: not ansible_check_mode and powerflex_config_storage_pool_output.changed and powerflex_media_type is not none
diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_config/molecule/configure_protection_domain/molecule.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_config/molecule/configure_protection_domain/molecule.yml
new file mode 100644
index 000000000..ed97d539c
--- /dev/null
+++ b/ansible_collections/dellemc/powerflex/roles/powerflex_config/molecule/configure_protection_domain/molecule.yml
@@ -0,0 +1 @@
+---
diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_config/tasks/main.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_config/tasks/main.yml
new file mode 100644
index 000000000..f9340f0fd
--- /dev/null
+++ b/ansible_collections/dellemc/powerflex/roles/powerflex_config/tasks/main.yml
@@ -0,0 +1,79 @@
+---
+- name: Get configured MDM IP addresses
+ dellemc.powerflex.mdm_cluster:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: "{{ validate_certs }}"
+ state: "present"
+ register: powerflex_config_mdm_ip_result
+ delegate_to: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}"
+
+- name: Set fact - PowerFlex version and MDM primary hostname
+ ansible.builtin.set_fact:
+ powerflex_config_array_version: "{{ powerflex_config_mdm_ip_result.mdm_cluster_details.master.versionInfo[1] }}"
+ powerflex_config_mdm_primary_hostname: "{{ hostvars[groups['mdm'][0]]['inventory_hostname'] }}"
+
+- name: Login to primary MDM of PowerFlex 3.6
+ ansible.builtin.command: scli --login --username {{ username }} --password "{{ password }}"
+ run_once: true
+ register: powerflex_config_login_output
+ changed_when: powerflex_config_login_output.rc == 0
+ delegate_to: "{{ powerflex_config_mdm_primary_hostname }}"
+ when: powerflex_config_array_version == '3'
+
+- name: Login to primary MDM of PowerFlex 4.5
+ ansible.builtin.command: scli --login --username {{ username }} --management_system_ip {{ hostname }} --password "{{ password }}"
+ run_once: true
+ register: powerflex_config_login_output
+ changed_when: powerflex_config_login_output.rc == 0
+ delegate_to: "{{ powerflex_config_mdm_primary_hostname }}"
+ when: powerflex_config_array_version == '4'
+
+- name: Create the protection domain
+ dellemc.powerflex.protection_domain:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: "{{ validate_certs }}"
+ port: "{{ port }}"
+ protection_domain_name: "{{ powerflex_protection_domain_name }}"
+ is_active: "{{ is_active | default(omit) }}"
+ network_limits: "{{ network_limits | default(omit) }}"
+ rf_cache_limits: "{{ rf_cache_limits | default(omit) }}"
+ state: "present"
+ register: powerflex_config_add_pd_output
+ delegate_to: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}"
+
+- name: Add fault set
+ ansible.builtin.command: scli --add_fault_set --protection_domain_name "{{ powerflex_protection_domain_name }}" --fault_set_name "{{ item }}"
+ with_items: "{{ powerflex_fault_sets }}"
+ run_once: true
+ delegate_to: "{{ powerflex_config_mdm_primary_hostname }}"
+ register: powerflex_config_add_fs_output
+ ignore_errors: true
+ changed_when: powerflex_config_add_fs_output.rc == 0
+ when:
+ - powerflex_fault_sets is defined
+
+- name: Create a new storage pool.
+ dellemc.powerflex.storagepool:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: "{{ validate_certs }}"
+ storage_pool_name: "{{ powerflex_storage_pool_name }}"
+ protection_domain_name: "{{ powerflex_protection_domain_name }}"
+ media_type: "{{ powerflex_media_type | default(omit) }}"
+ state: "present"
+ register: powerflex_config_storage_pool_output
+ delegate_to: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}"
+
+- name: Enable zero-padding
+ ansible.builtin.command: |
+ scli --modify_zero_padding_policy --protection_domain_name
+ {{ powerflex_protection_domain_name }} --storage_pool_name {{ powerflex_storage_pool_name }} --enable_zero_padding
+ run_once: true
+ register: powerflex_config_enable_zero_padding_output
+ changed_when: powerflex_config_enable_zero_padding_output.rc == 0
+ delegate_to: "{{ powerflex_config_mdm_primary_hostname }}"
diff --git a/ansible_collections/dellemc/powerflex/roles/powerflex_config/vars/main.yml b/ansible_collections/dellemc/powerflex/roles/powerflex_config/vars/main.yml
new file mode 100644
index 000000000..ac3d9b959
--- /dev/null
+++ b/ansible_collections/dellemc/powerflex/roles/powerflex_config/vars/main.yml
@@ -0,0 +1,2 @@
+---
+# vars file for powerflex_config