puppetlabs-toy-chest / puppetlabs-dsc

Puppet module for PowerShell Desired State Configuration (DSC) integration
Apache License 2.0
69 stars 81 forks source link

Compiling issue cChoco module #281

Closed nealpeters86 closed 2 years ago

nealpeters86 commented 7 years ago

Hello,

We are trying to compile the cChoco module (https://github.com/PowerShellOrg/cChoco). But we're having issue's doing that (yes I know puppet also supports Chocolatey, but we want to do it the DSC way).

CentOS Linux release 7.3.1611 (Core) ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]

The steps that we took:

In the following directory: [root@puppetmaster02 custom]# pwd /etc/puppetlabs/code/environments/production/modules/dsc/build/vendor/custom

1) git clone https://github.com/PowerShellOrg/cChoco.git 2) verified that the directory name and the PSD1 filename are the same. 3) Directory structure looks like this:

[root@puppetmaster02 cChoco]# ls -l total 32 drwxr-xr-x. 2 root root 4096 Feb 20 14:53 AppVeyor -rw-r--r--. 1 root root 914 Feb 20 14:53 appveyor.yml -rw-r--r--. 1 root root 495 Feb 20 14:53 cChoco.psd1 drwxr-xr-x. 6 root root 4096 Feb 20 14:53 DSCResources -rw-r--r--. 1 root root 1580 Feb 20 14:53 ExampleConfig.ps1 drwxr-xr-x. 2 root root 4096 Feb 20 14:53 Examples -rw-r--r--. 1 root root 2202 Feb 20 14:53 readme.md drwxr-xr-x. 2 root root 4096 Feb 20 14:53 Tests [root@puppetmaster02 cChoco]# pwd /etc/puppetlabs/code/environments/production/modules/dsc/build/vendor/custom/cChoco

4) after making sure all the files are in place we did the following:

4a) in folder: [root@puppetmaster02 build]# pwd /etc/puppetlabs/code/environments/production/modules/dsc/build

4b) runned the following command bundle exec rake dsc:resources:import["build/vendor/custom"]

4c) good results! [root@puppetmaster02 build]# bundle exec rake dsc:resources:import["build/vendor/custom"] (in /etc/puppetlabs/code/environments/production/modules/dsc) Importing custom types from '/etc/puppetlabs/code/environments/production/modules/dsc/build/vendor/custom' Copying vendored resources from /etc/puppetlabs/code/environments/production/modules/dsc/build/vendor/custom to /etc/puppetlabs/code/environments/production/modules/dsc/lib/puppet_x/dsc_resources Adding custom types to '/etc/puppetlabs/code/environments/production/modules/dsc/import/dsc_resources'

5) now we need to rebuild the module with the following command: bundle exec rake dsc:types:build

5a) [root@puppetmaster02 build]# pwd /etc/puppetlabs/code/environments/production/modules/dsc/build

5b) run the command: bundle exec rake dsc:types:build

5c) We're getting a lot of things now. But at the end we have the following:

