add win_chocolatey role
This commit is contained in:
36
roles/win_chocolatey_install/README.md
Normal file
36
roles/win_chocolatey_install/README.md
Normal 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
|
||||||
1
roles/win_chocolatey_install/defaults/main.yml
Normal file
1
roles/win_chocolatey_install/defaults/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
---
|
||||||
1
roles/win_chocolatey_install/handlers/main.yml
Normal file
1
roles/win_chocolatey_install/handlers/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
---
|
||||||
16
roles/win_chocolatey_install/meta/main.yml
Normal file
16
roles/win_chocolatey_install/meta/main.yml
Normal 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: []
|
||||||
@@ -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
|
||||||
22
roles/win_chocolatey_install/molecule/default/molecule.yml
Normal file
22
roles/win_chocolatey_install/molecule/default/molecule.yml
Normal 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 .
|
||||||
11
roles/win_chocolatey_install/molecule/default/verify.yml
Normal file
11
roles/win_chocolatey_install/molecule/default/verify.yml
Normal 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
|
||||||
34
roles/win_chocolatey_install/tasks/main.yml
Normal file
34
roles/win_chocolatey_install/tasks/main.yml
Normal 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
|
||||||
1
roles/win_chocolatey_install/vars/main.yml
Normal file
1
roles/win_chocolatey_install/vars/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
---
|
||||||
Reference in New Issue
Block a user