-
Notifications
You must be signed in to change notification settings - Fork 29
test: ensure role gathers the facts it uses by having test clear_facts before include_role #404
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| --- | ||
| # DO NOT EDIT THIS FILE - managed by linux-system-roles/.github | ||
| # Task file: clear_facts, run linux-system-roles.mssql. | ||
| # Include this with include_tasks or import_tasks | ||
| # Input: | ||
| # - __sr_tasks_from: tasks_from to run - same as tasks_from in include_role | ||
| # - __sr_public: export private vars from role - same as public in include_role | ||
| # - __sr_failed_when: set to false to ignore role errors - same as failed_when in include_role | ||
| - name: Clear facts | ||
| meta: clear_facts | ||
|
|
||
| # note that you can use failed_when with import_role but not with include_role | ||
| # so this simulates the __sr_failed_when false case | ||
| # Q: Why do we need a separate task to run the role normally? Why not just | ||
| # run the role in the block and rethrow the error in the rescue block? | ||
| # A: Because you cannot rethrow the error in exactly the same way as the role does. | ||
| # It might be possible to exactly reconstruct ansible_failed_result but it's not worth the effort. | ||
| - name: Run the role with __sr_failed_when false | ||
| when: | ||
| - __sr_failed_when is defined | ||
| - not __sr_failed_when | ||
| block: | ||
| - name: Run the role | ||
| include_role: | ||
| name: linux-system-roles.mssql | ||
| tasks_from: "{{ __sr_tasks_from | default('main') }}" | ||
| public: "{{ __sr_public | default(false) }}" | ||
| rescue: | ||
| - name: Ignore the failure when __sr_failed_when is false | ||
| debug: | ||
| msg: Ignoring failure when __sr_failed_when is false | ||
|
|
||
| - name: Run the role normally | ||
| include_role: | ||
| name: linux-system-roles.mssql | ||
| tasks_from: "{{ __sr_tasks_from | default('main') }}" | ||
| public: "{{ __sr_public | default(false) }}" | ||
| when: __sr_failed_when | d(true) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.