Skip to content

Commit fa681df

Browse files
committed
oraasm_manage_diskgroups: Refactoring and bugfixes for 4.0
1 parent 8638355 commit fa681df

File tree

4 files changed

+45
-58
lines changed

4 files changed

+45
-58
lines changed

changelogs/fragments/diskgroup.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- "oraasm_manage_diskgroups: Refactoring and bugfixes for 4.0 ()"

roles/oraasm_manage_diskgroups/README.md

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ Do not set them in inventory!
1010
## Table of content
1111

1212
- [Requirements](#requirements)
13-
- [Default Variables](#default-variables)
14-
- [_oraasm_manage_diskgroups_asmdevice_list](#_oraasm_manage_diskgroups_asmdevice_list)
15-
- [_oraasm_manage_diskgroups_attr_name](#_oraasm_manage_diskgroups_attr_name)
16-
- [_oraasm_manage_diskgroups_attr_value](#_oraasm_manage_diskgroups_attr_value)
1713
- [Discovered Tags](#discovered-tags)
18-
- [Open Tasks](#open-tasks)
1914
- [Dependencies](#dependencies)
2015
- [License](#license)
2116
- [Author](#author)
@@ -27,39 +22,10 @@ Do not set them in inventory!
2722
- Minimum Ansible version: `2.9.0`
2823

2924

30-
## Default Variables
31-
32-
### _oraasm_manage_diskgroups_asmdevice_list
33-
34-
#### Default value
35-
36-
```YAML
37-
_oraasm_manage_diskgroups_asmdevice_list: internal use only
38-
```
39-
40-
### _oraasm_manage_diskgroups_attr_name
41-
42-
#### Default value
43-
44-
```YAML
45-
_oraasm_manage_diskgroups_attr_name: internal use only
46-
```
47-
48-
### _oraasm_manage_diskgroups_attr_value
49-
50-
#### Default value
51-
52-
```YAML
53-
_oraasm_manage_diskgroups_attr_value: internal use only
54-
```
55-
5625
## Discovered Tags
5726

5827
**_diskgroup_**
5928

60-
## Open Tasks
61-
62-
- (bug): missing loop_control
6329

6430
## Dependencies
6531

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
---
2-
# @todo bug: missing loop_control
3-
4-
- name: oraasm_manage_diskgroups | Manage diskgroups
2+
- name: Manage diskgroups
53
opitzconsulting.ansible_oracle.oracle_asmdg:
64
un: sys
75
pw: "{{ sysasmpassword }}"
86
sn: +ASM
97
host: "{{ oracle_hostname }}"
108
oh: "{{ oracle_home_gi }}"
11-
name: "{{ item.diskgroup }}"
9+
name: "{{ ad_loop.diskgroup }}"
1210
disks: "{{ _oraasm_manage_diskgroups_asmdevice_list }}"
13-
redundancy: "{{ item.redundancy | default(omit) }}"
11+
redundancy: "{{ ad_loop.properties | map(attribute='redundancy') | first | default(omit) }}"
1412
attribute_name: "{{ _oraasm_manage_diskgroups_attr_name | default(omit) }}"
1513
attribute_value: "{{ _oraasm_manage_diskgroups_attr_value | default(omit) }}"
16-
state: "{{ item.state }}"
14+
state: "{{ ad_loop.state }}"
1715
environment: "{{ _grid_env }}"
1816
run_once: "{{ _oraswgi_meta_configure_cluster }}"
17+
become: true
1918
become_user: "{{ _grid_install_user }}"
2019
with_items: "{{ asm_diskgroups }}"
20+
loop_control:
21+
loop_var: ad_loop
22+
label: >-
23+
diskgroup: {{ ad_loop.diskgroup | default('') }}
24+
redundancy: {{ ad_loop.properties | map(attribute='redundancy') | first | default('') }}
25+
state: {{ ad_loop.state | default('') }}
2126
tags: diskgroup
Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
11
---
2-
# @var _oraasm_manage_diskgroups_asmdevice_list: $ "internal use only"
3-
_oraasm_manage_diskgroups_asmdevice_list: "{% if device_persistence | lower == 'asmlib' %}\
4-
{%- for disk in item.disk -%}{{ oracle_asm_disk_prefix }}{{ disk.asmlabel | upper }}\
5-
{%- if not loop.last -%},{%- endif -%}\
6-
{%- endfor %}\
7-
{%- elif device_persistence | lower == 'asmfd' %}\
8-
{%- for disk in item.disk -%}AFD:{{ disk.asmlabel | upper }}\
9-
{%- if not loop.last -%},{%- endif -%}\
10-
{%- endfor %}\
11-
{%- elif device_persistence | lower == 'udev' %}\
12-
{%- for disk in item.disk -%}{{ oracle_asm_disk_prefix }}{{ disk.asmlabel }}\
13-
{%- if not loop.last -%},{%- endif -%}\
14-
{%- endfor %}\
15-
{%- endif %}"
2+
_oraasm_manage_diskgroups_asmdevice_list: |-
3+
{% if device_persistence == 'asmlib' %}
4+
{%- for disk in ad_loop.disk %}{{ _oracle_asm_disk_prefix }}{{ disk.asmlabel | upper }}
5+
{%- if not loop.last -%},{%- endif %}
6+
{%- endfor %}
7+
{%- elif device_persistence == 'asmfd' %}
8+
{%- for disk in ad_loop.disk -%}AFD:{{ disk.asmlabel | upper }}
9+
{%- if not loop.last -%},{%- endif -%}
10+
{%- endfor %}
11+
{%- elif device_persistence == 'udev' %}
12+
{%- for disk in ad_loop.disk -%}{{ _oracle_asm_disk_prefix }}{{ disk.asmlabel }}
13+
{%- if not loop.last -%},{%- endif -%}
14+
{%- endfor %}
15+
{%- endif %}
1616
17-
# @var _oraasm_manage_diskgroups_attr_name: $ "internal use only"
18-
_oraasm_manage_diskgroups_attr_name: "{% if item.attributes is defined %}{{ item.attributes | default(omit) | map(attribute='name') | list }}{% else %}None{% endif %}"
17+
_oraasm_manage_diskgroups_attr_name: |-
18+
{% if ad_loop.attributes is defined %}
19+
{{- ad_loop.attributes | default(omit) | map(attribute='name') | list }}
20+
{%- else %}None{% endif %}
1921
20-
# @var _oraasm_manage_diskgroups_attr_value: $ "internal use only"
21-
_oraasm_manage_diskgroups_attr_value: "{% if item.attributes is defined %}{{ item.attributes | default(omit) | map(attribute='value') | list }}{% else %}None{% endif %}"
22+
_oraasm_manage_diskgroups_attr_value: |-
23+
{% if ad_loop.attributes is defined %}
24+
{{- ad_loop.attributes | default(omit) | map(attribute='value') | list }}
25+
{%- else %}None{% endif %}
26+
27+
_oracle_asm_disk_prefix: |-
28+
{%- if device_persistence == 'asmlib' %}
29+
{%- if oracle_asm_disk_string.endswith('*') %}{{ oracle_asm_disk_string[:-1] }}
30+
{%- else %}{{ oracle_asm_disk_string }}
31+
{%- endif %}
32+
{%- elif device_persistence == 'udev' %}{{ oracle_asm_disk_string }}
33+
{%- else %}
34+
{%- endif %}

0 commit comments

Comments
 (0)