-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing parameters #59
Missing parameters #59
Conversation
I see there are CI failures. I'll take a look on Monday. |
I only looked over it briefly, but from what I gathered everyone there is in agreement that we should not change settings for existing volumes because of omitted parameters. |
981ada0
to
fbb0a9e
Compare
I just rebased this and added the commit allowing lookup of an existing pool by name only. I ran one random integration test and it passed, so I'm waiting to see what CI turns up. |
To Do:
|
5b36c13
to
8c2beba
Compare
tests/run_blivet.yml
Outdated
@@ -1,6 +1,6 @@ | |||
--- | |||
- include_vars: | |||
name: roles/storage/defaults/main.yml | |||
file: roles/storage/defaults/main.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use file: "{{ playbook_dir }}/roles/linux-system-roles.storage/defaults/main.yml"
tests/tests_existing_lvm_pool.yml
Outdated
|
||
tasks: | ||
- include_role: | ||
name: storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use name: linux-system-roles.storage
tests/tests_existing_lvm_pool.yml
Outdated
|
||
- name: Create one LVM logical volume under one volume group | ||
include_role: | ||
name: storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use name: linux-system-roles.storage
tests/tests_existing_lvm_pool.yml
Outdated
|
||
- name: Create another volume in the existing pool, identified only by name. | ||
include_role: | ||
name: storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use name: linux-system-roles.storage
tests/tests_existing_lvm_pool.yml
Outdated
|
||
- name: Clean up. | ||
include_role: | ||
name: storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use name: linux-system-roles.storage
tests/tests_luks_pool.yml
Outdated
@@ -109,10 +110,11 @@ | |||
|
|||
- include_tasks: verify-role-results.yml | |||
|
|||
- name: Add encryption to the volume | |||
- name: Add both encryption and raid to the pool | |||
include_role: | |||
name: storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use name: linux-system-roles.storage
tests/tests_luks_pool.yml
Outdated
@@ -133,6 +136,7 @@ | |||
include_role: | |||
name: storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use name: linux-system-roles.storage
c76c635
to
51edee7
Compare
This pull request introduces 1 alert when merging 51edee7 into e990c1f - view on LGTM.com new alerts:
|
meta/main.yml
Outdated
@@ -7,6 +7,6 @@ galaxy_info: | |||
min_ansible_version: 2.5 | |||
platforms: | |||
- name: Fedora | |||
versions: [ 31, 32 ] | |||
versions: [ 31, 32, 33 ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jharuda can this be now changed to just versions: all
?
[citest] |
f221605
to
83681c7
Compare
Note to self, since I'm taking Friday off: There are two persistent CI failures that I have been unable to reproduce locally, both of which appear to be triggered by the CI infrastructure's slowness:
I can investigate blivet mitigation for failure 1, but I'll have to figure out how to examine the blivet log from the actual ci run in order to diagnose failure 2. |
[citest] |
642a053
to
15d8387
Compare
For new/non-existent pools and volumes, any missing parameters will be filled with the role default. For existing pools and volumes, missing parameters will be filled in with the current setting for that pool or volume in the system.
10af084
to
560a8b8
Compare
Are there changes which will break the API e.g. if a customer has playbooks that work with the existing role, will those playbooks continue to work the exact same way if they update the role? |
tasks/main-blivet.yml
Outdated
safe_mode: "{{ storage_safe_mode }}" | ||
diskvolume_mkfs_option_map: "{{ __storage_blivet_diskvolume_mkfs_option_map|d(omit) }}" | ||
register: blivet_output | ||
- command: 'systemctl list-units --all --plain --full --no-legend -t service' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use service_facts
instead? https://docs.ansible.com/ansible/2.9/modules/service_facts_module.html#service-facts-module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to use service_facts
in latest version. Bonus fun ensued related to json_query
.
diskvolume_mkfs_option_map: "{{ __storage_blivet_diskvolume_mkfs_option_map|d(omit) }}" | ||
register: blivet_output | ||
rescue: | ||
- fail: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to check the result of the failure in tests, you'll have to "re-raise" the error - see https://richm.github.io/how-to-catch-and-reraise-errors-in-ansible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in latest version, although tests were passing as it was.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in latest version, although tests were passing as it was.
Then you probably aren't trying to rescue
and check the error in a calling context.
No, the behavior will change when they run the role against pre-existing pools or volumes with any parameters omitted. It seems clear that the new behavior is "better" (don't change anything unless explicitly told to), but it's definitely different.
As I said above, the new behavior is less disruptive/destructive, but it's still different. |
Will a playbook run against the new role report any differences at all?
Will the playbook run report |
No, it should not report 'changed' in that case. |
Then IMO a major version change is not needed, only a minor version change. |
The systemd-cryptsetup@ services serve to prompt for a password when the encrypted/backing device appears, which is not desirable while blivet is configuring storage.
560a8b8
to
c899ef9
Compare
- set_fact: | ||
# For an explanation of the to_json|from_json silliness, see | ||
# https://github.com/ansible-collections/community.general/issues/320 | ||
storage_cryptsetup_services: "{{ ansible_facts.services|to_json|from_json|json_query('*.name')|json_query('[?starts_with(@, `\"systemd-cryptsetup@\"`)]') }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a way to do it without json_query:
storage_cryptsetup_services: "{{
ansible_facts.services | dict2items | selectattr('key', 'match', '^systemd-cryptsetup@') |
map(attribute='value') | map(attribute='name') | list
}}"
however, on fedora 33, this gives me a value like this: ['systemd-cryptsetup@luks\\x2d7fa23e85\\x2d4729\\x2d43b2\\x2dcc7a\\x2d9608d8cdb732.service']
not sure if that is the same result of using json_query
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone came in a while back and switched all of our selectattr
usage to json_query
since selectattr
doesn't work with Jinja versions < 2.8. You can see the comment, look at blame, etc. in storage/tests/test-verify-volume-mount.yml
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone came in a while back and switched all of our
selectattr
usage tojson_query
sinceselectattr
doesn't work with Jinja versions < 2.8. You can see the comment, look at blame, etc. instorage/tests/test-verify-volume-mount.yml
.
Mea culpa. That was based on my incomplete understanding of the problems of selectattr
and json_query
. The problem with jinja27 is not selectattr
in general, it is that certain filters are not available - specifically, the equalto
, equal
, ==
filters to test if a value in an object is equal to some given value.
We have just completed converting all of the system roles to work with jinja27, and we figured out how to get around this limitation, by using the match
filter instead of equalto
or ==
- linux-system-roles/logging@48d21ef#diff-fe77ca1acb10f971c92988a8aed5bb5ae631443b1a20668629ccc846c608205aL11-L12
In the case of this PR, we have to use match
anyway to look for services beginning with systemd-cryptsetup@
.
In addition, I have verified the code above works with ansible 2.8/jinja2.7/centos7 controller host.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have CI tests for ansible 2.8/jinja2.7/centos7 controller host - the statuses like */ansible-2.8
- so you can know if you make a change that breaks in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, all of that being said, if you prefer to keep the json_query
implementation, that's fine with me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with it as it is now if you are. No need to fiddle with it any more.
[citest bad] |
Don't worry about the |
The
rhel-x uses the internal rhel 8.4.0 snapshot 1 - which is quite old by now - we are in the process of upgrading it - is it possible that this test uses a component that had a bug in this older snapshot, or the test uses a component in rhel 8.4 that is in a later version of 8.4? |
[citest bad] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
No, crypttab is still missing when testing against the latest nightly snapshot. |
This changes the behavior of the role such that omitted parameters do not change settings on existing pools and volumes. Omitted parameters on new pools and volumes will be given the default value, while the same on existing pools and volumes will leave whatever the current setting is intact.