Anybody got win_package to install something from a network share?

I’m attempting to use win_package to install some software on windows managed hosts and I can’t get it to work if I specify the .exe from a network share. My ansible version is 2.18.9. The documentation is confusing because it mentions parameters which apparently aren’t supported anymore - like username or user_name. The only examples they have for a network share install are those. For example, I try something like this:

    - name: Install using win_package
      ansible.windows.win_package:
        path: \\tsi-nas\Approved_Software\Everyone\Notepad++\64bit\npp.8.6.4.Installer.x64.exe
        product_id: notepad++
        arguments: /S
        state: present
        user_name: TRIDSYS\greg
      become: true
      become_method: runas
      become_user: greg

As you can see because of user_name, I am on a domain network. I have set up my connection with kerberos and can successfully connect and ping with win_ping. I was hoping to have an option like user_name to be able to specify the user for the second hop authentication. The response I get is as follows:

fatal: [DEVOPS-GH-VM.tridsys.com]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "arguments": "/S",
            "path": "\\\\tsi-nas\\Approved_Software\\Everyone\\Notepad++\\64bit\\npp.8.6.4.Installer.x64.exe",
            "product_id": "notepad++",
            "state": "present",
            "user_name": "TRIDSYS\\greg"
        }
    },
    "msg": "Unsupported parameters for (ansible.windows.win_package) module: user_name. Supported parameters include: validate_certs, use_proxy, proxy_password, arguments, checksum, force_basic_auth, http_agent, headers, expected_return_code, creates_path, proxy_use_default_credential, wait_for_children, proxy_url, log_path, url_timeout, url_username, maximum_redirection, use_default_credential, client_cert, state, proxy_username, follow_redirects, creates_service, url_password, url_method, product_id, checksum_algorithm, creates_version, chdir, client_cert_password, path, provider"
}

Most of those supported parameters mentioned aren’t shown in the documentation for win_package. I’ve searched around for more recent documentation and/or examples of someone recent that has gotten this to work and I am coming up empty handed.

I’ve also tried to use win_copy to get the installer from the network share over to a local drive where I could use win_package but I run into the same problem with win_copy. Again the documentation doesn’t show how to deal with the 2nd hop authentication.

However, I can successfully get this to work if I use win_powershell instead, but that doesn’t give me the flexibility to make sure a specific version of the software is installed. The following DOES work for me:

            - name: Install notepad++
              ansible.windows.win_powershell:
                script: |
                  \\tsi-nas\Approved_Software\Everyone\Notepad++\64bit\npp.8.6.4.Installer.x64.exe /S
              become: true
              become_method: runas
              become_user: greg

Can someone tell me if there is a proven way to get this to work with more recent versions of ansible?

Thanks.

Please read the error message, it is saying the option user_name is not valid. Remove this option and it’ll move on.

As for the become you may be able to get it working by not specifying a password but that will only work if greg is logged on interactively when the task runs. To ensure the become method has a credential to delegate to the network share make sure you specify the become password through the var ansible_become_password or start Ansible with the correct become argument.

    - name: Install using win_package
      ansible.windows.win_package:
        path: \\tsi-nas\Approved_Software\Everyone\Notepad++\64bit\npp.8.6.4.Installer.x64.exe
        product_id: notepad++
        arguments: /S
        state: present
      become: true
      become_method: runas
      vars:
        ansible_become_user: greg
        ansible_become_pass: ...

Sounds like you’re using old documentation, somehow. Use ansible-doc ansible.windows.win_package or ansible.windows.win_package module – Installs/uninstalls an installable package — Ansible Community Documentation.

Thank you for the reply Jordan. Yes, I knew it was unsupported and I have tried without but couldn’t get past the “unauthorized” errors and was struggling to find the right syntax that would work. I tried what you suggested and it DOES work now so thank you very much. I swear I tried that before but I think it was when I was using NTLM instead of Kerberos. Since I switched to Kerberos, maybe the credential delegation was what I needed for that 2nd hop?? Either way, I’m glad it works. I’m still a little confused on “become” though because I read somewhere that become is the windows user that you become to run the command - i.e. becoming admin user to have privilege to install something, but for a network share access, it could be a different user that needs to authenticate. So the question I would have is that if the windows admin user is a different user than what is needed to authenticate for the network share, then how would you do that?

Shertel, you are correct about the version. I look back through my tabs on my browser and for some reason when I was viewing the documentation for win_package, it is looking at an ansible 2.9 version of that documentation. I have no idea how I got there and how the others are the most recent versions. I should have looked up. Anyway, I see the correct version now. Thank you. And thanks for the ansible-doc command. I will remember that for the future.