Search code examples
powershellansiblems-officesilent-installer

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 | Run installer from mounted ISO] stops any action. It probably has no end.

Difference when starting from powershell and from ansible in microsoft office install log:

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:

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. 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. But perhaps there is a way to do this through win_package?


Solution

  • On the advice of zeitounator, I split the argument into two 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!