使用psexec模块为.exe安装任务运行长期/无限期的脚本。

时间:2021-09-25 20:52:15

I am new to Ansible and I'm trying to configure windows 2012 R2 from RHEL Centos 7 Node. I'm able to establish connection between them using Winrm Credssp. Below is /etc/ansible/group_vars/windows.yml file

我是新手,我试着从RHEL Centos 7节点配置windows 2012 R2。我可以使用Winrm Credssp建立它们之间的连接。下面是/etc/ansible/group_vars/windows.yml文件

---
 ansible_user: admin
 ansible_password: XXXXXXX
 ansible_winrm_scheme: https
 ansible_winrm_transport: credssp
 ansible_port: 5986
 ansible_connection: winrm
 ansible_winrm_server_cert_validation: ignore
 validate_certs: false

In /etc/ansible/hosts file I have defined windows FQDN

在/etc/ansible/hosts文件中,我已经定义了windows FQDN。

[windows]
xx.xx.xx.xx

When I execute win_ping module for testing connection from central Linux node to Windows 2012 R2 server it was successful.

当我执行win_ping模块来测试从*Linux节点到Windows 2012 R2服务器的连接时,它是成功的。

[root@centos playbooks]# ansible windows -m win_ping
XX.XX.XX.XX | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

But When I have tried installing sample .exe (VLC) file in local drive using below playbook file, after submitting ansible-playbook playbook.yml command, it is continuously waiting for indefinite time, as It is not completing .exe installation. Note: PsExec.exe location is updated in PATH env variable for windows.

但是,当我尝试在本地驱动器上安装sample .exe (VLC)文件时,使用下面的playbook文件,在提交了一份ansi -playbook playbook之后。yml命令,它一直在等待无限的时间,因为它没有完成。exe安装。注意:PsExec。exe位置在PATH env变量中更新为windows。

---
  - name: Windows ansible playbook
    hosts: windows
    tasks:
      - name: installing VLC
        win_psexec:
         command: 'E:\\Softwares\\VLC.exe'
         system: yes

Below is console output after submitting ansible-playbook command for above playbook.

下面是在提交了上面的脚本后,控制台输出。

PLAY [Windows ansible playbook] ************************************************

TASK [Gathering Facts] *********************************************************
ok: [192.168.2.14]

TASK [installing VLC] **********************************************************

Below is the log that is constantly displaying same. Waiting continuously. /var/log/ansible/log

下面是经常显示相同的日志。持续等待。/var/log/ansible/log

