Best approach to use chocolatey in a salt state?

309 views
Skip to first unread message

Fredrik Averpil

unread,
Feb 5, 2016, 9:20:09 AM2/5/16
to Salt-users
Hi,

I'm setting up salt state (.sls) files for our Windows workstations. I'd like to use Chocolatey as the package manager. I can see from the chocolatey module docs that you can install packages only if they are missing, like so:
salt -G 'os:Windows' chocolatey.install_missing <package name>

What's the syntax like to put this inside a sls file?
This won't work:

sublimetext3:
  chocolatey.install_missing:
    - name: sublimetext3


Any ideas?

Cheers,
Fredrik

Fredrik Averpil

unread,
Feb 5, 2016, 9:43:30 AM2/5/16
to Salt-users
I believe I figured it out. I had to use the salt.states.module:

sublimetext3:
  module.run:
    - name: chocolatey.install_missing
    - m_name: sublimetext3


Cheers,
Fredrik

Megan Wilhite

unread,
Feb 8, 2016, 12:06:31 PM2/8/16
to Salt-users
Fredrik,

I'm glad you got it figured out and thanks for posting the answer. Just to note there is also a choclatey state module here: https://docs.saltstack.com/en/develop/ref/states/all/salt.states.chocolatey.html#module-salt.states.chocolatey that might be more applicable for your situation instead of running an execution module in your sls files. The salt.states.chocolatey.installed state module states that it will Installs a package if not already installed. 

Fredrik Averpil

unread,
Feb 8, 2016, 12:32:56 PM2/8/16
to salt-...@googlegroups.com
Hi Megan,

That looks fantastic. Hm. I see you are linking to the "develop" documentation. I'm on Salt 2015.8.5, so I'm not sure if I have chocolatey.installed available in that version? (I'm not with Salt right now so I can't try it out but I guess it's not in there)

Cheers,
Fredrik


--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Megan Wilhite

unread,
Feb 8, 2016, 12:42:53 PM2/8/16
to Salt-users
Fredrik,

You are right sorry I accidentally had it selected on the develop docs. It doesn't look like it is in 2015.8.5 but in the doc for the chocolatey module it states that it is going to be included in the boron release. I believe this is set to come out within the next couple of months. 

Here is the state module in the 2016.3 branch which will be in the boron release: https://github.com/saltstack/salt/blob/2016.3/salt/states/chocolatey.py
Reply all
Reply to author
Forward
0 new messages