open /etc/puppetlabs/code/environments/production/modules/dsc/import/dsc_resources/xWindowsUpdate/DscResources/MSFT_xMicrosoftUpdate/MSFT_xMicrosoftUpdate.schema.mof [pragma] open /etc/puppetlabs/code/environments/production/modules/dsc/import/dsc_resources/xWindowsUpdate/DscResources/MSFT_xWindowsUpdate/MSFT_xWindowsUpdate.schema.mof [pragma] open /etc/puppetlabs/code/environments/production/modules/dsc/import/dsc_resources/xWindowsUpdate/DscResources/MSFT_xWindowsUpdateAgent/MSFT_xWindowsUpdateAgent.schema.mof [pragma] open /etc/puppetlabs/code/environments/production/modules/dsc/import/dsc_resources/xWordPress/DscResources/MSFT_xWordPressSite/MSFT_xWordPressSite.schema.mof [pragma] rake aborted! NoMethodError: undefined method empty?' for nil:NilClass /etc/puppetlabs/code/environments/production/modules/dsc/build/dsc/psmodule.rb:13:inversion' (erb):81:in block (2 levels) in build_dsc_types' /etc/puppetlabs/code/environments/production/modules/dsc/build/dsc/manager.rb:187:inblock (2 levels) in build_dsc_types' /etc/puppetlabs/code/environments/production/modules/dsc/build/dsc/manager.rb:186:in open' /etc/puppetlabs/code/environments/production/modules/dsc/build/dsc/manager.rb:186:inblock in build_dsc_types' /etc/puppetlabs/code/environments/production/modules/dsc/build/dsc/manager.rb:178:in each' /etc/puppetlabs/code/environments/production/modules/dsc/build/dsc/manager.rb:178:inbuild_dsc_types' /etc/puppetlabs/code/environments/production/modules/dsc/build/dsc.rake:228:in block (3 levels) in <top (required)>' /usr/local/rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:ineval' /usr/local/rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:in `

' Tasks: TOP => dsc:types:build (See full trace by running task with --trace)

I've runned the task with the --trace and then we have the following output

open /etc/puppetlabs/code/environments/production/modules/dsc/import/dsc_resources/xWindowsUpdate/DscResources/MSFT_xWindowsUpdate/MSFT_xWindowsUpdate.schema.mof [pragma] open /etc/puppetlabs/code/environments/production/modules/dsc/import/dsc_resources/xWindowsUpdate/DscResources/MSFT_xWindowsUpdateAgent/MSFT_xWindowsUpdateAgent.schema.mof [pragma] open /etc/puppetlabs/code/environments/production/modules/dsc/import/dsc_resources/xWordPress/DscResources/MSFT_xWordPressSite/MSFT_xWordPressSite.schema.mof [pragma] rake aborted! NoMethodError: undefined method empty?' for nil:NilClass /etc/puppetlabs/code/environments/production/modules/dsc/build/dsc/psmodule.rb:13:inversion' (erb):81:in block (2 levels) in build_dsc_types' /usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/erb.rb:864:ineval' /usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/erb.rb:864:in result' /etc/puppetlabs/code/environments/production/modules/dsc/build/dsc/manager.rb:187:inblock (2 levels) in build_dsc_types' /etc/puppetlabs/code/environments/production/modules/dsc/build/dsc/manager.rb:186:in open' /etc/puppetlabs/code/environments/production/modules/dsc/build/dsc/manager.rb:186:inblock in build_dsc_types' /etc/puppetlabs/code/environments/production/modules/dsc/build/dsc/manager.rb:178:in each' /etc/puppetlabs/code/environments/production/modules/dsc/build/dsc/manager.rb:178:inbuild_dsc_types' /etc/puppetlabs/code/environments/production/modules/dsc/build/dsc.rake:228:in block (3 levels) in <top (required)>' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/lib/rake/task.rb:240:inblock in execute' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/lib/rake/task.rb:235:in each' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/lib/rake/task.rb:235:inexecute' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/lib/rake/task.rb:179:in block in invoke_with_call_chain' /usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/monitor.rb:214:inmon_synchronize' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/lib/rake/task.rb:172:in invoke_with_call_chain' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/lib/rake/task.rb:165:ininvoke' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/lib/rake/application.rb:150:in invoke_task' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/lib/rake/application.rb:106:inblock (2 levels) in top_level' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/lib/rake/application.rb:106:in each' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/lib/rake/application.rb:106:inblock in top_level' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/lib/rake/application.rb:115:in run_with_threads' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/lib/rake/application.rb:100:intop_level' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/lib/rake/application.rb:78:in block in run' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/lib/rake/application.rb:176:instandard_exception_handling' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/lib/rake/application.rb:75:in run' /usr/local/rvm/gems/ruby-2.3.3/gems/rake-10.5.0/bin/rake:33:in<top (required)>' /usr/local/rvm/gems/ruby-2.3.3/bin/rake:22:in load' /usr/local/rvm/gems/ruby-2.3.3/bin/rake:22:in

' /usr/local/rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:in eval' /usr/local/rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:in
'

Are we doing something wrong? :-)

ferventcoder commented 7 years ago

But we're having issue's doing that (yes I know puppet also supports Chocolatey, but we want to do it the DSC way).

That's fine, just keep in mind that the DSC way is much more limited currently than the Puppet supported puppetlabs/chocolatey module (which supports completely offline scenarios better than cChoco. Also not chocolatey/chocolatey - the supported module has chocolateysource, chocolateyconfig, and chocolateyfeature as well as package). However it is hoped that the DSC will achieve a bit more parity at some point this year as compared to the Puppet provider.

As for the issues you are running into, I imagine @jpogran or someone else will answer that.

jpogran commented 7 years ago

@nealpeters86 Believe it or not, the manifest file parser had a bug (line 21) in it which meant it expected single quotes in the psd1 file, and the cChoco DSC Resource is the first to use double quotes.

After editing the regex, we correctly parse the file. I'll put up a PR in abit with the fix

~/src/puppetlabs/modules/dsc>  git s
 M build/dsc/psmodule.rb
?? lib/puppet/type/dsc_cchocoinstaller.rb
?? lib/puppet/type/dsc_cchocopackageinstaller.rb
?? lib/puppet/type/dsc_cchocosource.rb
?? lib/puppet_x/dsc_resources/cChoco/

Note that the cChocoPackageInstallerSet Composite DSC Resource won't be parsed as Composite DSC Resources don't have a MOF schema file and can't be parsed at this time.

jpogran commented 7 years ago

Addressed in #282

jpogran commented 7 years ago

Hi,

Puppet will be shutting down the github issues tab in this repository as there already is a publicly accessible issue tracker on March 24th, 2017.

If you want to continue the discussion from this issue, please follow the ticket already created from this issue (typically MODULES-XXXX) in our issue tracker.

If you would like to file a new issue, please follow the template here to create a new ticket.

Thanks,

James Pogran

chelnak commented 2 years ago

Hello! We are doing some house keeping and noticed that this issue has been open for a long time.\n\nWe're going to close it but please do raise another issue if the issue still persists. 😄