2017-10-27 22:22:32,574 p=4269 u=root |  TASK [installing VLC] **********************************************************
2017-10-27 22:22:32,672 requests_credssp.credssp The credentials that will be used in the auth, DOMAIN: '.', USER: 'admin'
2017-10-27 22:22:32,675 requests.packages.urllib3.connectionpool Starting new HTTPS connection (1): 192.168.2.14
2017-10-27 22:22:32,712 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 401 0
2017-10-27 22:22:32,714 requests_credssp.credssp _start_tls_handshake(): Starting TLS handshake with server
2017-10-27 22:22:32,715 requests.packages.urllib3.connectionpool Resetting dropped connection: 192.168.2.14
2017-10-27 22:22:32,771 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 401 0
2017-10-27 22:22:32,774 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 401 0
2017-10-27 22:22:32,775 requests_credssp.credssp _start_tls_handshake(): Handshake complete. Protocol: TLSv1.2, Cipher: ECDHE-RSA-AES256-GCM-SHA384
2017-10-27 22:22:32,775 requests_credssp.credssp _get_authentication_token(): creating NTLM negotiate token and add it to the initial TSRequest
2017-10-27 22:22:32,776 requests_credssp.credssp _get_authentication_token(): NTLM Negotiate Token: TlRMTVNTUAABAAAAMpCI4gEAAQAoAAAAAAAAACkAAAAGAbEdAAAADy4=
2017-10-27 22:22:32,776 requests_credssp.credssp _get_authentication_token(): get NTLM challenge token from the server and add it to the ntlm context
2017-10-27 22:22:32,777 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 401 0
2017-10-27 22:22:32,779 requests_credssp.credssp _get_authentication_token(): NTLM Challenge Token: TlRMTVNTUAACAAAADwAPADgAAAA2goriAQ4M49EAIqMAAAAAAAAAAJgAmABHAAAACgBaKQAAAA9ERVNLVE9QLUVETEFLRzQCAB4ARABFAFMASwBUAE8AUAAtAEUARABMAEEASwBHADQAAQAeAEQARQBTAEsAVABPAFAALQBFAEQATABBAEsARwA0AAQAHgBEAEUAUwBLAFQATwBQAC0ARQBEAEwAQQBLAEcANAADAB4ARABFAFMASwBUAE8AUAAtAEUARABMAEEASwBHADQABwAIAGOmEf9DT9MBAAAAAA==
2017-10-27 22:22:32,779 requests_credssp.credssp _get_authentication_token(): create NTLM authentication token
2017-10-27 22:22:32,782 requests_credssp.credssp _send_auth_response(): Generate the encrypted public key data and add it to the TSRequest
2017-10-27 22:22:32,783 requests_credssp.credssp _send_auth_response(): Send TSRequest structure containing the final auth token and public key info
2017-10-27 22:22:32,783 requests_credssp.credssp _send_auth_response(): Get the public key structure response from the server
2017-10-27 22:22:32,786 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 401 0
2017-10-27 22:22:32,786 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 401 0
2017-10-27 22:22:32,787 requests_credssp.credssp _verify_public_keys(): Get raw public key from the server and decrypt it for verification
2017-10-27 22:22:32,788 requests_credssp.credssp _verify_public_keys(): verification of the server's public key is successful
2017-10-27 22:22:32,788 requests_credssp.credssp _send_encrypted_credentials(): Sending the encrypted credentials to the server
2017-10-27 22:22:32,822 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 200 1636
2017-10-27 22:22:32,832 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 200 847
2017-10-27 22:22:33,116 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 200 753
2017-10-27 22:22:33,889 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 200 998
2017-10-27 22:22:53,934 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 500 1320
2017-10-27 22:23:13,978 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 500 1320
2017-10-27 22:23:34,024 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 500 1320
2017-10-27 22:23:54,069 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 500 1320
2017-10-27 22:24:14,114 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 500 1320

above log continues/updates same for every 20 sec. This task .exe installation was never completed.

上面的日志每20秒更新一次。这个任务。exe的安装从来没有完成。

2017-10-27 22:24:14,114 requests.packages.urllib3.connectionpool "POST /wsman HTTP/1.1" 500 1320

Please suggest what change/Update I have to do on windows side so that .exe file installation should be completed.

请说明我在windows方面需要做哪些更改/更新,以便完成。exe文件安装。

2 个解决方案

#1


0  

vlc.exe is likely waiting for input, so it will just hang there indefenetely. Same happens if you start "notepad". You need to figure out how to install the software silently so that it returns an exit code.

vlc。exe很可能在等待输入,所以它只会在那里徘徊。同样的,如果你开始“记事本”。您需要知道如何静默安装软件,以便它返回一个退出代码。

Not sure why you'd want to use win_psexec instead of win_package to install, but in any case you need to be able to make sure that the process exits and returns.

不确定为什么要使用win_psexec而不是win_package来安装,但是在任何情况下,您都需要确保进程退出并返回。

#2


0  

Thanks @Trondh. Yes you are right. Silent installation options worked for this. Same PsExec with /S /VERYSILENT arguments worked for me. :)

谢谢@Trondh。是的,你是对的。静默安装选项为此工作。同样的PsExec和/S /非常安静的论点对我起作用了。:)

#1


0  

vlc.exe is likely waiting for input, so it will just hang there indefenetely. Same happens if you start "notepad". You need to figure out how to install the software silently so that it returns an exit code.

vlc。exe很可能在等待输入,所以它只会在那里徘徊。同样的,如果你开始“记事本”。您需要知道如何静默安装软件,以便它返回一个退出代码。

Not sure why you'd want to use win_psexec instead of win_package to install, but in any case you need to be able to make sure that the process exits and returns.

不确定为什么要使用win_psexec而不是win_package来安装,但是在任何情况下,您都需要确保进程退出并返回。

#2


0  

Thanks @Trondh. Yes you are right. Silent installation options worked for this. Same PsExec with /S /VERYSILENT arguments worked for me. :)

谢谢@Trondh。是的,你是对的。静默安装选项为此工作。同样的PsExec和/S /非常安静的论点对我起作用了。:)