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

Major change with multiple features #91

Merged
merged 32 commits into from
Dec 19, 2014
Merged

Major change with multiple features #91

merged 32 commits into from
Dec 19, 2014

Conversation

EasyAsABC123
Copy link
Contributor

  • Virtual Directory Support
  • section unlock and lock support
  • fixed issue with :add on pool provider not running all config
  • fixed issue with :config on all providers causing application pool recycles (every chef-client run)
  • moved to better method for XML checking of previous settings to detect changes

I apologize for the large pull request but the speed of approvals is taking too long and we have had to write too much code.

vdog and others added 19 commits April 24, 2014 09:56
If the site already exists, the site_id wasn't getting set in IIS.
This existed on 1/4 calls - just adding to the rest.  This prevents an
issue on IIS7, which doesn't like forward slashes in this arg.
Update README with :config action for both iis_site and iis_pool, :recycle action for iis_pool, and pool_username and pool_password attributes for iis_pool. No new functionality; documentation update only.
Added monospacing for some attributes and actions.
Converge the site_id during :config actions
Add win_friendly_path to all appcmd.exe /physicalPath arguments.
Fixing new_resource action being updated properly if action is called.
updated to fix bug with command
Conflicts:
	metadata.rb
	providers/pool.rb
@kwilczynski
Copy link
Contributor

Paging @adamedx, @btm, @jdmundrawala and @jtimberman.

Gentleman, any way you can help Justin to get this merged?

@jtimberman
Copy link

I'm not really qualified to comment about this with regard to IIS. However, I'll make some general comments in the code.

# Cookbook Name:: iis
# Resource:: lock
#
# Copyright:: 2011, Webtrends Inc.

Choose a reason for hiding this comment

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

Is Justin with Webtrends? Was this code written in 2011? The copyright should reflect reality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, simple copy + paste remnant changed to be no Copyright

@jtimberman
Copy link

Generally speaking, we prefer to avoid really large changes like this that add a bunch of different functionality. It is easier to review smaller sets of changes. We also want to have consistent style in the code, which is why we use rubocop and foodcritic across cookbook projects.

It would be superb to start getting test coverage for these new features, too, to ensure they "DWIM" and they don't alter existing functionality, especially where large amounts of code are refactored/moved around.

def initialize(*args)
super
@action = :config
end

Choose a reason for hiding this comment

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

I think we prefer the resource helper method, "default_action" here instead of an initialize method. The end result is the same, but the helper is easier to understand the intention.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to use the default_action method

identity_type = XPath.first(doc.root, "APPPOOL/add/processModel/@identityType").to_s == "SpecificUser" ? false : true
user_name = XPath.first(doc.root, "APPPOOL/add/processModel/@userName").to_s == @new_resource.pool_username.to_s || @new_resource.pool_username.to_s == '' ? false : true
password = XPath.first(doc.root, "APPPOOL/add/processModel/@password").to_s == @new_resource.pool_password.to_s || @new_resource.pool_password.to_s == '' ? false : true
end
Copy link
Contributor

Choose a reason for hiding this comment

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

These XPath lines could use some simplification or clarification. There's a bunch of order happening in there... looking at the right I might think that that the values on the left like user_name is either true or false. Some parenthesis might clear that up, but I there's probably a ton of value in considering if you could have a separate method implement this logic and then call that for each attribute/variable here.

Yeah, I'm just not sure what's happening here, so it could use some cleanup.

Copy link
Contributor

Choose a reason for hiding this comment

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

looking down below it looks like these are just true/false values, not an actual value, so I'd recommend changing the variable names to something that indicidates that you're a) setting something and b) is a true/false value (end with?)

set_max_processes?
enable_32_bit_app_on_win_64?
set_managed_runtime_version?

Or whatever.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added helper function and then added ? to variable names

@btm
Copy link
Contributor

btm commented Dec 17, 2014

It would be nice to update "ie vdirs" to "i.e. vdirs" in the README.md if you go back in there for anything.

@btm
Copy link
Contributor

btm commented Dec 17, 2014

okay, I think this looks pretty good. it's a lot, which means we've just got to get it in and test it a bit before we release.

we'll get it into master soon, and I hope you'll help test from master as this will be a major release.

I'd really like to get the test-kitchen framework we recently got into the windows cookbook copied over here so we can create some integration tests for this. I'd love it if you'd help with building those out.

👍

@EasyAsABC123
Copy link
Contributor Author

@btm sounds good, I look forward to seeing this move forward as a major release.

A lot of testing will need to be done both manually, and i'd love to be involved in adding the test-kitchen frameworks for IIS. Looking at the windows cookbook I don't see this being a huge issue, just a slight learning curve.

@drpebcak
Copy link

Awesome, I hope to see this released soon.

@endakenny
Copy link

Hi Guys - im relatively new to chef - i have a cookbook which uses the iis cookbook(2.1.2). I really like the prospect of having the virtual directory resource and also the lock/unlock thats in this pull request. How long approximately will it be before this will be released? Will it be weeks or months. Also, need i wait for it to be released? i did a quick test - pulled down the latest iis and windows cookbook and i got an error when i ran my cookbook which depends upon them.

@btm
Copy link
Contributor

