├── requirements.txt ├── .gitignore ├── .github ├── FUNDING.yml └── workflows │ ├── ci.yml │ └── release.yml ├── defaults └── main.yml ├── .pre-commit-config.yaml ├── meta └── main.yml ├── tasks └── main.yml ├── LICENSE └── README.md /requirements.txt: -------------------------------------------------------------------------------- 1 | ansible 2 | ansible-lint 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.keytab 2 | *.retry 3 | .DS_Store 4 | .DS_Store? 5 | ._* 6 | .Spotlight-V100 7 | .Trashes 8 | ehthumbs.db 9 | Thumbs.db 10 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | github: deekayen 4 | ko_fi: deekayen 5 | liberapay: deekayen 6 | custom: ["paypal.me/deekayen", "venmo.com/drdnorman", "buymeacoff.ee/deekayen"] 7 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | chocolatey_installer: https://chocolatey.org/install.ps1 4 | chocolatey_path: c:/ProgramData/chocolatey 5 | chocolatey_version: latest 6 | chocolatey_windows_compression: "false" 7 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | repos: 4 | - repo: https://github.com/ansible/ansible-lint.git 5 | rev: v5.0.12 6 | hooks: 7 | - id: ansible-lint 8 | files: \.(yaml|yml)$ 9 | args: [--exclude=/Users/deekayen/.ansible] 10 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | galaxy_info: 4 | role_name: chocolatey 5 | namespace: deekayen 6 | author: David Norman 7 | description: Install the Chocolatey package manager on Microsoft Windows. 8 | license: BSD 9 | min_ansible_version: 2.3 10 | 11 | github_branch: main 12 | issue_tracker_url: https://github.com/deekayen/ansible-role-chocolatey/issues 13 | 14 | platforms: 15 | - name: Windows 16 | versions: 17 | - all 18 | 19 | galaxy_tags: 20 | - windows 21 | - chocolatey 22 | 23 | dependencies: [] 24 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: CI 3 | 'on': 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | 9 | jobs: 10 | 11 | test: 12 | name: Linting 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Check out the codebase. 17 | uses: actions/checkout@v2 18 | 19 | - name: Set up Python 3. 20 | uses: actions/setup-python@v2 21 | with: 22 | python-version: '3.x' 23 | 24 | - name: Install test dependencies. 25 | run: pip install --upgrade --upgrade-strategy eager -r requirements.txt 26 | 27 | - name: Run ansible-lint. 28 | run: ansible-lint . 29 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | name: Release 4 | 'on': 5 | push: 6 | tags: 7 | - '*' 8 | 9 | jobs: 10 | 11 | release: 12 | name: Release 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Check out the codebase. 16 | uses: actions/checkout@v2 17 | 18 | - name: Set up Python 3. 19 | uses: actions/setup-python@v2 20 | with: 21 | python-version: '3.x' 22 | 23 | - name: Install Ansible. 24 | run: pip3 install ansible-base 25 | 26 | - name: GitHub Environment Variables Action 27 | uses: FranzDiebold/github-env-vars-action@v2.3.0 28 | 29 | - name: Trigger a new import on Galaxy. 30 | run: ansible-galaxy role import --branch $CI_REF_NAME --api-key ${{ secrets.GALAXY_API_KEY }} $CI_REPOSITORY_OWNER $CI_REPOSITORY_NAME 31 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: "Check for existing chocolatey install." 4 | win_stat: 5 | path: "{{ chocolatey_path }}/choco.exe" 6 | register: chocolatey_exe 7 | 8 | - name: "Debug: Existing Chocolatey status." 9 | debug: 10 | var: chocolatey_exe 11 | verbosity: 2 12 | 13 | - name: "Install latest Chocolatey." 14 | raw: "$env:chocolateyUseWindowsCompression='{{ chocolatey_windows_compression }}'; \ 15 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ 16 | iex ((New-Object System.Net.WebClient).DownloadString('{{ chocolatey_installer }}'))" 17 | register: chocolatey_install_result 18 | when: 19 | - chocolatey_exe.stat.exists is defined 20 | - not chocolatey_exe.stat.exists 21 | - chocolatey_version == "latest" 22 | 23 | - name: "Install specific Chocolatey." 24 | raw: "$env:chocolateyUseWindowsCompression='{{ chocolatey_windows_compression }}'; \ 25 | $env:chocolateyVersion = '{{ chocolatey_version }}'; \ 26 | iex ((New-Object System.Net.WebClient).DownloadString('{{ chocolatey_installer }}'))" 27 | register: chocolatey_install_result 28 | when: 29 | - chocolatey_exe.stat.exists is defined 30 | - not chocolatey_exe.stat.exists 31 | - chocolatey_version != "latest" 32 | 33 | - name: "Debug: Chocolatey install output." 34 | debug: 35 | var: chocolatey_install_result 36 | verbosity: 3 37 | 38 | - name: "Add chocolatey to PATH." 39 | win_path: 40 | name: PATH 41 | elements: '%ALLUSERSPROFILE%\chocolatey\bin' 42 | scope: machine 43 | state: present 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2017, David Norman 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Chocolatey 2 | ========== 3 | 4 | [![CI](https://github.com/deekayen/ansible-role-chocolatey/actions/workflows/ci.yml/badge.svg)](https://github.com/deekayen/ansible-role-chocolatey/actions/workflows/ci.yml) [![Project Status: Unsupported – The project has reached a stable, usable state but the author(s) have ceased all work on it. A new maintainer may be desired.](https://www.repostatus.org/badges/latest/unsupported.svg)](https://www.repostatus.org/#unsupported) ![BSD 3-Clause license](https://img.shields.io/badge/license-BSD%203--Clause-blue) ![Windows platform](https://img.shields.io/badge/platform-windows-lightgrey) 5 | 6 | Install the Chocolatey package manager on Microsoft Windows. 7 | 8 | If Chocolatey is missing from the system, the win_chocolatey module is supposed to install it. This role may be helpful to ensure Chocolatey is available on a system, even if you don't run win_chocolatey tasks against it. See http://docs.ansible.com/ansible/win_chocolatey_module.html. 9 | 10 | Role Variables 11 | -------------- 12 | 13 | The tasks look for `choco.exe` at the `chocolatey_path`. The installer Powershell script defaults to downloading from chocolatey.org; change `chocolatey_installer` if your target machine doesn't have Internet access or uses a customized install script. 14 | 15 | chocolatey_installer: https://chocolatey.org/install.ps1 16 | chocolatey_path: c:/ProgramData/chocolatey 17 | chocolatey_version: latest 18 | chocolatey_windows_compression: "false" 19 | 20 | Example Playbook 21 | ---------------- 22 | 23 | - hosts: win_servers 24 | roles: 25 | - role: deekayen.chocolatey 26 | chocolatey_installer: https://chocolatey.org/install.ps1 27 | chocolatey_path: c:/ProgramData/chocolatey 28 | 29 | Requirements 30 | ------------ 31 | 32 | The user running this role needs administrator access. 33 | 34 | * Windows 7+ / Windows Server 2008+ 35 | * PowerShell v3+ 36 | * .NET Framework 4+ (the installation will attempt to install .NET 4.0 if you do not have it installed) 37 | 38 | Dependencies 39 | ------------ 40 | 41 | None. 42 | 43 | License 44 | ------- 45 | 46 | BSD 47 | --------------------------------------------------------------------------------