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

iis_config fails with certain commands #89

Closed
kb18951452 opened this issue Nov 14, 2014 · 17 comments
Closed

iis_config fails with certain commands #89

kb18951452 opened this issue Nov 14, 2014 · 17 comments

Comments

@kb18951452
Copy link

I'd love someone else to verify this:

iis_config "-section:system.webServer/handlers /[name=\'ExtensionlessUrlHandler-Integrated-4.0\'].verb:\"GET,HEAD,POST,DEBUG,PUT,DELETE\"  /commit:apphost" do
    action :config
end

getting this error

==> default: Ran 
C:\Windows\System32\inetsrv\appcmd.exe set config -section:system.webServer/handlers /[name='ExtensionlessUrlHandler-Integrated-4.0'].verb:"GET,HEAD,POST,DEBUG,PUT,DELETE"  /commit:apphost returned 4312

Running the command it says it ran works......

C:\Windows\System32\inetsrv\appcmd.exe set config -section:system.webServer/handlers /[name='ExtensionlessUrlHandler-Integrated-4.0'].verb:"GET,HEAD,POST,DEBUG,PUT,DELETE"  /commit:apphost
@EasyAsABC123
Copy link
Contributor

Just ran:

iis_config "-section:system.webServer/handlers /[name=\'ExtensionlessUrlHandler-Integrated-4.0\'].verb:\"GET,HEAD,POST,DEBUG,PUT,DELETE\" /commit:apphost" do
    action :config
end

this is the chef result:

[2014-12-22T12:36:18-05:00] INFO: Processing iis_config[-section:system.webServer/handlers /[name='ExtensionlessUrlHandler-Integrated-4.0'].verb:"GET,HEAD,POST,DEBUG,PUT,DELETE" /commit:apphost] action config (hps-atlas-web::default line 23)

@kbarry-x Can you give the following information:
chef version?
iis version?

Thanks

@kb18951452
Copy link
Author

chef-server 11.0.10

iis version is 8.5

@EasyAsABC123
Copy link
Contributor

Cool, i just tested that with the latest code on a vagrant Windows Server 2012 x64 without error.
Are you on the latest iis cookbook?

@webframp
Copy link

Saw something similar with this snippet in a recipe:

  iis_config "/section:staticContent /+\"[fileExtension='.gem',mimeType='application/octet-stream ']\"" do
    action :config
  end
---- Begin output of C:\Windows\System32\inetsrv\appcmd.exe set config /section:staticContent /+"[fileExtension='.gem',mimeType='application/octet-stream ']" ----
STDOUT: ERROR ( message:New mimeMap object missing required attributes. Cannot add duplicate collection entry of type 'mimeMap' with unique key attribute 'fileExtension' set to '.gem'. )
STDERR:
---- End output of C:\Windows\System32\inetsrv\appcmd.exe set config /section:staticContent /+"[fileExtension='.gem',mimeType='application/octet-stream ']" ----
Ran C:\Windows\System32\inetsrv\appcmd.exe set config /section:staticContent /+"[fileExtension='.gem',mimeType='application/octet-stream ']" returned 183

This worked the first time it ran. It could just be my ignorance with how appcmd work, but it seems like maybe the resource isn't really idempotent in some cases?

chef-client 11.16.2, iis version 7.5 and iis cookbook version 2.1.6

@kb18951452
Copy link
Author

In '/+"[fileExtension .... ' the "+" means "Add", exit 183 means "This
already exists, you can't add it again"

You can change the expected exit codes to include 183, as its not really a
bad exit, it simply means "I am already there".

On Wed, Jan 28, 2015 at 1:40 PM, Sean Escriva notifications@github.com
wrote:

Saw something similar with this snippet in a recipe:

iis_config "/section:staticContent /+"[fileExtension='.gem',mimeType='application/octet-stream ']"" do
action :config
end

---- Begin output of C:\Windows\System32\inetsrv\appcmd.exe set config /section:staticContent /+"[fileExtension='.gem',mimeType='application/octet-stream ']" ----
STDOUT: ERROR ( message:New mimeMap object missing required attributes. Cannot add duplicate collection entry of type 'mimeMap' with unique key attribute 'fileExtension' set to '.gem'. )
STDERR:
---- End output of C:\Windows\System32\inetsrv\appcmd.exe set config /section:staticContent /+"[fileExtension='.gem',mimeType='application/octet-stream ']" ----
Ran C:\Windows\System32\inetsrv\appcmd.exe set config /section:staticContent /+"[fileExtension='.gem',mimeType='application/octet-stream ']" returned 183

This worked the first time it ran. It could just be my ignorance with how
appcmd work, but it seems like maybe the resource isn't really idempotent
in some cases?

chef-client 11.16.2, iis version 7.5 and iis cookbook version 2.1.6