btm commented Dec 19, 2014

@endakenny it could be weeks or months, depending how many people have time to work on it.

If you've copied this cookbook out of git and tried using it and gotten errors, you can file them as github issues and someone with more experience can look at them. Just make sure you mention that you're running from the git master in each issue you file, and include a copy of the error. You can use three backticks to quote code on github like this:

this is code

turns into this:

this is code

@EasyAsABC123
Copy link
Contributor Author

@drpebcak if you could join the testing effort and submit issues, you can definitely speed up the release.

@endakenny please submit your cookbook code and the error, i'll happily take a gander at it.

@drpebcak
Copy link

@EasyAsABC123 I definitely will. I've already been using a slightly hacked together version of this cookbook to get certain things working, so I would love to help test these changes.

@endakenny
Copy link

@EasyAsABC123 - my cookbook is too big(rather than complex) to show you as a sample. What ive done is broken down the sample to your code above - with only the iis_pool and iis_site resources. Obviously i added a dependency on the iis cookbook. Then i ran in chef-client in local mode

Here were the cookbooks used
[2014-12-22T10:41:29+00:00] INFO: Loading cookbooks [testing-new-iis-cookbook@0.1.0, iis@3.0.0, windows@1.36.1, chef_handler@1.1.6]
Synchronizing Cookbooks:

Here was the compile exception:
[2014-12-22T10:41:49+00:00] INFO: Storing updated cookbooks/chef_handler/README.md in the cache.

  • chef_handler
    Compiling Cookbooks...

Recipe Compile Error in C:/Users/kennye/.chef/local-mode-cache/cache/cookbooks/iis/providers/app.rb

TypeError

wrong argument type Class (expected Module)

Cookbook Trace:

C:/Users/kennye/.chef/local-mode-cache/cache/cookbooks/iis/providers/app.rb:26:in include' C:/Users/kennye/.chef/local-mode-cache/cache/cookbooks/iis/providers/app.rb:26:inclass_from_file'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/mixin/from_file.rb:42:in class_eval' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/mixin/from_file.rb:42:inclass_from_file'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/provider/lwrp_base.rb:94:in build_from_file' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/run_context/cookbook_compiler.rb:211:inload_lwrp_provider'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/run_context/cookbook_compiler.rb:202:in block in load_lwrps_from_cookbook ' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/run_context/cookbook_compiler.rb:201:ineach'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/run_context/cookbook_compiler.rb:201:in load_lwrps_from_cookbook' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/run_context/cookbook_compiler.rb:121:inblock in compile_lwrps'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/run_context/cookbook_compiler.rb:120:in each' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/run_context/cookbook_compiler.rb:120:incompile_lwrps'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/run_context/cookbook_compiler.rb:73:in compile' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/run_context.rb:88:inload'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/policy_builder/expand_node_object.rb:73:in setup_run_context' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/client.rb:265:insetup_run_context'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/client.rb:429:in do_run' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/client.rb:227:inrun'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/application.rb:217:in run_chef_client' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/application/client.rb:328:inblock in run_application'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/application/client.rb:317:in loop' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/application/client.rb:317:inrun_application'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/lib/chef/application.rb:67:in run' C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.4-x86-mingw32/bin/chef-client:26:in<top (required)>'
C:/opscode/chef/bin/chef-client:23:in load' C:/opscode/chef/bin/chef-client:23:in

'

Relevant File Content:

C:/Users/kennye/.chef/local-mode-cache/cache/cookbooks/iis/providers/app.rb:

19: # limitations under the License.
20: #
21:
22: require 'chef/mixin/shell_out'
23: require 'rexml/document'
24:
25: include Chef::Mixin::ShellOut
26>> include Opscode::IIS::Helper
27: include Windows::Helper
28: include REXML
29:
30: action :add do
31: unless @current_resource.exists
32: cmd = "#{appcmd} add app /site.name:"#{@new_resource.app_name}""
33: cmd << " /path:"#{@new_resource.path}""
34: cmd << " /applicationPool:"#{@new_resource.application_pool}"" if @new_resource.application_pool
35: cmd << " /physicalPath:"#{win_friendly_path(@new_resource.physical_path)}"" if @new_resource.physical_path

@endakenny
Copy link

@EasyAsABC123 - Thank you - ive logged the issue on Github - The version of iis cookbook ive used up to now was 2.1.2 - not in production but had used it extensively on preproduction servers.
I'm using hosted chef - version 11.16.4.
Ill take a look at hotfix helper class now.

@EasyAsABC123
Copy link
Contributor Author

@btm Chef::Util::PathHelper.validate_path doesn't seem to work with network paths, continually stating they are invalid.

@EasyAsABC123
Copy link
Contributor Author

@btm all resolved except for the include Opscode::IIS::Helper this is causing me to get [2014-12-29T03:32:16-05:00] FATAL: NoMethodError: iis_pool[DefaultAppPool] (iis::remove_default_site line 25) had an error: NoMethodError: No resource or method namedappcmd' for Chef::Provider::IisPool ""'
in my provider even though i included my helper with appcmd defined.

@EasyAsABC123
Copy link
Contributor Author

@btm nvm it was the usage of self. on the function declaration in the helper.rb file...woops

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.