Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win_chocolatey fails to deploy packages #27155

Closed
lmilbaum opened this issue Jul 21, 2017 · 13 comments · Fixed by #31085
Closed

win_chocolatey fails to deploy packages #27155

lmilbaum opened this issue Jul 21, 2017 · 13 comments · Fixed by #31085
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_info This issue requires further information. Please answer any outstanding questions. support:community This issue/PR relates to code supported by the Ansible community. windows Windows community

Comments

@lmilbaum
Copy link

lmilbaum commented Jul 21, 2017

ISSUE TYPE
  • Bug Report
COMPONENT NAME

win_chocolatey

ANSIBLE VERSION

ansible 2.3.1.0
config file =
configured module search path = Default w/o overrides
python version = 2.7.10 (default, Feb 7 2017, 00:08:15) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]

CONFIGURATION
OS / ENVIRONMENT

control machine: OS-X 10.12.6
target machine - Windows 2012 R2

SUMMARY

The following packages fail to deploy:
officeproplus2013
sql-server-management-studio

Extending the win_chocolatey timeout attribute didn't change the result.

Manually running choco on the target machine successfully deploys all packages.

STEPS TO REPRODUCE
- name: Deploy tools
  win_chocolatey:
    name: "{{ item }}"
  with_items:
    - officeproplus2013
    - visualstudio2013professional
    - sql-server-management-studio
EXPECTED RESULTS

Successfully deployed all packages

ACTUAL RESULTS
TASK [depy.dev : Deploy tools] ***************************************************************************************************************************
task path: /Users/liora/git/depy-backend/depy/ansible/roles/depy/depy.dev/tasks/main.yml:9
Using module file /Users/liora/venv/lib/python2.7/site-packages/ansible/modules/windows/win_chocolatey.ps1
<185.109.149.152> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 185.109.149.152
EXEC (via pipeline wrapper)
failed: [185.109.149.152] (item=officeproplus2013) => {
    "changed": true,
    "choco_error_cmd": "C:\\ProgramData\\chocolatey\\bin\\choco.exe install -dv -y officeproplus2013 -timeout 2700",
    "choco_error_log": null,
    "failed": true,
    "item": "officeproplus2013",
    "msg": "Error installing officeproplus2013",
    "rc": -2147418113
}
Using module file /Users/liora/venv/lib/python2.7/site-packages/ansible/modules/windows/win_chocolatey.ps1
EXEC (via pipeline wrapper)
changed: [185.109.149.152] => (item=visualstudio2013professional) => {
    "changed": true,
    "item": "visualstudio2013professional",
    "rc": 0
}
Using module file /Users/liora/venv/lib/python2.7/site-packages/ansible/modules/windows/win_chocolatey.ps1
EXEC (via pipeline wrapper)
failed: [185.109.149.152] (item=sql-server-management-studio) => {
    "changed": true,
    "choco_error_cmd": "C:\\ProgramData\\chocolatey\\bin\\choco.exe install -dv -y sql-server-management-studio -timeout 2700",
    "choco_error_log": null,
    "failed": true,
    "item": "sql-server-management-studio",
    "msg": "Error installing sql-server-management-studio",
    "rc": 5
}
@ansibot
Copy link
Contributor

ansibot commented Jul 21, 2017

@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. windows Windows community labels Jul 21, 2017
@jhawkesworth
Copy link
Contributor

jhawkesworth commented Jul 21, 2017

