Skip to content

Commit

Permalink
feat: write storage role fingerprint to /etc/fstab
Browse files Browse the repository at this point in the history
Feature: Write storage role fingerprint to /etc/fstab

Reason: This will allow us to track usage of the storage role
on managed nodes.

Result: Storage role usage on managed nodes can be tracked.

Signed-off-by: Rich Megginson <[email protected]>
  • Loading branch information
richm committed Jul 23, 2024
1 parent 06844b5 commit d2dadb6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tasks/main-blivet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@
- storage_udevadm_trigger | d(false)
- blivet_output is changed

- name: Check if /etc/fstab is present
stat:
path: /etc/fstab
register: __storage_fstab

- name: Add fingerprint to /etc/fstab if present
lineinfile:
insertbefore: "^#"
firstmatch: true
line: "{{ __str }}"
regexp: "{{ __str }}"
path: /etc/fstab
state: present
vars:
__str: "# system_role:storage"
when:
- __storage_fstab.stat.exists
- blivet_output is changed
rescue:
- name: Failed message
fail:
Expand Down
6 changes: 6 additions & 0 deletions tests/test-verify-volume-fstab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
- "'mount_options' in storage_test_volume"
- "'mount_point' in storage_test_volume"

- name: Verify fingerprint
assert:
that: __fingerprint in storage_test_fstab.stdout
vars:
__fingerprint: "system_role:storage"

- name: Clean up variables
set_fact:
storage_test_fstab_id_matches: null
Expand Down

0 comments on commit d2dadb6

Please sign in to comment.