Skip to content

Commit

Permalink
Cleanup of deprecation warnings and spurious change notifications (#6)
Browse files Browse the repository at this point in the history
* Fixed 'bare variable' warnings.

* Disabled 'changed' status for several shell commands.  These commands either do not make changes or are not interesting unless they fail.

* Adding another space in front of the email address prevents the template function from periodically trying to remove an extra space.
  • Loading branch information
jsushetski authored and jacoelho committed Oct 13, 2016
1 parent d87b4a3 commit 31ed5c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
13 changes: 8 additions & 5 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,23 @@
shell: "mdadm -D {{ item.device }}"
ignore_errors: yes
register: mdadm_check
with_items: software_raid_devices
with_items: "{{ software_raid_devices }}"
when: software_raid_devices is defined
changed_when: false

- name: software raid - initialise raid devices
shell: mdadm -v --create {{ item.0.device }} --level={{ item.0.level }} --raid-devices={{ item.0.components | length }} {{ item.0.components | join(" ") }} {{ software_raid_create_kwargs }}
with_together:
- software_raid_devices
- mdadm_check.results
- "{{ software_raid_devices }}"
- "{{ mdadm_check.results }}"
when: software_raid_devices is defined and item.1.rc != 0

- name: software raid - scan raid devices
shell: "mdadm --detail --scan"
ignore_errors: yes
register: mdadm_scan
when: software_raid_devices is defined
changed_when: false

- name: software raid - create mdadm config file
template: src=mdadm.conf.j2 dest=/etc/mdadm/mdadm.conf
Expand All @@ -33,12 +35,13 @@
shell: "update-initramfs -u"
ignore_errors: yes
when: software_raid_devices is defined and ansible_os_family == "Debian"
changed_when: false

- name: software raid - filesystem creation
filesystem:
fstype: "{{ item.filesystem_type }}"
dev: "{{ item.device }}"
with_items: software_raid_devices
with_items: "{{ software_raid_devices }}"
when: software_raid_devices is defined and item.mount_point is defined

- name: software raid - mount raid devices
Expand All @@ -50,5 +53,5 @@
dump: "{{ item.dump }}"
passno: "{{ item.passno }}"
state: mounted
with_items: software_raid_devices
with_items: "{{ software_raid_devices }}"
when: software_raid_devices is defined and item.mount_point is defined
4 changes: 2 additions & 2 deletions tasks/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- item.device != ""
- item.level != ""
- item.components | length > 1
with_items: software_raid_devices
with_items: "{{ software_raid_devices }}"
when: software_raid_devices is defined


Expand All @@ -16,5 +16,5 @@
- item.mount_options != ""
- item.passno != ""
- item.dump != ""
with_items: software_raid_devices
with_items: "{{ software_raid_devices }}"
when: software_raid_devices is defined and item.mount_point is defined
2 changes: 1 addition & 1 deletion templates/mdadm.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CREATE owner=root group=disk mode=0660 auto=yes
HOMEHOST <system>

# instruct the monitoring daemon where to send mail alerts
MAILADDR {{ software_raid_alerts_email }}
MAILADDR {{ software_raid_alerts_email }}

# definitions of existing MD arrays
{{ mdadm_scan.stdout }}

0 comments on commit 31ed5c9

Please sign in to comment.