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

use resource powershell instead of powershell_script #9

Closed
vkhatri opened this issue Nov 21, 2015 · 10 comments
Closed

use resource powershell instead of powershell_script #9

vkhatri opened this issue Nov 21, 2015 · 10 comments
Assignees

Comments

@vkhatri
Copy link
Owner

vkhatri commented Nov 21, 2015

@coffeepac FYI, as per cookbook wiki, powershell_script resource is default resource powershell. It is available for Chef 11 and 12.

42>> powershell_script 'install filebeat as service' do
 43:    code "#{node['filebeat']['windows']['base_dir']}/#{node['filebeat']['windows']['version_string']}/install-service-filebeat.ps1"
 44:    only_if { node['platform'] == 'windows' }
 45:  end

Updating cookbook to use resource powershell. As, i do not have Windows platform to test it out and cookbook is broken at the moment, kindly submit PR if you find some issue with new changes.

https://github.com/chef-cookbooks/powershell#resourceprovider

@vkhatri
Copy link
Owner Author

vkhatri commented Nov 21, 2015

However, seeing warning for powershell resource.

.[2015-11-21T15:16:56+05:30] WARN: The on_platforms option to node_map has been deprecated at /var/folders/4g/vkwwhwrn56n4x7p_q3h349v00000gn/T/d20151121-51830-1upguhc/cookbooks/powershell/libraries/powershell_module_resource.rb:25:in `<class:PowershellModule>' at /Users/vkhatri/.rvm/gems/ruby-2.2.1/gems/chef-12.5.1/lib/chef/event_dispatch/dispatcher.rb:38:in `call'
[2015-11-21T15:16:57+05:30] WARN: Please use the powershell_script resource in Chef Client 11.6+

@coffeepac
Copy link

I will take a look at this on Monday when I'm back in my office. Please keep adding notes as you see things, just giving you a timeline for my effort.

@coffeepac
Copy link

we should be using powershell_script. the powershell resource (along with windows_package and some others) was provided by a third party resource. they were migrated into chef core during the 11.x series. the powershell cookbook is now only used for altering your powershell deploy (version upgrade, powershell mods, etc)

not sure what the on_platforms deprecation warning is about though. I'm not well versed with the multi platform support in chef.

@vkhatri
Copy link
Owner Author

vkhatri commented Nov 28, 2015

@coffeepac I will try to dig it further, but i do not have windows environment to play with.

Does cookbook works for you at the moment with the recent changes?

@congpine
Copy link

congpine commented Dec 2, 2015

Hi,
We are using Chef 11 and it has powershell_script built-in. We don't want to download and have powershell cookbook in our Git Repo, therefore it would be nice if we can use powershell_script.
I tested on windows 8 and it works fine.

@coffeepac
Copy link

@vkhatri sorry this took so long, but no the overall thing doesn't work. I'm getting an error from filebeat though, not the cookbook. So while I think the cookbook is fine, I can't verify.

something has changed between beta-rc2 and the now released version that is breaking. I'm getting an error 'Error initialising publisher: no host configuration found'.

@coffeepac
Copy link

@vkhatri kept poking at it and hosts is required to have a value even if the output is false. so it works just fine.

onward my friend!

@vkhatri
Copy link
Owner Author

vkhatri commented Dec 5, 2015

@coffeepac I am glad to hear that it is working fine for you. Yeah, we have removed the default output configuration from all the beats, but have kept the node attributes commented in attributes/config. I will add examples and a note for it today.

I will go ahead and close it.

@eherot
Copy link
Contributor

eherot commented Sep 2, 2016

Wondering what ever happened to this. The powershell resource was dropped from the powershell cookbook in version 4.0.0, but because there is no version constraint on the dependency for that cookbook, new installations fail with

No resource or method named `powershell' for `Chef::Recipe "config"'

Can we go back to using powershell_script?

@vkhatri
Copy link
Owner Author

vkhatri commented Sep 8, 2016

@eherot Yes, updated cookbook to use powershell_script instead, AFAICR it was reverted in favor of Chef 11.

@vkhatri vkhatri closed this as completed Sep 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants