Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Manages software and products from Nimble Storage. This is BETA software.

## Requirements
Ansinimble supports two different product lines. HPE Nimble Storage arrays and HPE Cloud Volumes. Requirements vary slightly between products.

### Nimble Arrays
This role assumes the latest Nimble Linux Toolkit (NLT) is installed on the host being managed by Ansible. The latest version of NLT may be obtained from [InfoSight](https://infosight.nimblestorage.com) (Nimble customers and partners only).

Expand Down Expand Up @@ -230,8 +231,8 @@ nimble_volume_options_default:
description: "Volume created by Ansible"

# Device retries
nimble_device_retries: 3
nimble_device_delay: 10
nimble_device_retries: 5
nimble_device_delay: 24

# NimbleOS HTTP/JSON tunables
nimble_uri_retries: 6
Expand Down Expand Up @@ -295,6 +296,9 @@ nimble_array_config:
- 10.18.173.175 # Support IP address setting node A.
- 10.18.173.176 # Support IP address setting node B.

# Set to 'False' when using multiple initiators dynamically mapping/unmapping the volume
nimble_volume_unmap_volume_connections: True

# Cloud Volumes
cloud_portal_http_host: cloudvolumes.hpe.com

Expand Down
7 changes: 5 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ nimble_perfpolicy_update_options_default:
description: "Performance Policy updated by Ansible"

# Device retries
nimble_device_retries: 3
nimble_device_delay: 10
nimble_device_retries: 5
nimble_device_delay: 24

# NimbleOS HTTP/JSON tunables
nimble_uri_retries: 6
Expand Down Expand Up @@ -172,6 +172,9 @@ nimble_array_config:
- 10.18.173.175 # Support IP address setting node A.
- 10.18.173.176 # Support IP address setting node B.

# Set to 'False' when using multiple initiators dynamically mapping/unmapping the volume
nimble_volume_unmap_volume_connections: True

# Cloud Volumes
cloud_portal_http_host: cloudvolumes.hpe.com

Expand Down
11 changes: 11 additions & 0 deletions examples/nimble/sample_map.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# Provide nimble_volume as parameter to create and map a block device to a host
# $ ansible-playbook -l limit -e nimble_volume=myvol1 sample_map.yml

- hosts: all
roles:
- { role: NimbleStorage.Ansinimble, nimble_object: volume, nimble_operation: create }
- { role: NimbleStorage.Ansinimble, nimble_object: volume, nimble_operation: map }
tasks:
- debug:
var: vars
11 changes: 11 additions & 0 deletions examples/nimble/sample_unmap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# Provide nimble_volume as parameter to unmap a block device from a host and delete the volume
# $ ansible-playbook -l limit -e nimble_volume=myvol1 sample_unmap.yml

- hosts: all
roles:
- { role: NimbleStorage.Ansinimble, nimble_object: volume, nimble_operation: unmap }
- { role: NimbleStorage.Ansinimble, nimble_object: volume, nimble_operation: delete }
tasks:
- debug:
var: nimble_volume_device_name
31 changes: 27 additions & 4 deletions tasks/nimble_volume_map.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---
- name: Ensure nimble_volume
fail: msg="Missing variable nimble_volume, please provide a volume name in nimble_volume"
when: nimble_volume is undefined
- name: Ensure play variables are sane
fail:
msg: "Missing variable {{ item }}"
when: vars[item] is undefined
with_items:
- nimble_volume

- name: Host facts
include: nimble_host_facts.yml
Expand All @@ -12,9 +15,10 @@
vars:
nimble_group_facts:
initiator_groups: "fields=name,id"
volumes: "fields=name,id,access_control_records&name={{ nimble_volume }}"
volumes: "fields=name,id,target_name,serial_number,access_control_records&name={{ nimble_volume }}"
access_control_records: "fields=id,initiator_group_id,vol_id&vol_name={{ nimble_volume }}"
initiators: "fields=id,label"
subnets: "fields=allow_iscsi,discovery_ip"

- name: Merge nimble_initiator_group_options
set_fact:
Expand Down Expand Up @@ -130,3 +134,22 @@
delay: "{{ nimble_uri_delay }}"
register: nimble_acr_created
until: nimble_acr_created | success

- name: Discover Targets
command: ncmadm -e {{ nimble_group_discovery_ip }}
register: nimble_discover_targets

- name: Get volume serial number
set_fact:
nimble_volume_serial_number: "{{ nimble_group_facts | json_query(local_query) }}"
vars:
local_query: "volumes[?name=='{{ nimble_volume }}'].serial_number | [0]"

- name: Create device string
set_fact:
nimble_volume_device_name: "/dev/nimblestorage/{{ nimble_volume }}-2{{ nimble_volume_serial_number }}"

- name: Wait for device to appear
wait_for:
path: "{{ nimble_volume_device_name }}"
timeout: "{{ nimble_device_delay }}"
53 changes: 15 additions & 38 deletions tasks/nimble_volume_mount.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
---
- name: Ensure nimble_volume and nimble_volume_mountpoint
fail: msg="Missing variable nimble_volume and nimble_volume_mountpoint, please provide a volume name in nimble_volume and current mountpoint in nimble_volume_mountpoint"
when: nimble_volume is undefined and nimble_volume_mountpoint is undefined
- name: Ensure play variables are sane
fail:
msg: "Missing variable {{ item }}"
when: vars[item] is undefined
with_items:
- nimble_volume
- nimble_volume_mountpoint

- name: Host facts
include: nimble_host_facts.yml
Expand All @@ -11,31 +15,7 @@
include: nimble_group_facts.yml
vars:
nimble_group_facts:
volumes: "fields=name,target_name,id,serial_number&name={{ nimble_volume }}"
subnets: "fields=allow_iscsi,discovery_ip"

- name: Discover Targets
command: ncmadm -e {{ nimble_group_discovery_ip }}
register: nimble_discover_targets
when: ansible_os_family == 'RedHat'

- name: Discover Targets
open_iscsi:
show_nodes: yes
discover: yes
portal: "{{ nimble_group_discovery_ip }}"
when: ansible_os_family == 'Debian'

- name: Discover LUN
open_iscsi:
auto_node_startup: True
discover: True
login: True
portal: "{{ nimble_group_discovery_ip }}"
target: "{{ nimble_group_facts | json_query(local_query) }}"
vars:
local_query: "volumes[?name=='{{ nimble_volume }}'].target_name | [0]"
when: ansible_os_family == 'Debian'
volumes: "fields=name,id,serial_number&name={{ nimble_volume }}"

- name: Get volume serial number
set_fact:
Expand All @@ -45,18 +25,15 @@

- name: Create device string
set_fact:
nimble_volume_device_name: "{{ nimble_host_device_prefix }}/{{ nimble_volume }}-2{{ nimble_volume_serial_number }}"
when: ansible_os_family == 'RedHat'

- name: Create device string
set_fact:
nimble_volume_device_name: "/dev/disk/by-id/dm-uuid-mpath-2{{ nimble_volume_serial_number }}"
when: ansible_os_family == 'Debian'
nimble_volume_device_name: "/dev/nimblestorage/{{ nimble_volume }}-2{{ nimble_volume_serial_number }}"

- name: Wait for device to appear
wait_for:
- name: Ensure device
stat:
path: "{{ nimble_volume_device_name }}"
timeout: "{{ nimble_device_delay }}"
register: nimble_volume_device_info
- fail:
msg: "{{ nimble_volume_device_name }} does not exist."
when: nimble_volume_device_info.stat.exists == False

- name: Create filesystem label
include: util_volume_label.yml
Expand Down
67 changes: 6 additions & 61 deletions tasks/nimble_volume_umount.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,12 @@
---
- name: Ensure nimble_volume and nimble_volume_mountpoint
fail: msg="Missing variable nimble_volume and nimble_volume_mountpoint, please provide a volume name in nimble_volume and current mountpoint in nimble_volume_mountpoint"
when: nimble_volume is undefined and nimble_volume_mountpoint is undefined

- name: Host facts
include: nimble_host_facts.yml
when: nimble_host_facts is undefined

- name: Refresh group facts
include: nimble_group_facts.yml
vars:
nimble_group_facts:
volumes: "fields=name,id,serial_number,target_name&name={{ nimble_volume }}"

- name: Determine serial_number
set_fact:
nimble_volume_serial_number: "{{ nimble_group_facts | json_query(local_query) }}"
vars:
local_query: "volumes[?name=='{{ nimble_volume }}'].serial_number | [0]"

- name: Determine target
set_fact:
nimble_volume_target: "{{ nimble_group_facts | json_query(local_query) }}"
vars:
local_query: "volumes[?name=='{{ nimble_volume }}'].target_name | [0]"
when: ansible_os_family == 'Debian'
- name: Ensure play variables are sane
fail:
msg: "Missing variable {{ item }}"
when: vars[item] is undefined
with_items:
- nimble_volume_mountpoint

- name: Wipe fstab
mount:
name: "{{ nimble_volume_mountpoint }}"
state: absent

- block:
- name: Create device string
set_fact:
nimble_volume_device_name: "{{ nimble_host_device_prefix }}/{{ nimble_volume }}-2{{ nimble_volume_serial_number }}"

- name: Dismantle dm/iSCSI stack
command: ncmadm --remove {{ nimble_volume_device_name }}
when: ansible_os_family == 'RedHat'

- block:
- name: Create device string
set_fact:
nimble_volume_device_name: "/dev/disk/by-id/dm-uuid-mpath-2{{ nimble_volume_serial_number }}"

- name: Disconnect LUN
open_iscsi:
login: no
target: "{{ nimble_volume_target }}"

- name: Reload multipath
command: multipath -r
when: ansible_os_family == 'Debian'

- name: Wait for device to disappear
wait_for:
path: "{{ nimble_volume_device_name }}"
state: absent
timeout: "{{ nimble_device_delay }}"
register: nimble_volume_device_removal
ignore_errors: True

- name: Force dismantling of dm/iSCSI stack
command: ncmadm --force --remove {{ nimble_volume_device_name }}
when: nimble_volume_device_removal|failed
60 changes: 56 additions & 4 deletions tasks/nimble_volume_unmap.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,67 @@
---
- name: Ensure nimble_volume
fail: msg="Missing variable nimble_volume, please provide a volume name in nimble_volume"
when: nimble_volume is undefined
- name: Ensure play variables are sane
fail:
msg: "Missing variable {{ item }}"
when: vars[item] is undefined
with_items:
- nimble_volume

- name: Host facts
include: nimble_host_facts.yml
when: nimble_host_facts is undefined and nimble_initiator_options is undefined

- name: Refresh group facts
include: nimble_group_facts.yml
vars:
nimble_group_facts:
access_control_records: "fields=vol_name,initiator_group_name,id&vol_name={{ nimble_volume }}"
volumes: "fields=name,id&name={{ nimble_volume }}"
volumes: "fields=name,id,serial_number,target_name&name={{ nimble_volume }}"
initiator_groups: "fields=id&name={{ inventory_hostname_short }}"

- name: Determine serial_number
set_fact:
nimble_volume_serial_number: "{{ nimble_group_facts | json_query(local_query) }}"
vars:
local_query: "volumes[?name=='{{ nimble_volume }}'].serial_number | [0]"

- name: Create device string
set_fact:
nimble_volume_device_name: "/dev/nimblestorage/{{ nimble_volume }}-2{{ nimble_volume_serial_number }}"

- name: Dismantling data path
command: ncmadm --remove {{ nimble_volume_device_name }}
register: nimble_volume_removed
until: nimble_volume_removed.stdout.find('Done') != -1
retries: "{{ nimble_device_retries }}"
delay: "{{ nimble_device_delay }}"

- name: Dismantling data path (forcefully)
command: ncmadm --remove --force {{ nimble_volume_device_name }}
args:
removes: "{{ nimble_volume_device_name }}"

- name: Wait for device to disappear
wait_for:
path: "{{ nimble_volume_device_name }}"
state: absent
timeout: "{{ nimble_device_delay }}"

- name: Monitor volume connections
set_fact:
nimble_volume_id: "{{ nimble_group_facts.volumes[0].id }}"
- uri:
url: "{{ nimble_group_url }}/volumes/{{ nimble_volume_id }}"
validate_certs: no
method: GET
status_code: 200
headers:
X-Auth-Token: "{{ nimble_group_token }}"
retries: "{{ nimble_device_retries }}"
delay: "{{ nimble_device_delay }}"
register: nimble_volume_disconnected
when: nimble_volume_unmap_volume_connections == True
until: nimble_volume_disconnected.json.data.num_connections == 0

- name: Determine ACR ID
set_fact:
nimble_volume_acr: "{{ nimble_group_facts | json_query(local_query) }}"
Expand Down