-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix: ensure role is idempotent and supports check mode #41
Conversation
[citest] |
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.
Massive work, Rich!
|
||
- name: Print out response | ||
debug: | ||
var: snapshot_cmd.stdout | ||
var: snapshot_cmd_raw |
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.
var: snapshot_cmd_raw | |
var: snapshot_cmd_raw.stdout |
Should it print only stdout as it was before?
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.
No - would prefer to see all of the fields rather than just stdout
|
||
- name: Assert no changes for umount | ||
assert: | ||
that: not snapshot_cmd["changed"] |
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.
Cool way to test idempotency!
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 do this in a few roles - have the module (or script in this case) return "changed"
as a variable that can be used elsewhere - unfortunately Ansible doesn't expose the internal "changed" counter or state
snapshot_cmd.stderr_lines is search(__snapshot_failed_regex) | ||
- snapshot_cmd_raw is failed | ||
- snapshot_cmd["return_code"] != 0 | ||
- snapshot_cmd["errors"] is search(__snapshot_failed_regex) | ||
msg: "{{ __snapshot_failed_msg }}" |
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.
msg: "{{ __snapshot_failed_msg }}" | |
var: __snapshot_failed_msg |
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.
Looks like var
is not a valid parameter for assert
_VALID_ARGS = frozenset(('fail_msg', 'msg', 'quiet', 'success_msg', 'that'))
msg
is an alias for fail_msg
Cause: Role was not idempotent, and did not support check mode. Consequence: Users could not use role to ensure idempotence or check state. Fix: The role has been fixed to return `"changed": true` if the role changed the state of the system, and `false` otherwise. This means that some operations that used to return an error, such as trying to snapshot a volume that already had a snapshot, or trying to remove a snapshot that does not exist, will no longer return an error, but will instead just report `"changed": false`. Users should use the `list` operation to examine state of the system. Result: The role is idempotent and supports check mode. Signed-off-by: Rich Megginson <[email protected]>
Cause: Role was not idempotent, and did not support check mode.
Consequence: Users could not use role to ensure idempotence or
check state.
Fix: The role has been fixed to return
"changed": true
if therole changed the state of the system, and
false
otherwise. Thismeans that some operations that used to return an error, such as
trying to snapshot a volume that already had a snapshot, or trying
to remove a snapshot that does not exist, will no longer return
an error, but will instead just report
"changed": false
. Usersshould use the
list
operation to examine state of the system.Result: The role is idempotent and supports check mode.
Signed-off-by: Rich Megginson [email protected]