Skip to content

Commit 6633e54

Browse files
authored
Merge pull request #407 from DarkArc-Github/fix_binding_reapply
Fix: Unordered IIS Site Binding Comparison to Prevent Unnecessary Resource Updates
2 parents d79d4ea + d6db4d0 commit 6633e54

File tree

4 files changed

+85
-27
lines changed

4 files changed

+85
-27
lines changed

REFERENCE.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,56 @@ The sslflags parameter accepts integer values from 0 to 3 inclusive.
673673
the centralized SSL certificate store while requiring Server Name
674674
Indicator
675675

676+
For non-web protocols, the bindinginformation format varies by protocol:
677+
678+
**net.pipe protocol:**
679+
- Format: `hostname` (hostname only, no port or colons)
680+
- Example: `'bindinginformation' => 'hostname'`
681+
682+
**net.tcp protocol:**
683+
- Format: `port:hostname` (port number required, followed by colon and hostname)
684+
- Example: `'bindinginformation' => '808:hostname'`
685+
686+
**net.msmq protocol:**
687+
- Format: `hostname` (hostname only, no port or colons)
688+
- Example: `'bindinginformation' => 'hostname'`
689+
690+
**msmq.formatname protocol:**
691+
- Format: `hostname` (hostname only, no port or colons)
692+
- Example: `'bindinginformation' => 'hostname'`
693+
694+
**Note:** SSL-related parameters (sslflags, certificatehash, certificatestorename)
695+
are only valid for HTTPS protocol bindings and will cause validation errors
696+
if used with other protocols.
697+
Example with multiple protocols:
698+
```puppet
699+
bindings => [
700+
{
701+
'bindinginformation' => '*:80:',
702+
'protocol' => 'http',
703+
},
704+
{
705+
'bindinginformation' => '*:443:hostname',
706+
'certificatehash' => 'ABCDEF1234567890ABCDEF1234567890ABCDEF12',
707+
'certificatestorename' => 'MY',
708+
'protocol' => 'https',
709+
'sslflags' => 1,
710+
},
711+
{
712+
'bindinginformation' => 'hostname',
713+
'protocol' => 'net.pipe',
714+
},
715+
{
716+
'bindinginformation' => '808:hostname',
717+
'protocol' => 'net.tcp',
718+
},
719+
{
720+
'bindinginformation' => 'hostname',
721+
'protocol' => 'net.msmq',
722+
},
723+
]
724+
```
725+
676726
##### `defaultpage`
677727

678728
Specifies the default page of the site.
@@ -846,4 +896,3 @@ The name of the virtual directory to manage
846896

847897
The specific backend to use for this `iis_virtual_directory` resource. You will seldom need to specify this --- Puppet
848898
will usually discover the appropriate provider for your platform.
849-

lib/puppet/type/iis_site.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
require_relative '../../puppet_x/puppetlabs/iis/property/hash'
66
require_relative '../../puppet_x/puppetlabs/iis/property/path'
77
require_relative '../../puppet_x/puppetlabs/iis/property/authenticationinfo'
8-
require_relative '../../puppet_x/puppetlabs/iis/bindings'
98

109
Puppet::Type.newtype(:iis_site) do
1110
@doc = "Allows creation of a new IIS Web Site and configuration of site
@@ -156,17 +155,8 @@ def insync?(is)
156155
value
157156
end
158157

159-
def should
160-
PuppetX::PuppetLabs::IIS::Bindings.sort_bindings(super)
161-
end
162-
163-
def should=(values)
164-
super
165-
@should = PuppetX::PuppetLabs::IIS::Bindings.sort_bindings(@should)
166-
end
167-
168158
def insync?(is)
169-
PuppetX::PuppetLabs::IIS::Bindings.sort_bindings(is) == should
159+
(is || []).to_set == (should || []).to_set
170160
end
171161
end
172162

lib/puppet_x/puppetlabs/iis/bindings.rb

Lines changed: 0 additions & 15 deletions
This file was deleted.

spec/unit/puppet/type/iis_site_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,40 @@
137137
'bindinginformation' => '*:80:'
138138
}
139139
end
140+
141+
context 'order independent comparison' do
142+
let(:bindings_property) { resource.property(:bindings) }
143+
144+
before(:each) do
145+
resource[:bindings] = [
146+
{ 'protocol' => 'http', 'bindinginformation' => '*:80:' },
147+
{ 'protocol' => 'net.msmq', 'bindinginformation' => 'hostname' },
148+
]
149+
end
150+
151+
it 'considers same bindings in different order as in sync' do
152+
current_bindings = [
153+
{ 'protocol' => 'net.msmq', 'bindinginformation' => 'hostname' },
154+
{ 'protocol' => 'http', 'bindinginformation' => '*:80:' },
155+
]
156+
expect(bindings_property.insync?(current_bindings)).to be true
157+
end
158+
159+
it 'considers different bindings as out of sync' do
160+
current_bindings = [
161+
{ 'protocol' => 'net.msmq', 'bindinginformation' => 'hostname' },
162+
{ 'protocol' => 'http', 'bindinginformation' => '*:8080:' },
163+
]
164+
expect(bindings_property.insync?(current_bindings)).to be false
165+
end
166+
167+
it 'considers different number of bindings as out of sync' do
168+
current_bindings = [
169+
{ 'protocol' => 'http', 'bindinginformation' => '*:80:' },
170+
]
171+
expect(bindings_property.insync?(current_bindings)).to be false
172+
end
173+
end
140174
end
141175

142176
context 'property :limits' do

0 commit comments

Comments
 (0)