Skip to content
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

win_iis_website and win_iis_webbinding - Migrate from community #11

Conversation

shahargolshani
Copy link
Contributor

SUMMARY
  • Promote the win_iis_website module from community.windows to microsoft.iis
  • Promote the win_iis_webbinding module from community.windows to microsoft.iis
  • Consolidate win_iis_website and win_iis_webbinding modules into microsoft.iis.website
ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME
  • plugins/modules/website.ps1
  • plugins/modules/website.yml
  • plugins/modules/website_info.ps1
  • plugins/modules/website_info.yml
  • tests/integration/targets/website/aliases
  • tests/integration/targets/website/defaults/main.yml
  • tests/integration/targets/website/meta/main.yml
  • tests/integration/targets/website/tasks/bindings.yml
  • tests/integration/targets/website/tasks/main.yml
  • tests/integration/targets/website/tasks/tests.yml
  • tests/integration/targets/website_info/aliases
  • tests/integration/targets/website_info/defaults/main.yml
  • tests/integration/targets/website_info/meta/main.yml
  • tests/integration/targets/website_info/tasks/main.yml
  • tests/integration/targets/website_info/tasks/tests.yml
ADDITIONAL INFORMATION
  • Create website (set) module.
  • Create website_info (get) module.
  • New integration tests for module microsoft.iis.website
  • New integration tests for module microsoft.iis.website_info
  • Updating Documentation files to yml format.

jborean93 and others added 10 commits March 6, 2020 07:14
* Fix up docs after migration

* Fix up sanity errors
* fix up sanity ignores

* Bump ansible-windows dep

* Fix bad change for win_region
* Add Extra Information for IIS parameters.

hen configuring a website with custom site parameters, for people who are not familiar with PowerShell or IIS, it would be great to add in the documentation some examples to show them how to use these parameters.

* Slight tweaks to the docs

Co-authored-by: Emir Madrueno Peregrina <[email protected]>
* Rebalance the test targets

* Make sure IIS test removes the service so our httptester works
Copy link

@shahargolshani shahargolshani force-pushed the feature/migrate-win_iis_website branch from 3e5ab09 to 0a70f48 Compare January 1, 2025 13:20
Copy link

@shahargolshani shahargolshani force-pushed the feature/migrate-win_iis_website branch from 0a70f48 to 7179b56 Compare January 1, 2025 14:10
Copy link

@shahargolshani shahargolshani force-pushed the feature/migrate-win_iis_website branch from 7179b56 to d96bd0e Compare January 1, 2025 14:28
Copy link

@shahargolshani shahargolshani force-pushed the feature/migrate-win_iis_website branch from d96bd0e to 965182d Compare January 1, 2025 14:51
Copy link

@shahargolshani shahargolshani force-pushed the feature/migrate-win_iis_website branch from 965182d to 270beb4 Compare January 1, 2025 15:05
Copy link

@shahargolshani shahargolshani force-pushed the feature/migrate-win_iis_website branch from 270beb4 to ae67968 Compare January 1, 2025 15:25
Copy link

@shahargolshani shahargolshani force-pushed the feature/migrate-win_iis_website branch from ae67968 to 7a0c42a Compare January 7, 2025 15:21
Copy link

Copy link
Collaborator

@jborean93 jborean93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty large PR. I think we should try and slim it down a bit so we aren't holding up the other PRs.

Let's just focus on getting the bare minimum here of the website and website_info module without the parameters or bindings option implemented. We can focus completely on the simpler options and slowly add back in the other features in a subsequent PR where we can focus more on the UX and what they would look like.

port = @{ type = 'int' }
hostname = @{ type = 'str' }
protocol = @{ type = 'str' ; default = 'http' ; choices = @('http', 'https') }
ssl_flags = @{ type = 'str' ; default = '0' ; choices = @('0', '1', '2', '3') }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these flags representing some more human friendly value. It's hard to tell what each number means without having to look it up.

Comment on lines +75 to +82
# Custom site Parameters from string where properties are separated by a pipe and property name/values by colon.
# Ex. "foo:1|bar:2"
$parameters = $module.Params.parameters
if ($null -ne $parameters) {
$parameters = @($parameters -split '\|' | ForEach-Object {
return , ($_ -split "\:", 2)
})
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove this format entirely, it was written at a time when modules didn't accept a dictionary. Instead we should do something similar to web_app_pool's attributes option which accepts a dictionary value. We probably need to talk a bit more about trying to align this behavour so the option name stays the same and see if we can try and share the code for getting/setting/comparing the values in a module util.

$module.Result.changed = $false

if ($check_mode) {
Write-Output "in check mode"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause warnings and potentially errors as the output will be returned back to ansible which expects just a json string.

# Add site
If (($state -ne 'absent') -and (-not $site)) {
If (-not $physical_path) {
$module.FailJson("missing required arguments: physical_path $($_.Exception.Message)")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no exception here so this can become:

Suggested change
$module.FailJson("missing required arguments: physical_path $($_.Exception.Message)")
$module.FailJson("missing required arguments: physical_path")

$module.FailJson("missing required arguments: physical_path $($_.Exception.Message)")
}
ElseIf (-not (Test-Path -LiteralPath $physical_path)) {
$module.FailJson("specified folder must already exist: physical_path $($_.Exception.Message)")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here

Suggested change
$module.FailJson("specified folder must already exist: physical_path $($_.Exception.Message)")
$module.FailJson("specified folder must already exist: physical_path")

# Change Physical Path if needed
if ($physical_path) {
If (-not (Test-Path -LiteralPath $physical_path)) {
$module.FailJson("specified folder must already exist: physical_path $($_.Exception.Message)")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$module.FailJson("specified folder must already exist: physical_path $($_.Exception.Message)")
$module.FailJson("specified folder must already exist: physical_path")

Comment on lines +169 to +171
$user_bindings = if ($Module.Params.bindings.add) { $Module.Params.bindings.add }
elseif ($Module.Params.bindings.remove) { $Module.Params.bindings.remove }
elseif ($Module.Params.bindings.set) { $Module.Params.bindings.set }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic doesn't sound right to me. It seems like you want to check if set is present and use if, otherwise you need to check both add and remove together to add and remove accordingly.

$module.FailJson("SSLFlags can only be set for https protocol")
}
# Validate certificate details if provided
If ($_.certificate_hash -and $_.operation -ne 'remove') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think $_.operation is defined here.

# Validate certificate details if provided
If ($_.certificate_hash -and $_.operation -ne 'remove') {
If ($_.protocol -ne 'https') {
$module.FailJson("You can only provide a certificate thumbprint when protocol is set to https")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$module.FailJson("You can only provide a certificate thumbprint when protocol is set to https")
$module.FailJson("You can only provide a certificate thumbprint when protocol is set to https")

}
}
Catch {
$module.FailJson("$($module.Result) - $($_.Exception.Message)")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$module.FailJson("$($module.Result) - $($_.Exception.Message)")
$module.FailJson("$($module.Result) - $($_.Exception.Message)", $_)

@jborean93
Copy link
Collaborator

Closing as we migrated just the website in #15 and will be doing the binding work in a separate PR.

@jborean93 jborean93 closed this Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants