add win_chocolatey role

This commit is contained in:
Sergey Malyuk
2026-04-09 12:10:55 +03:00
parent f317671bbc
commit 23145a8247
9 changed files with 131 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
win_chocolatey_install
=========
Install chocolatey on windows hosts
Requirements
------------
None
Role Variables
--------------
None
Dependencies
------------
ansible.windows
Example Playbook
----------------
```yaml
- role: genlab.common.win_chocolatey_install
```
License
-------
BSD
Author Information
------------------
malyuk.ss@genlab.llc

View File

@@ -0,0 +1 @@
---

View File

@@ -0,0 +1 @@
---

View File

@@ -0,0 +1,16 @@
---
galaxy_info:
role_name: "win_chocolatey_install"
namespace: genlab
author: "Sergey Malyuk"
company: "Genlab, LLC"
description: "Install chocolatey"
license: "MIT"
min_ansible_version: "2.16"
platforms:
- name: "Windows"
galaxy_tags: []
dependencies: []

View File

@@ -0,0 +1,9 @@
---
- name: Converge
hosts: all
pre_tasks:
# Blank task for ignoring CI testing
# This role was tested manually
- name: Blank
ansible.builtin.command: echo
changed_when: false

View File

@@ -0,0 +1,22 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: ubuntu
image: geerlingguy/docker-ubuntu2204-ansible:latest
pre_build_image: true
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
provisioner:
name: ansible
verifier:
name: ansible
lint: |
set -e
yamllint .
ansible-lint .

View File

@@ -0,0 +1,11 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
# Blank task for ignoring CI testing
# This role was tested manually
- name: Blank
ansible.builtin.command: echo
changed_when: false

View File

@@ -0,0 +1,34 @@
---
- name: Check chocolatey existance
block:
- name: Get chocolatey status
ansible.windows.win_stat:
path: C:\ProgramData\chocolatey\bin\choco.exe
register: win_chocolatey_install_status
- name: Assert that choco binary exists
ansible.builtin.assert:
that: win_chocolatey_install_status.stat.exists
success_msg: Chocolatey IS installed
fail_msg: Chocolatey IS NOT installed
rescue:
- name: Create temp folder
ansible.windows.win_file:
path: C:\tmp
state: directory
- name: Download Chocolatey install script
ansible.windows.win_get_url:
url: https://community.chocolatey.org/install.ps1
dest: C:\tmp\install_choco.ps1
- name: Run Chocolatey install script
ansible.windows.win_shell: |
Set-ExecutionPolicy Bypass -Scope Process -Force
C:\tmp\install_choco.ps1
- name: Delete tmp directory
ansible.windows.win_file:
path: C:\tmp
state: absent

View File

@@ -0,0 +1 @@
---