Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.1 kB
1
Indexable
Never
- tags: install_choco
  block:
    - name: Get chocolatey installer script
      win_get_url:
        url: "{{ chocolatey_base_installer_url }}"
        dest: "{{ choco_installer }}"
        use_proxy: no
        force: yes

    - name: Install chocolatey client and make ready for configuring chocolatey central management
      win_command: powershell.exe
      args:
        stdin: |
          & "{{ choco_installer }}"
          exit $LASTEXITCODE
      environment:
        CHOCO_SOURCE_GIT_BRANCH_TAG: "{{ chocolatey_git_branch_tag }}"
        CHOCO_ENVIRONMENT: "{{ env }}"
        CHOCO_ENABLE_INSTALL_ON_SERVER: 'Y'
      register: out
      failed_when: out.rc != 0

    - name: Restart the host for chocolatey installation to take effect
      win_reboot:
        msg: "Reboot initiated. Wait a bit for the server to be up again."
        post_reboot_delay: 30
      when: out.rc == 0
  always:
    - name: Cleanup
      win_file:
        path: "{{ choco_installer }}"
        state: absent
  vars:
    choco_installer: C:/Temp/Install-Chocolatey.ps1
Leave a Comment