简体   繁体   English

Ansible 无法在 Windows 中安装 Microsoft Office 2016 10

[英]Ansible cant install Microsoft Office 2016 in Windows 10

    - name: Install | Install Microsoft Office 2016 | Mounting ISO
      community.windows.win_disk_image:
        image_path: C:\Temp\ansible_downloads\SW_DVD5_Office_2016_64Bit_Russian_MLF_X20-42506.ISO
        state: present
      register: mounted_iso
      changed_when: no

    - name: Install | Install Microsoft Office 2016 | Run installer from mounted ISO
      ansible.windows.win_package:
        path: '{{ mounted_iso.mount_paths[0] }}setup.exe'
        product_id: '{90160000-0012-0000-1000-0000000FF1CE}'
        state: present
        arguments:
        - /adminfile C:\Temp\ansible_downloads\SW_DVD5_Office_2016_64Bit_Russian_MLF_X20-42506.MSP
PLAY [Install initial programs] ********************************************************************************************************************************************************************************

TASK [Install | Install Microsoft Office 2016 | Mounting ISO] **************************************************************************************************************************************************
ok: [admin3]

TASK [Install | Install Microsoft Office 2016 | Run installer from mounted ISO] ********************************************************************************************************************************

And nothing happens.什么也没有发生。 On the TASK [Install |关于任务 [安装 | Install Microsoft Office 2016 |安装 Microsoft Office 2016 | Run installer from mounted ISO] stops any action.从已安装的 ISO 运行安装程序] 停止任何操作。 It probably has no end.它可能没有尽头。

Difference when starting from powershell and from ansible in microsoft office install log: microsoft office 安装日志中从 powershell 和 ansible 开始时的区别:

Ansible: Ansible:

2022/08/28 12:49:43:944::[13832] Command line: D:\setup.exe "/adminfile C:\Temp\ansible_downloads\SW_DVD5_Office_2016_64Bit_Russian_MLF_X20-42506.MSP"
2022/08/28 12:49:43:945::[13832] Parsing command line.
2022/08/28 12:49:43:945::[13832] Unrecognized command line parameter: /ADMINFILE C:\TEMP\ANSIBLE_DOWNLOADS\SW_DVD5_OFFICE_2016_64BIT_RUSSIAN_MLF_X20-42506.MSP

Powershell: Powershell:

2022/08/28 12:38:09:012::[11908] Command line: D:\setup.exe  /adminfile C:\Temp\ansible_downloads\SW_DVD5_Office_2016_64Bit_Russian_MLF_X20-42506.MSP
2022/08/28 12:38:09:013::[11908] Parsing command line.
2022/08/28 12:38:09:013::[11908] Admin patch file/path specified: C:\Temp\ansible_downloads\SW_DVD5_Office_2016_64Bit_Russian_MLF_X20-42506.MSP

The problem is that the ansible passes the argument in quotes.问题是 ansible 用引号传递参数。 Is it possible to remove these quotes?是否可以删除这些引号?

Of course, there is an alternative, I can send win_shell with when product_id is not have condition, that will solve the problem.当然,还有一个替代方案,我可以在product_id没有条件的时候发送win_shell,这样就可以解决问题了。 But perhaps there is a way to do this through win_package?但也许有办法通过 win_package 做到这一点?

On the advice of zeitounator , I split the argument into two arguments:根据zeitounator的建议,我将参数分成两个 arguments:

    - name: Install | Install Microsoft Office 2016 | Run installer from mounted ISO
      ansible.windows.win_package:
        path: '{{ mounted_iso.mount_paths[0] }}setup.exe'
        product_id: '{90160000-0012-0000-1000-0000000FF1CE}'
        state: present
        arguments:
        - /adminfile
        - C:\Temp\ansible_downloads\SW_DVD5_Office_2016_64Bit_Russian_MLF_X20-42506.MSP

and it worked!它奏效了! Thanks!谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM