Private chocolatey_package resource

Hi people,

I would like to have cookbooks installing packages on my node using a private repo located on the workstation for exemple, I don’t want to have my nodes searching for the packages on the internet but from a private chocolatey repo for exemple. Do you know how i could do this ?

thanks!

You can mirror the chocolatey repo locally using a simple web server, or an artifact repository that supports nuget (nexus, artifactory).

Here are instructions on chocolatey’s wiki.

Then change the chocolatey_package ‘source’ attribute

chocolatey_package 'name' do
  source                     http://example.com
  action                     :install
end

Hi @spuder

Thanks for your help , i finally used nexus to mirror my repo but i have two problems :
i need to authenticate with admin/admin123 in order to reach the repo. So how can we pass credentials in the chocolatey_package ressource?
my source is : localhost:8081/repository/ which is located on my workstation so i need to change this url to access server.
Do you know how can we do that from nexus?

Thanks!

You can try using chocolatey_package the way that the chocolatey resource worked

chocolatey "some_private_secure_package" do
  source "https://some.proget/feed"
  options ({'u' => 'username', 'p' => 'password'})
end

Sorry I don’t have a private repository set up to validate this. That snippet is taken from the chocolatey-cookbook repository

Yes you want to use the options property to pass along the user and password switches. The chocolatey_package handles the options property a bit differently than the chocolatey cookbook’s chocolatey LWRP. Instead of a hash you want to pass a string. So it would look like:

chocolatey_package "some_private_secure_package" do
  source "https://some.proget/feed"
  options '-u=username -p=password'
end
1 Like

Hi,

Thanks for your answers that helped me a lot! i tested the method to download and install soapui from a private nexus repo

that’s the recipe i used:
include_recipe ‘chocolatey’

chocolatey_package ‘soapui’ do
source "http://servername:8081/repository/nuget.org-proxy/"
options '-u=admin -p=admin123’
version "v5.2.1"
end

i had this error though:

  • chocolatey_package[soapui] action install[2016-07-19T15:49:00+02:00] INFO: P
    rocessing chocolatey_package[soapui] action install (soapui::default line 10)

    • No version specified, and no candidate version available for soapuie[0m
      ============================================================================
      ====
      Error executing action install on resource ‘chocolatey_package[soapui]’
      ============================================================================
      ====

    Chef::Exceptions::Package

    No version specified, and no candidate version available for soapui

    Resource Declaration:

    In c:/chef/cache/cookbooks/soapui/recipes/default.rb

    10: chocolatey_package ‘soapui’ do
    11: source "http://servername:8081/repository/nuget.org-
    proxy/"
    12: options '-u=admin -p=admin123’
    13: version "v5.2.1"
    14: end
    15:

    Compiled Resource:

    Declared in c:/chef/cache/cookbooks/soapui/recipes/default.rb:10:in `from_

file’

chocolatey_package("soapui") do
  package_name ["soapui"]
  action [:install]
  retries 0
  retry_delay 2
  default_guard_interpreter :default
  declared_type :chocolatey_package
  cookbook_name "soapui"
  recipe_name "default"
  source "http://servername:8081/repository/nuget.org-proxy

/"
options "-u=admin -p=admin123"
version [“v5.2.1”]
end

Platform:
---------
i386-mingw32

[2016-07-19T15:49:02+02:00] INFO: Running queued delayed notifications before re
-raising exception
e[0m
Running handlers:
[2016-07-19T15:49:02+02:00] ERROR: Running exception handlers
Running handlers complete
[2016-07-19T15:49:02+02:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 18 seconds
[2016-07-19T15:49:02+02:00] INFO: Sending resource update report (run-id: 985740
81-fc47-4f92-a17e-79a86590049e)
[2016-07-19T15:49:02+02:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stack
trace.out
[2016-07-19T15:49:02+02:00] FATAL: Please provide the contents of the stacktrace
.out file if you file a bug report
[2016-07-19T15:49:02+02:00] FATAL: Chef::Exceptions::package: chocolatey_package
[soapui] (soapui::default line 10) had an error: Chef::Exceptions::package: No v
ersion specified, and no candidate version available for soapui

Do you get the error? chocolatey seemes to recognize soapui though…

This means it could not find version v5.2.1. This makes sense since that format is not a legal nuget package version. Try 5.2.1 without the v.

okay! great i’ll try this!

Thanks a lot!