Files
windows-ansible/ansible/roles/win_chocolatey/tasks/chocolatey.yml
T

106 lines
3.3 KiB
YAML

---
- name: Chocolatey Server
tags: choco_server
block:
- name: Set up chocolatey server
import_role:
name: jborean93.win_chocolatey_server
- name: Chocolatey Packages
tags: all_packages
block:
- name: Community Pacakges
tags: community_packages
block:
- name: Create Package folder
win_file:
path: "{{ choco_package_path }}\\{{ package }}"
state: directory
loop: "{{ community_packages }}"
loop_control:
loop_var: package
- name: Download nupkg to Chocolatey server.
win_get_url:
url: "https://community.chocolatey.org/api/v2/package/{{ package }}"
dest: "{{ choco_package_path }}\\{{ package }}.nupkg"
loop: "{{ community_packages }}"
loop_control:
loop_var: package
pause: 10
# try create package folder if no change skip
rescue: # Fallback to local copies if rate limiting causes failure
- name: Local fallback - Get list of local packages
vars:
ansible_connection: local
find:
paths: "{{ community_package_path }}"
file_type: file
patterns: "*.nupkg"
delegate_to: localhost
register: local_community_packages
- name: Local fallback - Copy community packages to Chocolatey server.
win_copy:
src: "{{ package.path }}"
dest: "{{ choco_package_path }}\\"
loop: "{{ local_community_packages.files }}"
loop_control:
loop_var: package
- name: Custom Packages
tags:
- custom_packages
block:
- name: Get list of local packages
vars:
ansible_connection: local
find:
paths: "{{ custom_package_path }}"
file_type: file
patterns: "*.nupkg"
delegate_to: localhost
register: local_packages
- name: Copy custom packages to Chocolatey server.
win_copy:
src: "{{ package.path }}"
dest: "{{ choco_package_path }}\\"
#\\{{ package.path | basename | split('.') | first }}\\"
loop: "{{ local_packages.files }}"
loop_control:
loop_var: package
# taken from jborean93.win_chocolatey_server handler and modified with longer timeout (Create handler???)
- name: open package page to get Chocolatey server to load nuget packages
win_uri:
url: http://localhost:{{ opt_chocolatey_server_http_port }}/chocolatey/Packages
url_timeout: 600
tags: refresh_packages
- name: Server Packages
tags: server_packages
block:
- name: Add local Chocolatey source
win_chocolatey_source:
name: EPCC
state: present
source: "{{ local_repo_source }}"
- name: Install Chocolatey GUI
win_chocolatey:
name: ChocolateyGUI
state: present
package_params: "'/Global'"
source: "{{ local_repo_source }}"
tags: install_choco_gui
rescue:
- name: install Chocolatey GUI dependancies
win_chocolatey:
name: dotnetfx
state: present
allow_prerelease: true
tags: install_choco_gui