It looks like it is failing because the installers are exiting with a non-zero exit code (hence the "rc": -2147418113 for officeproplus2013 and "rc": 5 for sql-server-management-studio

Its worth using search engines to see why these packages might return these non-zero exit codes.

I have encounted '5' as an exit code before and in my case it was because a dependency on a visual studio c++ runtime was not present. In my case the VS runtime required a hotfix to be installed (this may have now been rolled up so perhaps not needed), but I will share the tasks needed to install the hotfix and runtime below in case it is relevant. It is a very vague error message though 5 means 'Access is denied' but doesn't tell you anything specific about what exactly has failed.

I don't use chocolately myself but worth checking if it logs any further information on the affected host, and worth checking the event log too.

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Jul 21, 2017
@jhawkesworth
Copy link
Contributor

Here's the hotfix and VC runtime installation steps.

- name: check if Windows8.1-KB2999226-x64.msu hotfix has been applied
  win_shell: Get-Hotfix -Id KB2999226
  register: hotfix_status
  ignore_errors: true

- name: show hotfix status
  debug:
    var: hotfix_status

# Unfortunately you can't use wusa directly to install windows updates.
# see https://support.microsoft.com/en-us/kb/2773898 for details
# you have to unpack the update file and then use dism.exe to install the cab

- name: unpack the hotfix if needed
  win_shell: 'wusa C:\deployment\current\Windows8.1-KB2999226-x64.msu /extract:C:\deployment\archive'
  when: hotfix_status.rc == 1

- name: use dism to install the cab containing the hotfix
  win_shell: 'dism.exe /online /add-package /PackagePath:C:\deployment\archive\Windows8.1-KB2999226-x64.cab'
  when: hotfix_status.rc == 1

- name: ensure Microsoft Visual C++ 2015 x64 Additional Runtime is present
  win_package:
     name: Microsoft Visual C++ 2015 x64 Additional Runtime
     path: 'C:/Program Files/FireDaemon Session 0 Viewer/vc_redist.x64.exe'
     state: present
     product_id: '{BC958BD2-5DAC-3862-BB1A-C1BE0790438D}'
     arguments: "/install /passive /norestart /quiet"

#  Info on the hotfix that needs to be applied first
# see http://stackoverflow.com/questions/33265663/api-ms-win-crt-runtime-l1-1-0-dll-is-missing-when-open-office-file
# the hotfix is KB2999226

@lmilbaum
Copy link
Author

search engines didn't help.
Trying to find a way to output chocolatey log. There used to be an attribute showlog which doesn't exists in current version. Any other way to produce the log with ansible?
Everything works just fine when running the choco install command in the command prompt (on the target machine).

@lmilbaum
Copy link
Author

lmilbaum commented Jul 21, 2017

Found a way to output the chocolatey log file. Here it is:
https://gist.github.com/lioramilbaum/792f3dc3173c26e80b6f69f8b83ed7ca

@jhawkesworth
Copy link
Contributor

hmm, so looks like its the actual office setup.exe that is returning that exit code, chocolatey is just passing it through.

I found a link below which suggest that the installer starts a scheduled task, so worth checking that you are installing as a user which can start scheduled task, and that the task scheduler is running.

Also I notice that chocolatey is attempting to run as privileged user, so worth trying as local Administrator if possible.

https://answers.microsoft.com/en-us/office/forum/office_2013_release-excel/cannot-install-office-2013-error-microsoft-office/e73faec4-3d6c-4a95-b610-4510a6011a55?page=2

Hope this helps,

Jon

@jhawkesworth
Copy link
Contributor

Another possibility is that the setup.exe is somehow expecting an interactive user session, which you won't have when running in winrm. It might be that there is a command line switch for the office setup.exe which would make setup.exe expect an unattended installation (and therefore not expect interactive user session).

However I'm not sure you can pass in extra arguments to the chocolatey installer via the win_chocolatey modules at the moment.

@ansibot ansibot added support:community This issue/PR relates to code supported by the Ansible community. and removed support:curated labels Aug 16, 2017
@jhawkesworth
Copy link
Contributor

At 19:00 UTC on Tuesday 19 September 2017 this ticket will be processed during the second Windows Sprint,
https://github.com/ansible/community/wiki/Windows:-sprints
we would appreciate if you could join the Sprint to help out with understanding/fixing/closing this issue.

@jhawkesworth
Copy link
Contributor

Discussed at sprint.
We suspect it might be possible using 'become' to run as a privileged user - please can you try using 'become'. If it works I will add to module examples.

needs_info

@ansibot ansibot added the needs_info This issue requires further information. Please answer any outstanding questions. label Sep 19, 2017
@jborean93
Copy link
Contributor

I haven't used chocolatey to install Office but I know you can use the normal install msi without anything special. Chocolatey could be doing something special or calling it in a different way than I did in the past so it could be it.

For SQL Management Studio, considering the normal SQL Server install requires credential delegation (CredSSP/Kerberos with delegation/become) I wouldn't be surprised if the management studio components is the same.

@jhawkesworth
Copy link
Contributor

jhawkesworth commented Sep 19, 2017

I was able to install office using become as follows
command line:
ansible-playbook 27155.yml -K

$ cat 27155.yml

- hosts: 12,
  gather_facts: false
  become_method: runas
  become_user: Administrator
  tasks:
    - name: Deploy tools
      win_chocolatey:
        name: "{{ item }}"
      with_items:
        - officeproplus2013
      become: yes

@jhawkesworth
Copy link
Contributor

For info I was able to install all 3 packages listed above by using 'become'.
Once I have documented this, I think this issue can be closed.

@jborean93
Copy link
Contributor

Documentation PR for this can be seen here #30783. Feel free to review and add your comments.

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_info This issue requires further information. Please answer any outstanding questions. support:community This issue/PR relates to code supported by the Ansible community. windows Windows community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants