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
Added module win_pester and relatives integration tests #37343
Conversation
If (Get-Module -Name $Module -ListAvailable -ErrorAction SilentlyContinue) { | ||
Import-Module $Module | ||
} else { | ||
Fail-Json -obj $result -message "Cannot find module: $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.
Just a little thing, but it would be nice to prompt the user to check if pester is installed and suggest they install it via win_psmodule or win_chocolatey as appropriate.
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.
What's the best way to prompt informations to users ?
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.
Sorry I could have been clearer. I just mean it would be nice to add more information to the -message string to suggest to the user how they could fix the problem where the pester module cannot be loaded by Get-Module. Something like
Fail-Json -obj $result -message "Cannot find module: $Module. Check if pester is installed, and if it is not, install using win_psmodule or win_chocolatey."
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.
Thanks @jhawkesworth I've modified the code with your recommendations .
- name: Get facts | ||
setup: | ||
|
||
- name: Add Pester 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.
I would consider adding these steps to the examples so users can know how to ensure they have pre-requisites for running the 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.
Sure thing !
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.
Done !
I think this would be a nice module to have. I see that the module documentation isn't passing the sanity checks currently. A quick way to check that the module documentation at least parses is to run 'ansible-doc win_pester'. You can of course run the same sanity tests like this from root of ansible source code. test/runner/ansible-test sanity --test validate-modules win_pester Hope this helps and that we can eventually get this module included into Ansible By the way, do you have any links you would recommend for getting started with pester - its not something I have made any use of? |
Hello @jhawkesworth, Thanks for the feedback ! I'll try to implement your comments as soon as possible. You'll find a lot of documentations about Pester directly on the Pester GitHub wiki. I'm quiet sure you'll find something useful ;-) |
I think we can remove the [WIP] in the title ;-) |
} | ||
|
||
# Run Pester tests | ||
If (Test-Path -Path $path -PathType Leaf) { |
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.
So I would be expecting -LiteralPath
everywhere unless this is not needed.
@jborean93 You have a good perspective on this.
Thanks for your help @dagwieers. I'm learning a lot ;-) |
- Run Pester tests on Windows hosts. | ||
- Test files have to be available on the remote host. | ||
requirements: | ||
- The Pester module should be present on the remote 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.
You only need to list the component name (and optionally minimum version). The documentation will generate the supporting text.
@LiranNis @SamLiu79 @timothyvandenbrande @andrewsaraceni @ar7z1 @blakfeld @brianlloyd @chrishoffman @daBONDi @elventear @henrikwallstrom @if-meaton @joshludwig @marqelme @nwchandler @nwsparks @petemounce @ptemplier @rndmh3ro @schwartzmx @smadam813 @themiwi @tksarah As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add |
Looks good to me shipit |
bot_status |
Componentslib/ansible/modules/windows/win_pester.ps1 lib/ansible/modules/windows/win_pester.py test/integration/targets/win_pester/aliases test/integration/targets/win_pester/defaults/main.yml test/integration/targets/win_pester/files/test01.test.ps1 test/integration/targets/win_pester/files/test02.test.ps1 test/integration/targets/win_pester/tasks/main.yml Metadatawaiting_on: maintainer |
bot doesn't automerge new modules apparently. |
* Added module win_pester and relatives integration tests * Corrected issues as stated by ansible-test * Added defaults variable in integration tests * Added task to install Pester if needed in the integration test * Corrected error in win_psmodule task * Added Pester installation with Chocolatey when Powershell version < 5 * Get facts... * Disabled invoke-pester output * Added pester_result type * Added jhawkesworth changes proposal * Corrected documentation linting * Corrected linting * Added dagwieers recommendations * Added dagwieers recommendations * Corrected linting errors and task error in integration test * Corrected error in integration test * Added dagwieers recommendations * Corrected requirements in the DOCUMENTATION block
SUMMARY
Run Pester tests with Ansible on Windows hosts.
You may integrate this module in your Ansible workflow to check if the configuration of your Windows host is correct after running your playbook.
ISSUE TYPE
COMPONENT NAME
win_pester
ANSIBLE VERSION
ADDITIONAL INFORMATION
Options
Examples
Return Values
Playbook
This playbook will copy the Pester tests files on the remote hosts, run the tests and verified if a test failed. The tests files are deleted at the end.