Reply to this email directly or view it on GitHub
#89 (comment)
.

Kenneth Barry
TuneIn | Build and Release Engineer
M: 409-673-0544
www.tunein.com

@EasyAsABC123
Copy link
Contributor

@webframp since you can run anything and everything via iis_config it can't really be idempotent...it is going to run everytime chef-client runs. With this specific example is there a reason you don't require the developers to code this into the web.config

require 'chef/mixin/shell_out'

include Chef::Mixin::ShellOut
include Opscode::IIS::Helper

action :config do
  cmd = "#{appcmd(node)} set config #{@new_resource.cfg_cmd}"
  Chef::Log.debug(cmd)
  shell_out!(cmd, :returns => @new_resource.returns)
  Chef::Log.info("IIS Config command run")
  @new_resource.updated_by_last_action(true)
end

this is all there is to the iis_config provider

@kbarry-x adding 183 doesn't look like a bad idea at all, let me think on it and see if I can find an issue.
one other solution would be make it accept any error (since it just runs anything given to it)...trying to make it idempotent is an impossible task I believe...

good find though

@kb18951452
Copy link
Author

I was not using the latest version of the cookbook. I am getting the latest version now. When I attempted to earlier, I ran into #95

I am updating, and testing now. Wish me luck.

@ksubrama
Copy link

The /+ config commands are currently not idempotent and I think there is some lingering issue in detecting them correctly. Let me know if the newest version works for you. If not, I'll keep an careful eye for this when doing a bug-fix pass.

@kb18951452
Copy link
Author

I'm still getting the erro, using the latest of both the windows and iis cookbooks.

I'm going to change

resources/config.rb

attribute :returns, :kind_of => [Integer, Array], :default => 0
to
attribute :returns, :kind_of => [Integer, Array], :default => [0,183]

@EasyAsABC123
Copy link
Contributor

@kbarry-x please test that and submit a pull request.

@kb18951452
Copy link
Author

183 is the "Its already there" code. And i believe it was a hack/fix in a
previous version employed by others. Lemme see if I can figure out a
pull-request ;)

On Tue, Mar 31, 2015 at 12:11 PM, Justin Schuhmann <notifications@github.com

wrote:

@kbarry-x https://github.com/kbarry-x please test that and submit a
pull request.


Reply to this email directly or view it on GitHub
#89 (comment)
.

Kenneth Barry
TuneIn | Build and Release Engineer
M: 409-673-0544
www.tunein.com

@EasyAsABC123
Copy link
Contributor

Actually this isn't a pull request, here is the solution...

add an attribute to your provider call

iis_config "-section:system.webServer/handlers /[name=\'ExtensionlessUrlHandler-Integrated-4.0\'].verb:\"GET,HEAD,POST,DEBUG,PUT,DELETE\"  /commit:apphost" do
    returns [0, 183]
end

A global change isn't a great idea here but this will definitely solve your use case.

@ksubrama mind validating that you agree changing this globally isn't the best idea?

@kb18951452
Copy link
Author

Awesome. Thanks very much. I wasnt aware of "returns" but I suspect its a
"common attribute"

On Tue, Mar 31, 2015 at 1:29 PM, Justin Schuhmann notifications@github.com
wrote:

Actually this isn't a pull request, here is the solution...

add an attribute to your provider call

iis_config "-section:system.webServer/handlers /[name='ExtensionlessUrlHandler-Integrated-4.0'].verb:"GET,HEAD,POST,DEBUG,PUT,DELETE" /commit:apphost" do
action :config
returns [0, 183]end

A global change isn't a great idea here but this will definitely solve
your use case.


Reply to this email directly or view it on GitHub
#89 (comment)
.

Kenneth Barry
TuneIn | Build and Release Engineer
M: 409-673-0544
www.tunein.com

@EasyAsABC123
Copy link
Contributor

@kbarry-x never a problem, this is definitely a permanent solution for you. We just need to decide if that's the permanent solution for everyone via default.

@kb18951452
Copy link
Author

How do we handle configs that are in the form of an "addition"?
On Tue, Mar 31, 2015 at 3:10 PM, Justin Schuhmann notifications@github.com
wrote:

@kbarry-x https://github.com/kbarry-x never a problem, this is
definitely a permanent solution for you. We just need to decide if that's
the permanent solution for everyone via default.


Reply to this email directly or view it on GitHub
#89 (comment)
.

Kenneth Barry
TuneIn | Build and Release Engineer
M: 409-673-0544
www.tunein.com

@EasyAsABC123
Copy link
Contributor

@kbarry-x can you provide an example?

@EasyAsABC123
Copy link
Contributor

@kbarry-x Closing issue, appears to be resolved. If you have an example of the issue persisting please re-open. Thanks

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

No branches or pull requests

4 participants