win_package - missing product id error

Trying to install notepad onto a windows 2012 server and getting an error “Missing required arguement: product_id”

  • Do I have to go lookup a product id for every .exe I want to install? Where do I get this?

-notepad.yml

install Notepad 6.9.2 from executable in shared drive

  • hosts: all

gather_facts: false

tasks:

  • name: Install Notepad 6.9.2 Package

win_package:

path: “https://10.10.128.0/mnt/ansible/npp.6.9.2.Installer.exe

arguements: “/install /passive /norestart”

Log below -

[root@localhost group_vars]# ansible-playbook notepad.yml -vvvv
Using /etc/ansible/ansible.cfg as config file
Loaded callback default of type stdout, v2.0

PLAYBOOK: notepad.yml **********************************************************
1 plays in notepad.yml

PLAY [all] *********************************************************************

TASK [Install Notepad 6.9.2 Package] *******************************************
task path: /etc/ansible/group_vars/notepad.yml:5
<10.10.128.0> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO 10.10.128.0
<10.10.128.0> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name “ansible-tmp-1471633257.79-18742 9094883462”).FullName | Write-Host -Separator ‘’;
<10.10.128.0> PUT “/tmp/tmpFMnfbg” TO “C:\Users\Administrator\AppData\Local\Temp \ansible-tmp-1471633257.79-187429094883462\win_package.ps1”
<10.10.128.0> EXEC Set-StrictMode -Version Latest
Try
{
& ‘C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1471633257.79-187429094 883462\win_package.ps1’
}
Catch
{
$obj = @{ failed = $true }
If ($
.Exception.GetType)
{
$obj.Add(‘msg’, $.Exception.Message)
}
Else
{
$obj.Add(‘msg’, $.ToString())
}
If ($.InvocationInfo.PositionMessage)
{
$obj.Add(‘exception’, $.InvocationInfo.PositionMessage)
}
ElseIf ($
.ScriptStackTrace)
{
$obj.Add(‘exception’, $.ScriptStackTrace)
}
Try
{
$obj.Add(‘error_record’, ($ | ConvertTo-Json | ConvertFrom-Json))
}
Catch
{
}
Echo $_obj | ConvertTo-Json -Compress -Depth 99
Exit 1
}
Finally { Remove-Item “C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-147 1633257.79-187429094883462” -Force -Recurse -ErrorAction SilentlyContinue }
fatal: [10.10.128.0]: FAILED! => {“changed”: false, “failed”: true, “invocation” : {“module_name”: “win_package”}, “msg”: “Missing required argument: product_id” }

NO MORE HOSTS LEFT *************************************************************
to retry, use: --limit @notepad.retry

PLAY RECAP *********************************************************************
10.10.128.0 : ok=0 changed=0 unreachable=0 failed=1

Nevermind - I just added product_id=“notepad” to get past this error

You basically need the id, as that’s what gets checked for idempodency. So if you put in something wrong it will attempt to install on every run. You’ll find the correct key in the uninstall node in the registry.

so is there no way I can use a dummy id? Id have to install on another machine first and then find the product_id?

Changed my playbook to the following but it seems like it stalls and doesnt provide an final error

install Notepad 6.9.2 from specified repository

  • hosts: all
    gather_facts: false
    tasks:
  • name: Install Notepad 6.9.2 Package
    win_package:
    path: \IT00001352\Users\user\Documents\ANSIBLE\npp.6.9.2.Installer.exe
    product_id: “Notepad 6.9.2”
    user_name: “user”
    user_password: “pass”
    arguements: “/install /passive /norestart”

It seems to stick at the following output for a long time. I can see from the target box that powershell.exe is running as is the notepad installer itself.

Is there something else I am missing in the above playbook?

Log output -

10.10.128.0> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO 10.10.128.0
<10.10.128.0> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name “ansible-tmp-1471961958.88-29561 933562114”).FullName | Write-Host -Separator ‘’;
<10.10.128.0> PUT “/tmp/tmpW4L0nP” TO “C:\Users\Administrator\AppData\Local\Temp \ansible-tmp-1471961958.88-29561933562114\win_package.ps1”
<10.10.128.0> EXEC Set-StrictMode -Version Latest
Try
{
& ‘C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1471961958.88-295619335 62114\win_package.ps1’
}
Catch
{
$obj = @{ failed = $true }
If ($
.Exception.GetType)
{
$obj.Add(‘msg’, $.Exception.Message)
}
Else
{
$obj.Add(‘msg’, $.ToString())
}
If ($.InvocationInfo.PositionMessage)
{
$obj.Add(‘exception’, $.InvocationInfo.PositionMessage)
}
ElseIf ($
.ScriptStackTrace)
{
$obj.Add(‘exception’, $.ScriptStackTrace)
}
Try
{
$obj.Add(‘error_record’, ($ | ConvertTo-Json | ConvertFrom-Json))
}
Catch
{
}
Echo $_obj | ConvertTo-Json -Compress -Depth 99
Exit 1
}
Finally { Remove-Item “C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-147 1961958.88-29561933562114” -Force -Recurse -ErrorAction SilentlyContinue }

Also took the product id from the registry of my machine and tried that in the playbook also, same result

Any ideas anyone?

Yes, I have hit this with notepad++. I think it hangs because a dialog is prompting the user for some input.

I think there's a chocolatey package for it, so probably the easiest way to get round it is to use chocolatey.

I think there's a zip file version as well if you don't mind scripting a bit more of the installation.

Otherwise I would suggest raising an issue with the notepad++ developers. Having a fully unattended installer is not an unreasonable thing to ask for and likely the devs could make use of such a thing in their testing.

Let us know how you get on.

Jon

https://gist.github.com/don-rumata/f42134fd59e7c7630cbef31b05306552