-1

I'm new to Ansible and I'm trying to create a package to deploy to a Windows client running Chocolatey. I have all the winrm connections working between my ansible server and my windows client, but I am struggling to understand how to define and create packages.

As an example: I want to install Notepad++ on the Windows client. I do not want it to connect to the internet to download the installer executable. Instead, I want the ansible server to push the exe to the client, then have the client execute it locally.

Can anyone explain and/or provide an example of a playbook to handle this? I know this is more easily achievable on windows via other products like SCCM, but for these purposes ansible is required.

arrowSpace
  • 11
  • 3

3 Answers3

1

The ansible playbook call you would look to make would look like such:

- name: Install notepadplusplus.install
  win_chocolatey:
    name: notepadplusplus.install
    version: '8.4.5'
    source: https:/YourInternalNuGetV2Repo
    state: present

You would look to host the Chococlatey package on an internal NuGet V2 Repository

1

I think the part here that's missing is that you don't have a packages repository for Chocolatey to pull from. If you want to deploy a package with Chocolatey, it needs to get it from somewhere; the Ansible playbooks don't allow you to create packages directly and push them to machines, they mostly just allow you to setup Chocolatey and run Chocolatey commands.

If you want to build a Chocolatey package directly on the Ansible server, the Ansible modules for Chocolatey specifically don't have that functionality built in. You could potentially use other Ansible modules to construct the necessary script and zip files for the Chocolatey package, bundle in a targeted installer .exe, and upload it to the client. Not sure exactly how you'd do that, Ansible is generally for the deployment itelf moreso than packaging things for deployment.

Then, you could have the client instructed to install it by first adding the local folder that the package was uploaded to as a Chocolatey source:

win_chocolatey_source:
  name: local
  state: present
  source: C:\\packages_folder

win_chocolatey:
  name: package_name
  source: local
  state: latest
Rain
  • 153
  • 5
0

Instead, I want the ansible server to push the exe to the client, then have the client execute it locally.

If that is all you want then you don't need Chocolatey. Use win_copy to copy the EXE over from the server to the client and use something like win_command to execute it.

There are some caveats to it. You will need the command line arguments to make it run silently and headless. You'll need to test it all as some installers return immediately (and so control would return immediately to your playbook) even though they are still installing.

If you need to use Chocolatey then the other answers here are what you are looking for.

pauby
  • 683
  • 3
  • 9