问:
ansible *servergroup* -m win_ping throws error
I installed and configured ansible as per the instructions on the official documentation. The setup is as follows:

WIN 10 Enterprise VM Host runs the ansible control node which is
Ubuntu 20.04LTS VM in VirtualBox.
This control node then SSHs to a Linux server (this works just fine) or a Windows Server 2019.

As mentioned before the connection has to happen via SSH and not winrm.
After the setup yesterday I was able to win_ping the server.  After that I changed the standard shell from cmd to PowerShell. win_pinged again and shut the VM off.

Today no changes whatsoever, I started the VM and for starters wanted to verify the connection and got an error back:

```<code>ansiblenode@ansiblenode-VirtualBox:~$ ansible windows-servers -m win_ping
</code>```

[DEPRECATION WARNING]: The TRANSFORM_INVALID_GROUP_CHARS settings is set to allow bad characters in group names by default, this will
change, but still be user configurable on deprecation. This feature will be removed in version 2.10. Deprecation warnings can be
disabled by setting deprecation_warnings=False in ansible.cfg.
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
windowsTest_host1 | FAILED! => {
    "changed": false,
    "module_stderr": "At line:1 char:26\r\n+ chcp.com 65001 >nul 2>&1 && PowerShell -NoProfile -NonInteractive -Ex ...\r\n+                          ~~\r\nThe token '&&' is not a valid statement separator in this version.\r\n    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException\r\n    + FullyQualifiedErrorId : InvalidEndOfLine\r\n \r\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}```

Detailed Version with -vvvv:

windowsTest_host1 | FAILED! => {
    "changed": false,
    "module_stderr": "OpenSSH_8.2p1 Ubuntu-4ubuntu0.4, OpenSSL 1.1.1f  31 Mar 2020\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug2: resolve_canonicalize: hostname XXX.XX.XXX.XXX is address\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: Control socket \"/home/ansiblenode/.ansible/cp/c7e43effac\" does not exist\r\ndebug2: ssh_connect_direct\r\ndebug1: Connecting to XXX.XX.XXX.XXX [XXX.XX.XXX.XXX] port 22.\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: fd 3 clearing O_NONBLOCK\r\ndebug1: Connection established.\r\ndebug3: timeout: 9980 ms remain after connect\r\ndebug1: identity file /home/ansiblenode/.ssh/id_rsa type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_rsa-cert type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_dsa type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_dsa-cert type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ecdsa type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ecdsa-cert type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ecdsa_sk type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ecdsa_sk-cert type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ed25519 type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ed25519-cert type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ed25519_sk type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ed25519_sk-cert type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_xmss type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_xmss-cert type -1\r\ndebug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.4\r\ndebug1: Remote protocol version 2.0, remote software version OpenSSH_for_Windows_8.6\r\ndebug1: match: OpenSSH_for_Windows_8.6 pat OpenSSH* compat 0x04000000\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: Authenticating to XXX.XX.XXX.XXX:22 as 'Administrator'\r\ndebug3: hostkeys_foreach: reading file \"/home/ansiblenode/.ssh/known_hosts\"\r\ndebug3: record_hostkey: found key type ECDSA in file /home/ansiblenode/.ssh/known_hosts:1\r\ndebug3: load_hostkeys: loaded 1 keys from XXX.XX.XXX.XXX\r\ndebug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521\r\ndebug3: send packet: type 20\r\ndebug1: SSH2_MSG_KEXINIT sent\r\ndebug3: receive packet: type 20\r\ndebug1: SSH2_MSG_KEXINIT received\r\ndebug2: local client KEXINIT proposal\r\ndebug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c\r\ndebug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,sk-ssh-ed25519@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa\r\ndebug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com\r\ndebug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com\r\ndebug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1\r\ndebug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1\r\ndebug2: compression ctos: zlib@openssh.com,zlib,none\r\ndebug2: compression stoc: zlib@openssh.com,zlib,none\r\ndebug2: languages ctos: \r\ndebug2: languages stoc: \r\ndebug2: first_kex_follows 0 \r\ndebug2: reserved 0 \r\ndebug2: peer server KEXINIT proposal\r\ndebug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256\r\ndebug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519\r\ndebug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com\r\ndebug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com\r\ndebug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1\r\ndebug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1\r\ndebug2: compression ctos: none,zlib@openssh.com\r\ndebug2: compression stoc: none,zlib@openssh.com\r\ndebug2: languages ctos: \r\ndebug2: languages stoc: \r\ndebug2: first_kex_follows 0 \r\ndebug2: reserved 0 \r\ndebug1: kex: algorithm: curve25519-sha256\r\ndebug1: kex: host key algorithm: ecdsa-sha2-nistp256\r\ndebug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: zlib@openssh.com\r\ndebug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: zlib@openssh.com\r\ndebug3: send packet: type 30\r\ndebug1: expecting SSH2_MSG_KEX_ECDH_REPLY\r\ndebug3: receive packet: type 31\r\ndebug1: Server host key: XXXXXXXXXX
 hostkeys_foreach: reading file \"/home/ansiblenode/.ssh/known_hosts\"\r\ndebug3: record_hostkey: found key type ECDSA in file /home/ansiblenode/.ssh/known_hosts:1\r\ndebug3: load_hostkeys: loaded 1 keys from XXX.XX.XXX.XXX\r\ndebug1: Host 'XXX.XX.XXX.XXX' is known and matches the ECDSA host key.\r\ndebug1: Found key in /home/ansiblenode/.ssh/known_hosts:1\r\ndebug3: send packet: type 21\r\ndebug2: set_newkeys: mode 1\r\ndebug1: rekey out after 134217728 blocks\r\ndebug1: SSH2_MSG_NEWKEYS sent\r\ndebug1: expecting SSH2_MSG_NEWKEYS\r\ndebug3: receive packet: type 21\r\ndebug1: SSH2_MSG_NEWKEYS received\r\ndebug2: set_newkeys: mode 0\r\ndebug1: rekey in after 134217728 blocks\r\ndebug1: Will attempt key: /home/ansiblenode/.ssh/id_rsa \r\ndebug1: Will attempt key: /home/ansiblenode/.ssh/id_dsa \r\ndebug1: Will attempt key: /home/ansiblenode/.ssh/id_ecdsa \r\ndebug1: Will attempt key: /home/ansiblenode/.ssh/id_ecdsa_sk \r\ndebug1: Will attempt key: /home/ansiblenode/.ssh/id_ed25519 \r\ndebug1: Will attempt key: /home/ansiblenode/.ssh/id_ed25519_sk \r\ndebug1: Will attempt key: /home/ansiblenode/.ssh/id_xmss \r\ndebug2: pubkey_prepare: done\r\ndebug3: send packet: type 5\r\ndebug3: receive packet: type 7\r\ndebug1: SSH2_MSG_EXT_INFO received\r\ndebug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,webauthn-sk-ecdsa-sha2-nistp256@openssh.com>\r\ndebug3: receive packet: type 6\r\ndebug2: service_accept: ssh-userauth\r\ndebug1: SSH2_MSG_SERVICE_ACCEPT received\r\ndebug3: send packet: type 50\r\ndebug3: receive packet: type 51\r\ndebug1: Authentications that can continue: publickey,password,keyboard-interactive\r\ndebug3: start over, passed a different list publickey,password,keyboard-interactive\r\ndebug3: preferred gssapi-with-mic,publickey,keyboard-interactive,password\r\ndebug3: authmethod_lookup publickey\r\ndebug3: remaining preferred: keyboard-interactive,password\r\ndebug3: authmethod_is_enabled publickey\r\ndebug1: Next authentication method: publickey\r\ndebug1: Trying private key: /home/ansiblenode/.ssh/id_rsa\r\ndebug3: no such identity: /home/ansiblenode/.ssh/id_rsa: No such file or directory\r\ndebug1: Trying private key: /home/ansiblenode/.ssh/id_dsa\r\ndebug3: no such identity: /home/ansiblenode/.ssh/id_dsa: No such file or directory\r\ndebug1: Trying private key: /home/ansiblenode/.ssh/id_ecdsa\r\ndebug3: no such identity: /home/ansiblenode/.ssh/id_ecdsa: No such file or directory\r\ndebug1: Trying private key: /home/ansiblenode/.ssh/id_ecdsa_sk\r\ndebug3: no such identity: /home/ansiblenode/.ssh/id_ecdsa_sk: No such file or directory\r\ndebug1: Trying private key: /home/ansiblenode/.ssh/id_ed25519\r\ndebug3: no such identity: /home/ansiblenode/.ssh/id_ed25519: No such file or directory\r\ndebug1: Trying private key: /home/ansiblenode/.ssh/id_ed25519_sk\r\ndebug3: no such identity: /home/ansiblenode/.ssh/id_ed25519_sk: No such file or directory\r\ndebug1: Trying private key: /home/ansiblenode/.ssh/id_xmss\r\ndebug3: no such identity: /home/ansiblenode/.ssh/id_xmss: No such file or directory\r\ndebug2: we did not send a packet, disable method\r\ndebug3: authmethod_lookup keyboard-interactive\r\ndebug3: remaining preferred: password\r\ndebug3: authmethod_is_enabled keyboard-interactive\r\ndebug1: Next authentication method: keyboard-interactive\r\ndebug2: userauth_kbdint\r\ndebug3: send packet: type 50\r\ndebug2: we sent a keyboard-interactive packet, wait for reply\r\ndebug3: receive packet: type 51\r\ndebug1: Authentications that can continue: publickey,password,keyboard-interactive\r\ndebug3: userauth_kbdint: disable: no info_req_seen\r\ndebug2: we did not send a packet, disable method\r\ndebug3: authmethod_lookup password\r\ndebug3: remaining preferred: \r\ndebug3: authmethod_is_enabled password\r\ndebug1: Next authentication method: password\r\ndebug3: send packet: type 50\r\ndebug2: we sent a password packet, wait for reply\r\ndebug3: receive packet: type 52\r\ndebug1: Enabling compression at level 6.\r\ndebug1: Authentication succeeded (password).\r\nAuthenticated to XXX.XX.XXX.XXX ([XXX.XX.XXX.XXX]:22).\r\ndebug1: setting up multiplex master socket\r\ndebug3: muxserver_listen: temporary control path /home/ansiblenode/.ansible/cp/c7e43effac.bc3nbpSV394EBUJr\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug3: fd 4 is O_NONBLOCK\r\ndebug3: fd 4 is O_NONBLOCK\r\ndebug1: channel 0: new [/home/ansiblenode/.ansible/cp/c7e43effac]\r\ndebug3: muxserver_listen: mux listener channel 0 fd 4\r\ndebug2: fd 3 setting TCP_NODELAY\r\ndebug3: ssh_packet_set_tos: set IP_TOS 0x08\r\ndebug1: control_persist_detach: backgrounding master process\r\ndebug2: control_persist_detach: background process is 3177\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug1: forking to background\r\ndebug1: Entering interactive session.\r\ndebug1: pledge: id\r\ndebug2: set_control_persist_exit_time: schedule exit in 60 seconds\r\ndebug1: multiplexing control connection\r\ndebug2: fd 5 setting O_NONBLOCK\r\ndebug3: fd 5 is O_NONBLOCK\r\ndebug1: channel 1: new [mux-control]\r\ndebug3: channel_post_mux_listener: new mux channel 1 fd 5\r\ndebug3: mux_master_read_cb: channel 1: hello sent\r\ndebug2: set_control_persist_exit_time: cancel scheduled exit\r\ndebug3: mux_master_read_cb: channel 1 packet type 0x00000001 len 4\r\ndebug2: mux_master_process_hello: channel 1 slave version 4\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_master_read_cb: channel 1 packet type 0x10000004 len 4\r\ndebug2: mux_master_process_alive_check: channel 1: alive check\r\ndebug3: mux_client_request_alive: done pid = 3179\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_master_read_cb: channel 1 packet type 0x10000002 len 3122\r\ndebug2: mux_master_process_new_session: channel 1: request tty 0, X 0, agent 0, subsys 0, term \"xterm-256color\", cmd \"chcp.com 65001 >nul 2>&1 && PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand UABvAHcAZQByAFMAaABlAGwAbAAgAC0ATgBvAFAAcgBvAGYAaQBsAGUAIAAtAE4AbwBuAEkAbgB0AGUAcgBhAGMAdABpAHYAZQAgAC0ARQB4AGUAYwB1AHQAaQBvAG4AUABvAGwAaQBjAHkAIABVAG4AcgBlAHMAdAByAGkAYwB0AGUAZAAgAC0ARQBuAGMAbwBkAGUAZABDAG8AbQBtAGEAbgBkACAASgBnAEIAagBBAEcAZwBBAFkAdwBCAHcAQQBDADQAQQBZAHcAQgB2AEEARwAwAEEASQBBAEEAMgBBAEQAVQBBAE0AQQBBAHcAQQBEAEUAQQBJAEEAQQArAEEAQwBBAEEASgBBAEIAdQBBAEgAVQBBAGIAQQBCAHMAQQBBAG8AQQBKAEEAQgBsAEEASABnAEEAWgBRAEIAagBBAEYAOABBAGQAdwBCAHkAQQBHAEUAQQBjAEEAQgB3AEEARwBVAEEAYwBnAEIAZgBBAEgATQBBAGQAQQBCAHkAQQBDAEEAQQBQAFEAQQBnAEEAQwBRAEEAYQBRAEIAdQBBAEgAQQBBAGQAUQBCADAAQQBDAEEAQQBmAEEAQQBnAEEARQA4AEEAZABRAEIAMABBAEMAMABBAFUAdwBCADAAQQBIAEkAQQBhAFEAQgB1AEEARwBjAEEAQwBnAEEAawBBAEgATQBBAGMAQQBCAHMAQQBHAGsAQQBkAEEAQgBmAEEASABBAEEAWQBRAEIAeQBBAEgAUQBBAGMAdwBBAGcAQQBEADAAQQBJAEEAQQBrAEE\r\ndebug3: mux_master_process_new_session: got fds stdin 6, stdout 7, stderr 8\r\ndebug2: fd 6 setting O_NONBLOCK\r\ndebug2: fd 7 setting O_NONBLOCK\r\ndebug2: fd 8 setting O_NONBLOCK\r\ndebug1: channel 2: new [client-session]\r\ndebug2: mux_master_process_new_session: channel_new: 2 linked to control channel 1\r\ndebug2: channel 2: send open\r\ndebug3: send packet: type 90\r\ndebug3: receive packet: type 80\r\ndebug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0\r\ndebug3: receive packet: type 91\r\ndebug2: channel_input_open_confirmation: channel 2: callback start\r\ndebug2: client_session2_setup: id 2\r\ndebug1: Sending environment.\r\ndebug1: Sending env LC_ADDRESS = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_NAME = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_MONETARY = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_PAPER = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LANG = en_US.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_IDENTIFICATION = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_TELEPHONE = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_MEASUREMENT = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_TIME = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_NUMERIC = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending command: chcp.com 65001 >nul 2>&1 && PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand UABvAHcAZQByAFMAaABlAGwAbAAgAC0ATgBvAFAAcgBvAGYAaQBsAGUAIAAtAE4AbwBuAEkAbgB0AGUAcgBhAGMAdABpAHYAZQAgAC0ARQB4AGUAYwB1AHQAaQBvAG4AUABvAGwAaQBjAHkAIABVAG4AcgBlAHMAdAByAGkAYwB0AGUAZAAgAC0ARQBuAGMAbwBkAGUAZABDAG8AbQBtAGEAbgBkACAASgBnAEIAagBBAEcAZwBBAFkAdwBCAHcAQQBDADQAQQBZAHcAQgB2AEEARwAwAEEASQBBAEEAMgBBAEQAVQBBAE0AQQBBAHcAQQBEAEUAQQBJAEEAQQArAEEAQwBBAEEASgBBAEIAdQBBAEgAVQBBAGIAQQBCAHMAQQBBAG8AQQBKAEEAQgBsAEEASABnAEEAWgBRAEIAagBBAEYAOABBAGQAdwBCAHkAQQBHAEUAQQBjAEEAQgB3AEEARwBVAEEAYwBnAEIAZgBBAEgATQBBAGQAQQBCAHkAQQBDAEEAQQBQAFEAQQBnAEEAQwBRAEEAYQBRAEIAdQBBAEgAQQBBAGQAUQBCADAAQQBDAEEAQQBmAEEAQQBnAEEARQA4AEEAZABRAEIAMABBAEMAMABBAFUAdwBCADAAQQBIAEkAQQBhAFEAQgB1AEEARwBjAEEAQwBnAEEAawBBAEgATQBBAGMAQQBCAHMAQQBHAGsAQQBkAEEAQgBmAEEASABBAEEAWQBRAEIAeQBBAEgAUQBBAGMAdwBBAGcAQQBEADAAQQBJAEEAQQBr\r\ndebug2: channel 2: request exec confirm 1\r\ndebug3: send packet: type 98\r\ndebug3: mux_session_confirm: sending success reply\r\ndebug2: channel_input_open_confirmation: channel 2: callback done\r\ndebug2: channel 2: open confirm rwindow 0 rmax 32768\r\ndebug2: channel 2: rcvd adjust 2097152\r\ndebug3: receive packet: type 99\r\ndebug2: channel_input_status_confirm: type 99 id 2\r\ndebug2: exec request accepted on channel 2\r\ndebug2: channel 2: read<=0 rfd 6 len 0\r\ndebug2: channel 2: read failed\r\ndebug2: channel 2: chan_shutdown_read (i0 o0 sock -1 wfd 6 efd 8 [write])\r\ndebug2: channel 2: input open -> drain\r\ndebug2: channel 2: ibuf empty\r\ndebug2: channel 2: send eof\r\ndebug3: send packet: type 96\r\ndebug2: channel 2: input drain -> closed\r\ndebug2: channel 2: rcvd adjust 16384\r\ndebug2: channel 2: rcvd ext data 19\r\nAt line:1 char:26\r\ndebug2: channel 2: written 19 to efd 8\r\ndebug2: channel 2: rcvd ext data 77\r\ndebug2: channel 2: rcvd ext data 31\r\ndebug2: channel 2: rcvd ext data 68\r\ndebug2: channel 2: rcvd ext data 87\r\ndebug2: channel 2: rcvd ext data 48\r\n+ chcp.com 65001 >nul 2>&1 && PowerShell -NoProfile -NonInteractive -Ex ...\r\n+                          ~~\r\nThe token '&&' is not a valid statement separator in this version.\r\n    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException\r\n    + FullyQualifiedErrorId : InvalidEndOfLine\r\ndebug2: channel 2: written 311 to efd 8\r\ndebug2: channel 2: rcvd ext data 3\r\n \r\ndebug2: channel 2: written 3 to efd 8\r\ndebug3: receive packet: type 98\r\ndebug1: client_input_channel_req: channel 2 rtype eow@openssh.com reply 0\r\ndebug2: channel 2: rcvd eow\r\ndebug3: receive packet: type 96\r\ndebug2: channel 2: rcvd eof\r\ndebug2: channel 2: output open -> drain\r\ndebug2: channel 2: obuf empty\r\ndebug2: channel 2: chan_shutdown_write (i3 o1 sock -1 wfd 7 efd 8 [write])\r\ndebug2: channel 2: output drain -> closed\r\ndebug2: channel 2: send close\r\ndebug3: send packet: type 97\r\ndebug3: channel 2: will not send data after close\r\ndebug3: receive packet: type 98\r\ndebug1: client_input_channel_req: channel 2 rtype exit-status reply 0\r\ndebug3: mux_exit_message: channel 2: exit message, exitval 1\r\ndebug3: receive packet: type 97\r\ndebug2: channel 2: rcvd close\r\ndebug3: channel 2: will not send data after close\r\ndebug2: channel 2: is dead\r\ndebug2: channel 2: gc: notify user\r\ndebug3: mux_master_session_cleanup_cb: entering for channel 2\r\ndebug2: channel 1: rcvd close\r\ndebug2: channel 1: output open -> drain\r\ndebug2: channel 1: chan_shutdown_read (i0 o1 sock 5 wfd 5 efd -1 [closed])\r\ndebug2: channel 1: input open -> closed\r\ndebug2: channel 2: gc: user detached\r\ndebug2: channel 2: is dead\r\ndebug2: channel 2: garbage collecting\r\ndebug1: channel 2: free: client-session, nchannels 3\r\ndebug3: channel 2: status: The following connections are open:\r\n  #1 mux-control (t16 nr0 i3/0 o1/16 e[closed]/0 fd 5/5/-1 sock 5 cc -1)\r\n  #2 client-session (t4 r0 i3/0 o3/0 e[write]/0 fd -1/-1/8 sock -1 cc -1)\r\n\r\ndebug2: channel 1: obuf empty\r\ndebug2: channel 1: chan_shutdown_write (i3 o1 sock 5 wfd 5 efd -1 [closed])\r\ndebug2: channel 1: output drain -> closed\r\ndebug2: channel 1: is dead (local)\r\ndebug2: channel 1: gc: notify user\r\ndebug3: mux_master_control_cleanup_cb: entering for channel 1\r\ndebug2: channel 1: gc: user detached\r\ndebug2: channel 1: is dead (local)\r\ndebug2: channel 1: garbage collecting\r\ndebug1: channel 1: free: mux-control, nchannels 2\r\ndebug3: channel 1: status: The following connections are open:\r\n  #1 mux-control (t16 nr0 i3/0 o3/0 e[closed]/0 fd 5/5/-1 sock 5 cc -1)\r\n\r\ndebug2: set_control_persist_exit_time: schedule exit in 60 seconds\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}```
</div>
</div>
</p>
<p>Does sbdy know where these errors are coming from?
The error the that's actually thrown is even larger than what I posted in the second codesnippet. For some reason it won't paste the full version though.
(Maybe I do have to change the language from JS, but to what I don't know)</p>
<p>Thanks for you're help.</p>
<p>EDIT1:</p>
<p>I did find that line in the logs:</p>
```<XXX.XX.XXX.XXX> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="Administrator"' -o ConnectTimeout=10 -o ControlPath=/home/ansiblenode/.ansible/cp/c7e43effac XXX.XX.XXX.XXX 'chcp.com 65001 >nul 2>&1 && PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand

 Failed to connect to the host via ssh: At line:1 char:26 + chcp.com 65001 >nul 2>&1 && PowerShell -NoProfile -NonInteractive -Ex ...
```

This appears to be what the error is pointing to, but I lack the knowledge to know where to find and how to change and to what value.

EDIT2:
As far as I understand it has something to do with cmd vs PowerShell Commands.
Maybe there is something to change in addition to what is outlined in the officle ansible docs.

I was under the impression that when working with ansible one should change the default shell to PowerShell?

答:
I forgot that for previous reasons I had specified the

```<code>ansible_shell_type=cmd
</code>```

in the hosts file for windows-servers

```<code>ansible_shell_type=powershell
</code>```

now works just fine.

Maybe would've gotten to the solution faster if I didn't convince myself that I had done another thestrun after changing the default shell to powershell.

Maybe it helps someone else to remember to check their hosts file.

Body:
I installed and configured ansible as per the instructions on the official documentation. The setup is as follows:

WIN 10 Enterprise VM Host runs the ansible control node which is
Ubuntu 20.04LTS VM in VirtualBox.
This control node then SSHs to a Linux server (this works just fine) or a Windows Server 2019.

As mentioned before the connection has to happen via SSH and not winrm.
After the setup yesterday I was able to win_ping the server.  After that I changed the standard shell from cmd to PowerShell. win_pinged again and shut the VM off.

Today no changes whatsoever, I started the VM and for starters wanted to verify the connection and got an error back:

ansiblenode@ansiblenode-VirtualBox:~$ ansible windows-servers -m win_ping

[DEPRECATION WARNING]: The TRANSFORM_INVALID_GROUP_CHARS settings is set to allow bad characters in group names by default, this will
change, but still be user configurable on deprecation. This feature will be removed in version 2.10. Deprecation warnings can be
disabled by setting deprecation_warnings=False in ansible.cfg.
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
windowsTest_host1 | FAILED! => {
    "changed": false,
    "module_stderr": "At line:1 char:26\r\n+ chcp.com 65001 >nul 2>&1 && PowerShell -NoProfile -NonInteractive -Ex ...\r\n+                          ~~\r\nThe token '&&' is not a valid statement separator in this version.\r\n    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException\r\n    + FullyQualifiedErrorId : InvalidEndOfLine\r\n \r\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Detailed Version with -vvvv:

windowsTest_host1 | FAILED! => {
    "changed": false,
    "module_stderr": "OpenSSH_8.2p1 Ubuntu-4ubuntu0.4, OpenSSL 1.1.1f  31 Mar 2020\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug2: resolve_canonicalize: hostname XXX.XX.XXX.XXX is address\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: Control socket \"/home/ansiblenode/.ansible/cp/c7e43effac\" does not exist\r\ndebug2: ssh_connect_direct\r\ndebug1: Connecting to XXX.XX.XXX.XXX [XXX.XX.XXX.XXX] port 22.\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: fd 3 clearing O_NONBLOCK\r\ndebug1: Connection established.\r\ndebug3: timeout: 9980 ms remain after connect\r\ndebug1: identity file /home/ansiblenode/.ssh/id_rsa type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_rsa-cert type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_dsa type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_dsa-cert type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ecdsa type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ecdsa-cert type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ecdsa_sk type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ecdsa_sk-cert type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ed25519 type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ed25519-cert type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ed25519_sk type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_ed25519_sk-cert type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_xmss type -1\r\ndebug1: identity file /home/ansiblenode/.ssh/id_xmss-cert type -1\r\ndebug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.4\r\ndebug1: Remote protocol version 2.0, remote software version OpenSSH_for_Windows_8.6\r\ndebug1: match: OpenSSH_for_Windows_8.6 pat OpenSSH* compat 0x04000000\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: Authenticating to XXX.XX.XXX.XXX:22 as 'Administrator'\r\ndebug3: hostkeys_foreach: reading file \"/home/ansiblenode/.ssh/known_hosts\"\r\ndebug3: record_hostkey: found key type ECDSA in file /home/ansiblenode/.ssh/known_hosts:1\r\ndebug3: load_hostkeys: loaded 1 keys from XXX.XX.XXX.XXX\r\ndebug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521\r\ndebug3: send packet: type 20\r\ndebug1: SSH2_MSG_KEXINIT sent\r\ndebug3: receive packet: type 20\r\ndebug1: SSH2_MSG_KEXINIT received\r\ndebug2: local client KEXINIT proposal\r\ndebug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c\r\ndebug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,sk-ssh-ed25519@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa\r\ndebug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com\r\ndebug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com\r\ndebug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1\r\ndebug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1\r\ndebug2: compression ctos: zlib@openssh.com,zlib,none\r\ndebug2: compression stoc: zlib@openssh.com,zlib,none\r\ndebug2: languages ctos: \r\ndebug2: languages stoc: \r\ndebug2: first_kex_follows 0 \r\ndebug2: reserved 0 \r\ndebug2: peer server KEXINIT proposal\r\ndebug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256\r\ndebug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519\r\ndebug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com\r\ndebug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com\r\ndebug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1\r\ndebug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1\r\ndebug2: compression ctos: none,zlib@openssh.com\r\ndebug2: compression stoc: none,zlib@openssh.com\r\ndebug2: languages ctos: \r\ndebug2: languages stoc: \r\ndebug2: first_kex_follows 0 \r\ndebug2: reserved 0 \r\ndebug1: kex: algorithm: curve25519-sha256\r\ndebug1: kex: host key algorithm: ecdsa-sha2-nistp256\r\ndebug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: zlib@openssh.com\r\ndebug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: zlib@openssh.com\r\ndebug3: send packet: type 30\r\ndebug1: expecting SSH2_MSG_KEX_ECDH_REPLY\r\ndebug3: receive packet: type 31\r\ndebug1: Server host key: XXXXXXXXXX
 hostkeys_foreach: reading file \"/home/ansiblenode/.ssh/known_hosts\"\r\ndebug3: record_hostkey: found key type ECDSA in file /home/ansiblenode/.ssh/known_hosts:1\r\ndebug3: load_hostkeys: loaded 1 keys from XXX.XX.XXX.XXX\r\ndebug1: Host 'XXX.XX.XXX.XXX' is known and matches the ECDSA host key.\r\ndebug1: Found key in /home/ansiblenode/.ssh/known_hosts:1\r\ndebug3: send packet: type 21\r\ndebug2: set_newkeys: mode 1\r\ndebug1: rekey out after 134217728 blocks\r\ndebug1: SSH2_MSG_NEWKEYS sent\r\ndebug1: expecting SSH2_MSG_NEWKEYS\r\ndebug3: receive packet: type 21\r\ndebug1: SSH2_MSG_NEWKEYS received\r\ndebug2: set_newkeys: mode 0\r\ndebug1: rekey in after 134217728 blocks\r\ndebug1: Will attempt key: /home/ansiblenode/.ssh/id_rsa \r\ndebug1: Will attempt key: /home/ansiblenode/.ssh/id_dsa \r\ndebug1: Will attempt key: /home/ansiblenode/.ssh/id_ecdsa \r\ndebug1: Will attempt key: /home/ansiblenode/.ssh/id_ecdsa_sk \r\ndebug1: Will attempt key: /home/ansiblenode/.ssh/id_ed25519 \r\ndebug1: Will attempt key: /home/ansiblenode/.ssh/id_ed25519_sk \r\ndebug1: Will attempt key: /home/ansiblenode/.ssh/id_xmss \r\ndebug2: pubkey_prepare: done\r\ndebug3: send packet: type 5\r\ndebug3: receive packet: type 7\r\ndebug1: SSH2_MSG_EXT_INFO received\r\ndebug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,webauthn-sk-ecdsa-sha2-nistp256@openssh.com>\r\ndebug3: receive packet: type 6\r\ndebug2: service_accept: ssh-userauth\r\ndebug1: SSH2_MSG_SERVICE_ACCEPT received\r\ndebug3: send packet: type 50\r\ndebug3: receive packet: type 51\r\ndebug1: Authentications that can continue: publickey,password,keyboard-interactive\r\ndebug3: start over, passed a different list publickey,password,keyboard-interactive\r\ndebug3: preferred gssapi-with-mic,publickey,keyboard-interactive,password\r\ndebug3: authmethod_lookup publickey\r\ndebug3: remaining preferred: keyboard-interactive,password\r\ndebug3: authmethod_is_enabled publickey\r\ndebug1: Next authentication method: publickey\r\ndebug1: Trying private key: /home/ansiblenode/.ssh/id_rsa\r\ndebug3: no such identity: /home/ansiblenode/.ssh/id_rsa: No such file or directory\r\ndebug1: Trying private key: /home/ansiblenode/.ssh/id_dsa\r\ndebug3: no such identity: /home/ansiblenode/.ssh/id_dsa: No such file or directory\r\ndebug1: Trying private key: /home/ansiblenode/.ssh/id_ecdsa\r\ndebug3: no such identity: /home/ansiblenode/.ssh/id_ecdsa: No such file or directory\r\ndebug1: Trying private key: /home/ansiblenode/.ssh/id_ecdsa_sk\r\ndebug3: no such identity: /home/ansiblenode/.ssh/id_ecdsa_sk: No such file or directory\r\ndebug1: Trying private key: /home/ansiblenode/.ssh/id_ed25519\r\ndebug3: no such identity: /home/ansiblenode/.ssh/id_ed25519: No such file or directory\r\ndebug1: Trying private key: /home/ansiblenode/.ssh/id_ed25519_sk\r\ndebug3: no such identity: /home/ansiblenode/.ssh/id_ed25519_sk: No such file or directory\r\ndebug1: Trying private key: /home/ansiblenode/.ssh/id_xmss\r\ndebug3: no such identity: /home/ansiblenode/.ssh/id_xmss: No such file or directory\r\ndebug2: we did not send a packet, disable method\r\ndebug3: authmethod_lookup keyboard-interactive\r\ndebug3: remaining preferred: password\r\ndebug3: authmethod_is_enabled keyboard-interactive\r\ndebug1: Next authentication method: keyboard-interactive\r\ndebug2: userauth_kbdint\r\ndebug3: send packet: type 50\r\ndebug2: we sent a keyboard-interactive packet, wait for reply\r\ndebug3: receive packet: type 51\r\ndebug1: Authentications that can continue: publickey,password,keyboard-interactive\r\ndebug3: userauth_kbdint: disable: no info_req_seen\r\ndebug2: we did not send a packet, disable method\r\ndebug3: authmethod_lookup password\r\ndebug3: remaining preferred: \r\ndebug3: authmethod_is_enabled password\r\ndebug1: Next authentication method: password\r\ndebug3: send packet: type 50\r\ndebug2: we sent a password packet, wait for reply\r\ndebug3: receive packet: type 52\r\ndebug1: Enabling compression at level 6.\r\ndebug1: Authentication succeeded (password).\r\nAuthenticated to XXX.XX.XXX.XXX ([XXX.XX.XXX.XXX]:22).\r\ndebug1: setting up multiplex master socket\r\ndebug3: muxserver_listen: temporary control path /home/ansiblenode/.ansible/cp/c7e43effac.bc3nbpSV394EBUJr\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug3: fd 4 is O_NONBLOCK\r\ndebug3: fd 4 is O_NONBLOCK\r\ndebug1: channel 0: new [/home/ansiblenode/.ansible/cp/c7e43effac]\r\ndebug3: muxserver_listen: mux listener channel 0 fd 4\r\ndebug2: fd 3 setting TCP_NODELAY\r\ndebug3: ssh_packet_set_tos: set IP_TOS 0x08\r\ndebug1: control_persist_detach: backgrounding master process\r\ndebug2: control_persist_detach: background process is 3177\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug1: forking to background\r\ndebug1: Entering interactive session.\r\ndebug1: pledge: id\r\ndebug2: set_control_persist_exit_time: schedule exit in 60 seconds\r\ndebug1: multiplexing control connection\r\ndebug2: fd 5 setting O_NONBLOCK\r\ndebug3: fd 5 is O_NONBLOCK\r\ndebug1: channel 1: new [mux-control]\r\ndebug3: channel_post_mux_listener: new mux channel 1 fd 5\r\ndebug3: mux_master_read_cb: channel 1: hello sent\r\ndebug2: set_control_persist_exit_time: cancel scheduled exit\r\ndebug3: mux_master_read_cb: channel 1 packet type 0x00000001 len 4\r\ndebug2: mux_master_process_hello: channel 1 slave version 4\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_master_read_cb: channel 1 packet type 0x10000004 len 4\r\ndebug2: mux_master_process_alive_check: channel 1: alive check\r\ndebug3: mux_client_request_alive: done pid = 3179\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_master_read_cb: channel 1 packet type 0x10000002 len 3122\r\ndebug2: mux_master_process_new_session: channel 1: request tty 0, X 0, agent 0, subsys 0, term \"xterm-256color\", cmd \"chcp.com 65001 >nul 2>&1 && PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand UABvAHcAZQByAFMAaABlAGwAbAAgAC0ATgBvAFAAcgBvAGYAaQBsAGUAIAAtAE4AbwBuAEkAbgB0AGUAcgBhAGMAdABpAHYAZQAgAC0ARQB4AGUAYwB1AHQAaQBvAG4AUABvAGwAaQBjAHkAIABVAG4AcgBlAHMAdAByAGkAYwB0AGUAZAAgAC0ARQBuAGMAbwBkAGUAZABDAG8AbQBtAGEAbgBkACAASgBnAEIAagBBAEcAZwBBAFkAdwBCAHcAQQBDADQAQQBZAHcAQgB2AEEARwAwAEEASQBBAEEAMgBBAEQAVQBBAE0AQQBBAHcAQQBEAEUAQQBJAEEAQQArAEEAQwBBAEEASgBBAEIAdQBBAEgAVQBBAGIAQQBCAHMAQQBBAG8AQQBKAEEAQgBsAEEASABnAEEAWgBRAEIAagBBAEYAOABBAGQAdwBCAHkAQQBHAEUAQQBjAEEAQgB3AEEARwBVAEEAYwBnAEIAZgBBAEgATQBBAGQAQQBCAHkAQQBDAEEAQQBQAFEAQQBnAEEAQwBRAEEAYQBRAEIAdQBBAEgAQQBBAGQAUQBCADAAQQBDAEEAQQBmAEEAQQBnAEEARQA4AEEAZABRAEIAMABBAEMAMABBAFUAdwBCADAAQQBIAEkAQQBhAFEAQgB1AEEARwBjAEEAQwBnAEEAawBBAEgATQBBAGMAQQBCAHMAQQBHAGsAQQBkAEEAQgBmAEEASABBAEEAWQBRAEIAeQBBAEgAUQBBAGMAdwBBAGcAQQBEADAAQQBJAEEAQQBrAEE\r\ndebug3: mux_master_process_new_session: got fds stdin 6, stdout 7, stderr 8\r\ndebug2: fd 6 setting O_NONBLOCK\r\ndebug2: fd 7 setting O_NONBLOCK\r\ndebug2: fd 8 setting O_NONBLOCK\r\ndebug1: channel 2: new [client-session]\r\ndebug2: mux_master_process_new_session: channel_new: 2 linked to control channel 1\r\ndebug2: channel 2: send open\r\ndebug3: send packet: type 90\r\ndebug3: receive packet: type 80\r\ndebug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0\r\ndebug3: receive packet: type 91\r\ndebug2: channel_input_open_confirmation: channel 2: callback start\r\ndebug2: client_session2_setup: id 2\r\ndebug1: Sending environment.\r\ndebug1: Sending env LC_ADDRESS = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_NAME = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_MONETARY = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_PAPER = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LANG = en_US.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_IDENTIFICATION = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_TELEPHONE = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_MEASUREMENT = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_TIME = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending env LC_NUMERIC = de_DE.UTF-8\r\ndebug2: channel 2: request env confirm 0\r\ndebug3: send packet: type 98\r\ndebug1: Sending command: chcp.com 65001 >nul 2>&1 && PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand UABvAHcAZQByAFMAaABlAGwAbAAgAC0ATgBvAFAAcgBvAGYAaQBsAGUAIAAtAE4AbwBuAEkAbgB0AGUAcgBhAGMAdABpAHYAZQAgAC0ARQB4AGUAYwB1AHQAaQBvAG4AUABvAGwAaQBjAHkAIABVAG4AcgBlAHMAdAByAGkAYwB0AGUAZAAgAC0ARQBuAGMAbwBkAGUAZABDAG8AbQBtAGEAbgBkACAASgBnAEIAagBBAEcAZwBBAFkAdwBCAHcAQQBDADQAQQBZAHcAQgB2AEEARwAwAEEASQBBAEEAMgBBAEQAVQBBAE0AQQBBAHcAQQBEAEUAQQBJAEEAQQArAEEAQwBBAEEASgBBAEIAdQBBAEgAVQBBAGIAQQBCAHMAQQBBAG8AQQBKAEEAQgBsAEEASABnAEEAWgBRAEIAagBBAEYAOABBAGQAdwBCAHkAQQBHAEUAQQBjAEEAQgB3AEEARwBVAEEAYwBnAEIAZgBBAEgATQBBAGQAQQBCAHkAQQBDAEEAQQBQAFEAQQBnAEEAQwBRAEEAYQBRAEIAdQBBAEgAQQBBAGQAUQBCADAAQQBDAEEAQQBmAEEAQQBnAEEARQA4AEEAZABRAEIAMABBAEMAMABBAFUAdwBCADAAQQBIAEkAQQBhAFEAQgB1AEEARwBjAEEAQwBnAEEAawBBAEgATQBBAGMAQQBCAHMAQQBHAGsAQQBkAEEAQgBmAEEASABBAEEAWQBRAEIAeQBBAEgAUQBBAGMAdwBBAGcAQQBEADAAQQBJAEEAQQBr\r\ndebug2: channel 2: request exec confirm 1\r\ndebug3: send packet: type 98\r\ndebug3: mux_session_confirm: sending success reply\r\ndebug2: channel_input_open_confirmation: channel 2: callback done\r\ndebug2: channel 2: open confirm rwindow 0 rmax 32768\r\ndebug2: channel 2: rcvd adjust 2097152\r\ndebug3: receive packet: type 99\r\ndebug2: channel_input_status_confirm: type 99 id 2\r\ndebug2: exec request accepted on channel 2\r\ndebug2: channel 2: read<=0 rfd 6 len 0\r\ndebug2: channel 2: read failed\r\ndebug2: channel 2: chan_shutdown_read (i0 o0 sock -1 wfd 6 efd 8 [write])\r\ndebug2: channel 2: input open -> drain\r\ndebug2: channel 2: ibuf empty\r\ndebug2: channel 2: send eof\r\ndebug3: send packet: type 96\r\ndebug2: channel 2: input drain -> closed\r\ndebug2: channel 2: rcvd adjust 16384\r\ndebug2: channel 2: rcvd ext data 19\r\nAt line:1 char:26\r\ndebug2: channel 2: written 19 to efd 8\r\ndebug2: channel 2: rcvd ext data 77\r\ndebug2: channel 2: rcvd ext data 31\r\ndebug2: channel 2: rcvd ext data 68\r\ndebug2: channel 2: rcvd ext data 87\r\ndebug2: channel 2: rcvd ext data 48\r\n+ chcp.com 65001 >nul 2>&1 && PowerShell -NoProfile -NonInteractive -Ex ...\r\n+                          ~~\r\nThe token '&&' is not a valid statement separator in this version.\r\n    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException\r\n    + FullyQualifiedErrorId : InvalidEndOfLine\r\ndebug2: channel 2: written 311 to efd 8\r\ndebug2: channel 2: rcvd ext data 3\r\n \r\ndebug2: channel 2: written 3 to efd 8\r\ndebug3: receive packet: type 98\r\ndebug1: client_input_channel_req: channel 2 rtype eow@openssh.com reply 0\r\ndebug2: channel 2: rcvd eow\r\ndebug3: receive packet: type 96\r\ndebug2: channel 2: rcvd eof\r\ndebug2: channel 2: output open -> drain\r\ndebug2: channel 2: obuf empty\r\ndebug2: channel 2: chan_shutdown_write (i3 o1 sock -1 wfd 7 efd 8 [write])\r\ndebug2: channel 2: output drain -> closed\r\ndebug2: channel 2: send close\r\ndebug3: send packet: type 97\r\ndebug3: channel 2: will not send data after close\r\ndebug3: receive packet: type 98\r\ndebug1: client_input_channel_req: channel 2 rtype exit-status reply 0\r\ndebug3: mux_exit_message: channel 2: exit message, exitval 1\r\ndebug3: receive packet: type 97\r\ndebug2: channel 2: rcvd close\r\ndebug3: channel 2: will not send data after close\r\ndebug2: channel 2: is dead\r\ndebug2: channel 2: gc: notify user\r\ndebug3: mux_master_session_cleanup_cb: entering for channel 2\r\ndebug2: channel 1: rcvd close\r\ndebug2: channel 1: output open -> drain\r\ndebug2: channel 1: chan_shutdown_read (i0 o1 sock 5 wfd 5 efd -1 [closed])\r\ndebug2: channel 1: input open -> closed\r\ndebug2: channel 2: gc: user detached\r\ndebug2: channel 2: is dead\r\ndebug2: channel 2: garbage collecting\r\ndebug1: channel 2: free: client-session, nchannels 3\r\ndebug3: channel 2: status: The following connections are open:\r\n  #1 mux-control (t16 nr0 i3/0 o1/16 e[closed]/0 fd 5/5/-1 sock 5 cc -1)\r\n  #2 client-session (t4 r0 i3/0 o3/0 e[write]/0 fd -1/-1/8 sock -1 cc -1)\r\n\r\ndebug2: channel 1: obuf empty\r\ndebug2: channel 1: chan_shutdown_write (i3 o1 sock 5 wfd 5 efd -1 [closed])\r\ndebug2: channel 1: output drain -> closed\r\ndebug2: channel 1: is dead (local)\r\ndebug2: channel 1: gc: notify user\r\ndebug3: mux_master_control_cleanup_cb: entering for channel 1\r\ndebug2: channel 1: gc: user detached\r\ndebug2: channel 1: is dead (local)\r\ndebug2: channel 1: garbage collecting\r\ndebug1: channel 1: free: mux-control, nchannels 2\r\ndebug3: channel 1: status: The following connections are open:\r\n  #1 mux-control (t16 nr0 i3/0 o3/0 e[closed]/0 fd 5/5/-1 sock 5 cc -1)\r\n\r\ndebug2: set_control_persist_exit_time: schedule exit in 60 seconds\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Does sbdy know where these errors are coming from?
The error the that's actually thrown is even larger than what I posted in the second codesnippet. For some reason it won't paste the full version though.
(Maybe I do have to change the language from JS, but to what I don't know)

Thanks for you're help.

EDIT1:

I did find that line in the logs:

<XXX.XX.XXX.XXX> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="Administrator"' -o ConnectTimeout=10 -o ControlPath=/home/ansiblenode/.ansible/cp/c7e43effac XXX.XX.XXX.XXX 'chcp.com 65001 >nul 2>&1 && PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand

 Failed to connect to the host via ssh: At line:1 char:26 + chcp.com 65001 >nul 2>&1 && PowerShell -NoProfile -NonInteractive -Ex ...

This appears to be what the error is pointing to, but I lack the knowledge to know where to find and how to change and to what value.

EDIT2:
As far as I understand it has something to do with cmd vs PowerShell Commands.
Maybe there is something to change in addition to what is outlined in the officle ansible docs.

I was under the impression that when working with ansible one should change the default shell to PowerShell?

Body:
I forgot that for previous reasons I had specified the

ansible_shell_type=cmd

in the hosts file for windows-servers

ansible_shell_type=powershell

now works just fine.

Maybe would've gotten to the solution faster if I didn't convince myself that I had done another thestrun after changing the default shell to powershell.

Maybe it helps someone else to remember to check their hosts file.


来源: stackexchange

问:
Unable to assume role and validate the specified targetGroupArn
I'd like to create and deploy a cluster using terraform ecs_service, but am unable to do so. My terraform applys always fail around IAM roles, which I don't clearly understand. Specifically, the error message is:

InvalidParametersException: Unable to assume role and validate the specified targetGroupArn. Please verify that the ECS service role being passed has the proper permissions.

And I have found that:

When I have iam_role specified in ecs_service, ECS complains that I need to use a service-linked role.

When I have iam_role commented in ecs_service, ECS complains that the assumed role cannot validate the targetGroupArn.

My terraform spans a bunch of files. I pulled what feels like the relevant portions out below. Though I have seen a few similar problems posted, none have provided an actionable solution that solves the dilemma above, for me.

```<code>## ALB

resource "aws_alb" "frankly_internal_alb" {
    name = "frankly-internal-alb"
    internal = false
    security_groups = ["${aws_security_group.frankly_internal_alb_sg.id}"]
    subnets = ["${aws_subnet.frankly_public_subnet_a.id}", "${aws_subnet.frankly_public_subnet_b.id}"]
}

resource "aws_alb_listener" "frankly_alb_listener" {
    load_balancer_arn = "${aws_alb.frankly_internal_alb.arn}"

    port = "8080"
    protocol = "HTTP"

    default_action {
        target_group_arn = "${aws_alb_target_group.frankly_internal_target_group.arn}"
        type = "forward"
    }
}

## Target Group

resource "aws_alb_target_group" "frankly_internal_target_group" {
    name = "internal-target-group"
    port = 8080
    protocol = "HTTP"
    vpc_id = "${aws_vpc.frankly_vpc.id}"

    health_check {
        healthy_threshold = 5
        unhealthy_threshold = 2
        timeout = 5
    }
}

## IAM

resource "aws_iam_role" "frankly_ec2_role" {
  name               = "franklyec2role"
  assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "ec2.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
EOF
}

resource "aws_iam_role" "frankly_ecs_role" {
  name = "frankly_ecs_role"

  assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "ecs.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
EOF
}

# aggresively add permissions...
resource "aws_iam_policy" "frankly_ecs_policy" {
  name        = "frankly_ecs_policy"
  description = "A test policy"

  policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "ec2:*",
        "ecs:*",
        "ecr:*",
        "autoscaling:*",
        "elasticloadbalancing:*",
        "application-autoscaling:*",
        "logs:*",
        "tag:*",
        "resource-groups:*"
      ],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}
EOF
}

resource "aws_iam_role_policy_attachment" "frankly_ecs_attach" {
  role       = "${aws_iam_role.frankly_ecs_role.name}"
  policy_arn = "${aws_iam_policy.frankly_ecs_policy.arn}"
}

## ECS

resource "aws_ecs_cluster" "frankly_ec2" {
    name = "frankly_ec2_cluster"
}

resource "aws_ecs_task_definition" "frankly_ecs_task" {
  family                = "service"
  container_definitions = "${file("terraform/task-definitions/search.json")}"

  volume {
    name      = "service-storage"

    docker_volume_configuration {
      scope         = "shared"
      autoprovision = true
    }
  }

  placement_constraints {
    type       = "memberOf"
    expression = "attribute:ecs.availability-zone in [us-east-1]"
  }
}

resource "aws_ecs_service" "frankly_ecs_service" {
  name            = "frankly_ecs_service"
  cluster         = "${aws_ecs_cluster.frankly_ec2.id}"
  task_definition = "${aws_ecs_task_definition.frankly_ecs_task.arn}"
  desired_count   = 2
  iam_role        = "${aws_iam_role.frankly_ecs_role.arn}"
  depends_on      = ["aws_iam_role.frankly_ecs_role", "aws_alb.frankly_internal_alb", "aws_alb_target_group.frankly_internal_target_group"]

  # network_configuration = {
  #   subnets = ["${aws_subnet.frankly_private_subnet_a.id}", "${aws_subnet.frankly_private_subnet_b}"]
  #   security_groups = ["${aws_security_group.frankly_internal_alb_sg}", "${aws_security_group.frankly_service_sg}"]
  #   # assign_public_ip = true
  # }

  ordered_placement_strategy {
    type  = "binpack"
    field = "cpu"
  }

  load_balancer {
    target_group_arn = "${aws_alb_target_group.frankly_internal_target_group.arn}"
    container_name   = "search-svc"
    container_port   = 8080
  }

  placement_constraints {
    type       = "memberOf"
    expression = "attribute:ecs.availability-zone in [us-east-1]"
  }
}
</code>```

答: For me, I was using output of previous command. But the output was empty hence target group arn was empty in the create service call.</p>

ContentLicense: CC BY-SA 4.0

Body:
I'd like to create and deploy a cluster using terraform ecs_service, but am unable to do so. My terraform applys always fail around IAM roles, which I don't clearly understand. Specifically, the error message is:

InvalidParametersException: Unable to assume role and validate the specified targetGroupArn. Please verify that the ECS service role being passed has the proper permissions.

And I have found that:

When I have iam_role specified in ecs_service, ECS complains that I need to use a service-linked role.

When I have iam_role commented in ecs_service, ECS complains that the assumed role cannot validate the targetGroupArn.

My terraform spans a bunch of files. I pulled what feels like the relevant portions out below. Though I have seen a few similar problems posted, none have provided an actionable solution that solves the dilemma above, for me.

## ALB

resource "aws_alb" "frankly_internal_alb" {
    name = "frankly-internal-alb"
    internal = false
    security_groups = ["${aws_security_group.frankly_internal_alb_sg.id}"]
    subnets = ["${aws_subnet.frankly_public_subnet_a.id}", "${aws_subnet.frankly_public_subnet_b.id}"]
}

resource "aws_alb_listener" "frankly_alb_listener" {
    load_balancer_arn = "${aws_alb.frankly_internal_alb.arn}"

    port = "8080"
    protocol = "HTTP"

    default_action {
        target_group_arn = "${aws_alb_target_group.frankly_internal_target_group.arn}"
        type = "forward"
    }
}

## Target Group

resource "aws_alb_target_group" "frankly_internal_target_group" {
    name = "internal-target-group"
    port = 8080
    protocol = "HTTP"
    vpc_id = "${aws_vpc.frankly_vpc.id}"

    health_check {
        healthy_threshold = 5
        unhealthy_threshold = 2
        timeout = 5
    }
}

## IAM

resource "aws_iam_role" "frankly_ec2_role" {
  name               = "franklyec2role"
  assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "ec2.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
EOF
}

resource "aws_iam_role" "frankly_ecs_role" {
  name = "frankly_ecs_role"

  assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "ecs.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
EOF
}

# aggresively add permissions...
resource "aws_iam_policy" "frankly_ecs_policy" {
  name        = "frankly_ecs_policy"
  description = "A test policy"

  policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "ec2:*",
        "ecs:*",
        "ecr:*",
        "autoscaling:*",
        "elasticloadbalancing:*",
        "application-autoscaling:*",
        "logs:*",
        "tag:*",
        "resource-groups:*"
      ],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}
EOF
}

resource "aws_iam_role_policy_attachment" "frankly_ecs_attach" {
  role       = "${aws_iam_role.frankly_ecs_role.name}"
  policy_arn = "${aws_iam_policy.frankly_ecs_policy.arn}"
}

## ECS

resource "aws_ecs_cluster" "frankly_ec2" {
    name = "frankly_ec2_cluster"
}

resource "aws_ecs_task_definition" "frankly_ecs_task" {
  family                = "service"
  container_definitions = "${file("terraform/task-definitions/search.json")}"

  volume {
    name      = "service-storage"

    docker_volume_configuration {
      scope         = "shared"
      autoprovision = true
    }
  }

  placement_constraints {
    type       = "memberOf"
    expression = "attribute:ecs.availability-zone in [us-east-1]"
  }
}

resource "aws_ecs_service" "frankly_ecs_service" {
  name            = "frankly_ecs_service"
  cluster         = "${aws_ecs_cluster.frankly_ec2.id}"
  task_definition = "${aws_ecs_task_definition.frankly_ecs_task.arn}"
  desired_count   = 2
  iam_role        = "${aws_iam_role.frankly_ecs_role.arn}"
  depends_on      = ["aws_iam_role.frankly_ecs_role", "aws_alb.frankly_internal_alb", "aws_alb_target_group.frankly_internal_target_group"]

  # network_configuration = {
  #   subnets = ["${aws_subnet.frankly_private_subnet_a.id}", "${aws_subnet.frankly_private_subnet_b}"]
  #   security_groups = ["${aws_security_group.frankly_internal_alb_sg}", "${aws_security_group.frankly_service_sg}"]
  #   # assign_public_ip = true
  # }

  ordered_placement_strategy {
    type  = "binpack"
    field = "cpu"
  }

  load_balancer {
    target_group_arn = "${aws_alb_target_group.frankly_internal_target_group.arn}"
    container_name   = "search-svc"
    container_port   = 8080
  }

  placement_constraints {
    type       = "memberOf"
    expression = "attribute:ecs.availability-zone in [us-east-1]"
  }
}


问:
How can I concatenate two JSON files to produce a single JSON result?
I am getting two results, one which is in form of json and the other just as text from different sources. I need to append the results together, I have tried some methods but seems I am not getting it right.

Here is my first code and the json result attached below

```<code>const posts = fetch('https://jsonplaceholder.typicode.com/posts')
  .then(response => response.json())
  .then(json => console.log(json.slice(0, 2)))
</code>```

Here is the json result

```<code>[
  {
    userId: 1,
    id: 1,
    title: 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit',
    body: 'quia et suscipit\n' +
      'suscipit recusandae consequuntur expedita et cum\n' +
      'reprehenderit molestiae ut ut quas totam\n' +
      'nostrum rerum est autem sunt rem eveniet architecto'
  },
  {
    userId: 1,
    id: 2,
    title: 'qui est esse',
    body: 'est rerum tempore vitae\n' +
      'sequi sint nihil reprehenderit dolor beatae ea dolores neque\n' +
      'fugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\n' +
      'qui aperiam non debitis possimus qui neque nisi nulla'
  }
]
</code>```

Here is the second code and the json result attached below

```<code>function generateNames(){
  for (let i = 0; i < 2; i++) {
    const playersName = fetch('https://www.balldontlie.io/api/v1/players?per_page=5')
      .then(response => response.json())
      .then(json => console.log(json['data'][i]['first_name']))
  }
}
generateNames()
</code>```

Here is the result

```<code>Ike
Ron
</code>```

What I am trying to achieve is something of this format

```<code>[
  {
    first_name: 'Ike',
    userId: 1,
    id: 1,
    title: 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit',
    body: 'quia et suscipit\n' +
      'suscipit recusandae consequuntur expedita et cum\n' +
      'reprehenderit molestiae ut ut quas totam\n' +
      'nostrum rerum est autem sunt rem eveniet architecto'
  },
  {
    first_name: 'Ron',
    id: 2,
    title: 'qui est esse',
    body: 'est rerum tempore vitae\n' +
      'sequi sint nihil reprehenderit dolor beatae ea dolores neque\n' +
      'fugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\n' +
      'qui aperiam non debitis possimus qui neque nisi nulla'
  }
]
</code>```

答:
try this

```<code>function AddNames(json1) {
  var json2 = ["Ike", "Ron"];
  var i = 0;
  json1.forEach((element) => {
    element.first_name = json2[i];
    if ((i == 1)) return;
    i++;
  });
}

var posts = fetch("https://jsonplaceholder.typicode.com/posts")
  .then((response) => {
    return response.json();
  })
  .then((json) => {
    AddNames(json.slice(0, 2));
  });
</code>```

or you can use this syntax

```<code>async function getPosts(num) {
  let posts = await fetch('https://jsonplaceholder.typicode.com/posts')
  .then(response => response.json())
  .then(json => {
    return json.slice(0,num);
   })
  return posts;
}

async function AddNames() {
  var json1= await getPosts(2);
  var json2 = ["Ike", "Ron"];
  var i = 0;
   json1.forEach((element) => {
     element.first_name = json2[i];
     if ((i == 1)) return;
     i++;
   });
   console.log(json1);
}

AddNames();
</code>```

Body:
I am getting two results, one which is in form of json and the other just as text from different sources. I need to append the results together, I have tried some methods but seems I am not getting it right.

Here is my first code and the json result attached below

const posts = fetch('https://jsonplaceholder.typicode.com/posts')
  .then(response => response.json())
  .then(json => console.log(json.slice(0, 2)))

Here is the json result

[
  {
    userId: 1,
    id: 1,
    title: 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit',
    body: 'quia et suscipit\n' +
      'suscipit recusandae consequuntur expedita et cum\n' +
      'reprehenderit molestiae ut ut quas totam\n' +
      'nostrum rerum est autem sunt rem eveniet architecto'
  },
  {
    userId: 1,
    id: 2,
    title: 'qui est esse',
    body: 'est rerum tempore vitae\n' +
      'sequi sint nihil reprehenderit dolor beatae ea dolores neque\n' +
      'fugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\n' +
      'qui aperiam non debitis possimus qui neque nisi nulla'
  }
]

Here is the second code and the json result attached below

function generateNames(){
  for (let i = 0; i < 2; i++) {
    const playersName = fetch('https://www.balldontlie.io/api/v1/players?per_page=5')
      .then(response => response.json())
      .then(json => console.log(json['data'][i]['first_name']))
  }
}
generateNames()

Here is the result

Ike
Ron

What I am trying to achieve is something of this format

[
  {
    first_name: 'Ike',
    userId: 1,
    id: 1,
    title: 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit',
    body: 'quia et suscipit\n' +
      'suscipit recusandae consequuntur expedita et cum\n' +
      'reprehenderit molestiae ut ut quas totam\n' +
      'nostrum rerum est autem sunt rem eveniet architecto'
  },
  {
    first_name: 'Ron',
    id: 2,
    title: 'qui est esse',
    body: 'est rerum tempore vitae\n' +
      'sequi sint nihil reprehenderit dolor beatae ea dolores neque\n' +
      'fugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\n' +
      'qui aperiam non debitis possimus qui neque nisi nulla'
  }
]

Body:
try this

function AddNames(json1) {
  var json2 = ["Ike", "Ron"];
  var i = 0;
  json1.forEach((element) => {
    element.first_name = json2[i];
    if ((i == 1)) return;
    i++;
  });
}

var posts = fetch("https://jsonplaceholder.typicode.com/posts")
  .then((response) => {
    return response.json();
  })
  .then((json) => {
    AddNames(json.slice(0, 2));
  });

or you can use this syntax

async function getPosts(num) {
  let posts = await fetch('https://jsonplaceholder.typicode.com/posts')
  .then(response => response.json())
  .then(json => {
    return json.slice(0,num);
   })
  return posts;
}

async function AddNames() {
  var json1= await getPosts(2);
  var json2 = ["Ike", "Ron"];
  var i = 0;
   json1.forEach((element) => {
     element.first_name = json2[i];
     if ((i == 1)) return;
     i++;
   });
   console.log(json1);
}

AddNames();


问:
How to hide IntelliJ IDEA's "Background tasks" window using the keyboard?
IntelliJ IDEA's Background Tasks window can be shown by following Window → Background Tasks → Show in the main menu.

But once it's open, I can only hide the window by clicking on the top right dash button, which requires reaching for the pointing device.

Is there a way to hide IntelliJ IDEAD's Background Tasks window using only the keyboard (either by an existing keymap, or by navigating through the main menu)?

答: It's not possible at the moment, feel free to vote for the corresponding issue.</p>


问:
Merge two tables with same columns and get the column value in specific table
I have two tables that have the same column of position and salary.

Table_a

ID
Name
Position
Salary

1
Peter
Sale
10,000

2
Tom
IT
15,000

3
Jane
Sale
12,000

4
Mary
PR
8,000

5
John
IT
14,000

Table_b

ID
Position
Salary

1
Driver
9,000

2
Manager
20,000

4
Sale
13,000

I would like to merge two tables that the output is based on the Position value and Salary value of Table_b.

Output

ID
Name
Position
Salary

1
Peter
Driver
9,000

2
Tom
Manager
20,000

3
Jane
Sale
12,000

4
Mary
Sale
13,000

5
John
IT
14,000

Please give me an advice how can I query and get the above output.

答:
SELECT id,
       t1.name,
       COALESCE(t2.position, t1.position),
       COALESCE(t2.salary, t1.salary)
FROM table_a t1
LEFT JOIN table_b t2 USING (id)
```


问:
Bulk sending to multiple recipients docusign php
Good morning, I'm trying to send a document to multiple recipients, but it's only sending to one, and it doesn't generate any error!

```<code>$signers = [];
    # Create the signer recipient model
    $signer1 = new \DocuSign\eSign\Model\Signer([
        'email' => $this->email_signatario, 'name' => $this->nome_signatario,
        'recipient_id' => "1", 'routing_order' => "5"]);

    array_push( $signers, $signer1 );

    $routing_order_count = 6;

    foreach ( $this->emails_adicionais as $endereco_adicional ) {
      $signer = new \DocuSign\eSign\Model\Signer([
        'email' => $endereco_adicional, 'name' => $this->nome_signatario . "_$routing_order_count",
        'recipient_id' => $routing_order_count, 'routing_order' => $routing_order_count]);

        array_push( $signers, $signer );
        $routing_order_count++;
    }$sign_here1 =  new \DocuSign\eSign\Model\SignHere([
        'anchor_string' => '*signature_1*', 'anchor_units' => 'pixels',
        'anchor_y_offset' => '10', 'anchor_x_offset' => '20']);
    $sign_here2 =  new \DocuSign\eSign\Model\SignHere([
        'anchor_string' => '/sn1/', 'anchor_units' =>  'pixels',
        'anchor_y_offset' => '10', 'anchor_x_offset' => '20']);

    # Add the tabs model (including the sign_here tabs) to the signer
    # The Tabs object wants arrays of the different field/tab types
    foreach ( $signers as $signer ) {
      $signer->setTabs( new \DocuSign\eSign\Model\Tabs([
        'sign_here_tabs' => [$sign_here1, $sign_here2]]));
    }

    # Add the recipients to the envelope object
    $recipients =  new \DocuSign\eSign\Model\Recipients([
        'signers' => $signers, 'recipient_count' => count( $signers ), 'carbon_copies' => [$cc1,$cc2,$cc3,$cc4]]);
    $envelope_definition->setRecipients($recipients);
</code>```

This is the code I use to add signers and copies.

If anyone has an example of multiple submissions, please send them, thank you!

答:
You have this code:

```<code>$routing_order_count++;
</code>```

So you are generating recipients with routing order 1,2,3,4 etc.

The first one will get it right away, but the second one will only get it after the first one completes to sign it.

So what you see is expected.

If you want them to all get it at once - change it to :

```<code>$routing_order_count = 1
</code>```

Body:
Good morning, I'm trying to send a document to multiple recipients, but it's only sending to one, and it doesn't generate any error!

$signers = [];
    # Create the signer recipient model
    $signer1 = new \DocuSign\eSign\Model\Signer([
        'email' => $this->email_signatario, 'name' => $this->nome_signatario,
        'recipient_id' => "1", 'routing_order' => "5"]);

    array_push( $signers, $signer1 );

    $routing_order_count = 6;

    foreach ( $this->emails_adicionais as $endereco_adicional ) {
      $signer = new \DocuSign\eSign\Model\Signer([
        'email' => $endereco_adicional, 'name' => $this->nome_signatario . "_$routing_order_count",
        'recipient_id' => $routing_order_count, 'routing_order' => $routing_order_count]);

        array_push( $signers, $signer );
        $routing_order_count++;
    }$sign_here1 =  new \DocuSign\eSign\Model\SignHere([
        'anchor_string' => '*signature_1*', 'anchor_units' => 'pixels',
        'anchor_y_offset' => '10', 'anchor_x_offset' => '20']);
    $sign_here2 =  new \DocuSign\eSign\Model\SignHere([
        'anchor_string' => '/sn1/', 'anchor_units' =>  'pixels',
        'anchor_y_offset' => '10', 'anchor_x_offset' => '20']);

    # Add the tabs model (including the sign_here tabs) to the signer
    # The Tabs object wants arrays of the different field/tab types
    foreach ( $signers as $signer ) {
      $signer->setTabs( new \DocuSign\eSign\Model\Tabs([
        'sign_here_tabs' => [$sign_here1, $sign_here2]]));
    }

    # Add the recipients to the envelope object
    $recipients =  new \DocuSign\eSign\Model\Recipients([
        'signers' => $signers, 'recipient_count' => count( $signers ), 'carbon_copies' => [$cc1,$cc2,$cc3,$cc4]]);
    $envelope_definition->setRecipients($recipients);

This is the code I use to add signers and copies.

If anyone has an example of multiple submissions, please send them, thank you!

Body:
You have this code:

$routing_order_count++;

So you are generating recipients with routing order 1,2,3,4 etc.

The first one will get it right away, but the second one will only get it after the first one completes to sign it.

So what you see is expected.

If you want them to all get it at once - change it to :

$routing_order_count = 1


问:
Easiest way to append non-directory component to Python Path?
Several SO questions ask how to append a directory to a pathlib.Path object. That's not this question.

I would like to use a Path object a prefix for a series of files in a single directory, like this:

```<code>2022-01-candidates.csv
2022-01-resumes.zip
2022-02-candidates.csv
2022-02-resumes.zip
</code>```

Ideally, I would construct Path objects for the 2022-01 and 2022-02 components, and then append -candidates.csv and -resumes.zip to each.

Unfortunately, Path appears to only understand appending subdirectores, not extensions to existing path names.

The only workaround that I see is something like p.parent / (p.name + "-candidates.csv"). Although that's not so bad, it's clumsy and this pattern is common for me.  I wonder whether I'm missing a more streamlined method. (For example, why isn't there a + concatenation operator?)

Path.with_suffix() requires that the suffix start with a dot, so that doesn't work.

答:
As you mentioned, using the division operator always creates a sub-directory, and with_suffix is only for extensions. You could use with_path to edit the filename:

import pathlib
path = pathlib.Path("2022-01")
path.with_name(f"{path.name}-candidates.csv")
```

Body:
Several SO questions ask how to append a directory to a pathlib.Path object. That's not this question.

I would like to use a Path object a prefix for a series of files in a single directory, like this:

2022-01-candidates.csv
2022-01-resumes.zip
2022-02-candidates.csv
2022-02-resumes.zip

Ideally, I would construct Path objects for the 2022-01 and 2022-02 components, and then append -candidates.csv and -resumes.zip to each.

Unfortunately, Path appears to only understand appending subdirectores, not extensions to existing path names.

The only workaround that I see is something like p.parent / (p.name + "-candidates.csv"). Although that's not so bad, it's clumsy and this pattern is common for me.  I wonder whether I'm missing a more streamlined method. (For example, why isn't there a + concatenation operator?)

Path.with_suffix() requires that the suffix start with a dot, so that doesn't work.


问:
Click two elements at the same time by clicking one button with javascript
Is it possible to click one button and simultaneously click another element. Like I click a button to show an image and simultaneously let something else appear which would also appear when clicking on it</p>

答:
As our friend Said says, is possible, just I think if would be better if you name classes instead of ID because is a better practice</p>
```<code>   <button class="button">Do something here</button>
   <button class="button">And here</button>
   <script>
     const button = document.getElementsByClassName ('button');
     button.addEventListener('click', () => {
     // do whatever you want here
        });
   </script>
</code>```

Body:
As our friend Said says, is possible, just I think if would be better if you name classes instead of ID because is a better practice

   <button class="button">Do something here</button>
   <button class="button">And here</button>
   <script>
     const button = document.getElementsByClassName ('button');
     button.addEventListener('click', () => {
     // do whatever you want here
        });
   </script>


问:
Getting 1 testcase wrong using this method
There are three Hill Stations named A, B, and C. There are flights between each pair of Hill Stations. A one-way flight between the Hill Stations A and B (and vice versa) takes a hours, a one-way flight between Hill Stations B and C (and vice versa) takes b hours, a one-way flight between the Hill Stations C and A (and vice versa) takes c hours.

You are a tourist and you want to visit each of the hill stations exactly once. You can start at any of the stations. Find the minimum time taken to visit each Hill Station exactly once.

And this is the code I wrote:

from itertools import combinations
ipl = [int(i) for i in input().split()]
l = combinations(ipl,2)
for i in l:
    print(i)
print(sum(min(l)))
```

Can someone help me with the reason which leads me to get one test case wrong?

答:
You're getting the minimum path, and calculating its sum. But you want to get all the sums, and then get the minimum of those sums.</p>
```<code>print(min(sum(path) for path in l))
</code>```

Body:
There are three Hill Stations named A, B, and C. There are flights between each pair of Hill Stations. A one-way flight between the Hill Stations A and B (and vice versa) takes a hours, a one-way flight between Hill Stations B and C (and vice versa) takes b hours, a one-way flight between the Hill Stations C and A (and vice versa) takes c hours.

You are a tourist and you want to visit each of the hill stations exactly once. You can start at any of the stations. Find the minimum time taken to visit each Hill Station exactly once.

And this is the code I wrote:

from itertools import combinations
ipl = [int(i) for i in input().split()]
l = combinations(ipl,2)
for i in l:
    print(i)
print(sum(min(l)))

Can someone help me with the reason which leads me to get one test case wrong?

Body:
You're getting the minimum path, and calculating its sum. But you want to get all the sums, and then get the minimum of those sums.

print(min(sum(path) for path in l))


问:
Using visual studio 2019 in dark mode with high contrast in Windows 10
Is there anyone who is using Visual studio 2019 in dark mode with High contrast?
If yes, can you tell me exactly how to do that?

As far as I know, Visual studio doesn't have an option to use High contrast for dark mode (it's there only for blue theme which I don't want).

And also if I change my Windows OS to use high contrast mode and come back to Visual studio, and then by default VS adjusts itself to high contrast but it's very poor to read (it reads like plain white text on a black blackground devoid of any other colors)

I was wondering if there's something in VS 2019 which is similar to Visual studio code high contrast mode or maybe IntelliJ Idea which is very user friendly and serves the purpose.

Thanks in advance.

答:
The most clean way is to modify the current used theme as this is the behaviour Visual Studio executes when changing themes in the settings.

Close all instances of Visual Studio 2019 / 2022

Press Ctlr+R and run regedit

In the node tree, expand HKEY_USERS

Press File -> Load Hive...

In the dialog navigate to C:\Users\<UserName>\AppData\Local\Microsoft\VisualStudio\16.0_XXXXXXXX or if you use Visual Studio 2022 C:\Users\<UserName>\AppData\Local\Microsoft\VisualStudio\17.0_XXXXXXXX and load the privateregistry.bin file. It will ask you to give some name, for example, "vs2019". (before proceeding a backup of the privateregistry.bin file is advised)

Navigate to HKEY_USERS\vs20xx\Software\Microsoft\VisualStudio\1x.0_xxxxxxxx\ApplicationPrivateSettings\Microsoft\VisualStudio

There, set the value of ColorTheme and ColorThemeNew to 0*System.String*1ded0138-47ce-435e-84ef-9ec1f439b749 and 0*System.String*{1ded0138-47ce-435e-84ef-9ec1f439b749} respectively. If you wish any other color please check HKEY_USERS\vs20xx\Software\Microsoft\VisualStudio\1x.0_????????_Config\Themes\ for the theme IDs.

Click on the loaded node in the node tree named vs20xx and then File -> Unload Hive...

This will change the setting in Visual Studio to use a different theme instead of changing the themes themselves and will most likely be persistent after updates.


问:
Android - listView's click gives index out of bounds exception
I have a ListView where i am storing some URLs and i load the contents of the listview using an arraylist which is of the type ArrayList<HashMap<String,String>>. I am trying to handle the click of this list using the following code snippet.

```<code>        listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
                long arg3) {
            System.out.println("List Clicked..." + pos);
            System.out.println("URL: " + listView.getItemAtPosition(pos).toString());
        }
    });
</code>```

The first SOP is executed correctly, but the second print statement is giving me the following error
ERROR/AndroidRuntime(382): java.lang.IndexOutOfBoundsException: Invalid location 0, size is 0

Here is my adapter's getView()

```<code>        @Override
    public View getView(int position, View arg1, ViewGroup arg2) {
        View v = arg1;

        if (v == null)
        {
            LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.list_row, null);

        }
        t1=(TextView) v.findViewById(R.id.text1);
        HashMap<String, String> values = storedURLArrayList.get(position);
        t1.setText(values.get("value"));
        return v;
    }
</code>```

Please help.

答:
@Shafi can't give answer in such short code, but many assumptions possible here:

Based on your above comment that you are using custom adapter to load it, check your getCount() method, there may be return 0 statement, it is wrong , you need to return the size of either array or arraylist.

For example:

```<code>public int getCount() {
        return listData.size();
       // listData is the arrayList that you want to bind to listview
    }
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have a ListView where i am storing some URLs and i load the contents of the listview using an arraylist which is of the type ArrayList<HashMap<String,String>>. I am trying to handle the click of this list using the following code snippet.

        listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
                long arg3) {
            System.out.println("List Clicked..." + pos);
            System.out.println("URL: " + listView.getItemAtPosition(pos).toString());
        }
    });

The first SOP is executed correctly, but the second print statement is giving me the following error
ERROR/AndroidRuntime(382): java.lang.IndexOutOfBoundsException: Invalid location 0, size is 0

Here is my adapter's getView()

        @Override
    public View getView(int position, View arg1, ViewGroup arg2) {
        View v = arg1;

        if (v == null)
        {
            LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.list_row, null);

        }
        t1=(TextView) v.findViewById(R.id.text1);
        HashMap<String, String> values = storedURLArrayList.get(position);
        t1.setText(values.get("value"));
        return v;
    }

Please help.

Body:
@Shafi can't give answer in such short code, but many assumptions possible here:

Based on your above comment that you are using custom adapter to load it, check your getCount() method, there may be return 0 statement, it is wrong , you need to return the size of either array or arraylist.

For example:

public int getCount() {
        return listData.size();
       // listData is the arrayList that you want to bind to listview
    }


问:
upload file to web server error 6 php
I am trying to upload a file from a php form.It wont work on linux server. I want it to move it to a subdir '/uploads' from where the file is.

I get the below error when executing the page by echo the $_FILES["file_upload"]['error']; to get the error number.

It returns :

```<code>Upload failed with error code 6
</code>```

Does anyone know what this error stands for?

Form Code :

```<code><!DOCTYPE html>
<html>
<body>

<form action="upload.php" method="post" enctype="multipart/form-data">
    Select File to upload:
    <input type="file" name="file_upload" id="file_upload">
    <input type="submit" value="Upload File" name="submit">
</form>

</body>
</html>
</code>```

upload.php :

```<code><?php

    if(isset($_POST['submit']))
    {
        if($_FILES['file_upload']['name'] != "" )
    {
            $target_dir = "uploads/";
            $target_file = $target_dir . basename($_FILES["file_upload"]["name"]);
            $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
            $uploadOk = 1;
    }
    else
    {
        die("No file specified!");
    }

    // Check if file already exists
    if (file_exists($target_file)) {
        echo "Sorry, file already exists.";
        $uploadOk = 0;
    }

    // Check file size
    if ($_FILES["file_upload"]["size"] > 500000) {
        echo "Sorry, your file is too large.";
        $uploadOk = 0;
    }

    // Allow certain file formats
    if($imageFileType != "txt" && $imageFileType != "xls" && $imageFileType != "xlsx")
     {
        echo "Sorry, only TXT, XLS, XLSX files are allowed.";
        $uploadOk = 0;
    }

    if ($_FILES["file_upload"]['error'] !== UPLOAD_ERR_OK) {
       die("Upload failed with error code " . $_FILES['file_upload']['error']);
    }
    // Check if $uploadOk is set to 0 by an error
    if ($uploadOk == 0) {
        echo "Sorry, your file was not uploaded.";
    // if everything is ok, try to upload file
    } else {
        if (move_uploaded_file($_FILES["file_upload"]["tmp_name"], $target_file)) {
            echo "The file ". basename( $_FILES["file_upload"]["name"]). " has been uploaded.";
        } else {
            echo "Sorry, there was an error uploading your file.";
        }
    }
    }
    ?>
</code>```

I already search for this problem and find the solution Here. But not undestand properly.

I also given full permission 777 to /uploads folder.
Any help will be greatly appreciated. Thanks

答:
Edit your php.ini file , and update the below changes and restart apache or iis

like below -

error_log = "C:\Windows\new_folder\php-5.6.1_errors.log"

upload_tmp_dir = "C:\Windows\new_folder"

Title: upload file to web server error 6 php

Body:
I am trying to upload a file from a php form.It wont work on linux server. I want it to move it to a subdir '/uploads' from where the file is.

I get the below error when executing the page by echo the $_FILES["file_upload"]['error']; to get the error number.

It returns :

Upload failed with error code 6

Does anyone know what this error stands for?

Form Code :

<!DOCTYPE html>

<form action="upload.php" method="post" enctype="multipart/form-data">
    Select File to upload:
    <input type="file" name="file_upload" id="file_upload">
    <input type="submit" value="Upload File" name="submit">
</form>

upload.php :

<?php

    if(isset($_POST['submit']))
    {
        if($_FILES['file_upload']['name'] != "" )
    {
            $target_dir = "uploads/";
            $target_file = $target_dir . basename($_FILES["file_upload"]["name"]);
            $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
            $uploadOk = 1;
    }
    else
    {
        die("No file specified!");
    }

    // Check if file already exists
    if (file_exists($target_file)) {
        echo "Sorry, file already exists.";
        $uploadOk = 0;
    }

    // Check file size
    if ($_FILES["file_upload"]["size"] > 500000) {
        echo "Sorry, your file is too large.";
        $uploadOk = 0;
    }

    // Allow certain file formats
    if($imageFileType != "txt" && $imageFileType != "xls" && $imageFileType != "xlsx")
     {
        echo "Sorry, only TXT, XLS, XLSX files are allowed.";
        $uploadOk = 0;
    }

    if ($_FILES["file_upload"]['error'] !== UPLOAD_ERR_OK) {
       die("Upload failed with error code " . $_FILES['file_upload']['error']);
    }
    // Check if $uploadOk is set to 0 by an error
    if ($uploadOk == 0) {
        echo "Sorry, your file was not uploaded.";
    // if everything is ok, try to upload file
    } else {
        if (move_uploaded_file($_FILES["file_upload"]["tmp_name"], $target_file)) {
            echo "The file ". basename( $_FILES["file_upload"]["name"]). " has been uploaded.";
        } else {
            echo "Sorry, there was an error uploading your file.";
        }
    }
    }
    ?>

I already search for this problem and find the solution Here. But not undestand properly.

I also given full permission 777 to /uploads folder.
Any help will be greatly appreciated. Thanks


问:
Create a new variable in pre-existing column
I am a beginner of R and I would like to create a new variable "Overall" and "Profit (sum of profits of 1st and 2nd term per company) under each column</p>
```<code>Company Term Profit
   A    1st   300
   B    1st   400
   A    2nd   500
   B    2nd   200
</code>```

答:
Take a look at my solution.</p>
```<code>library(dplyr)

test_data = read.table(
    text = "
Company Term Profit
   A    1st   300
   B    1st   400
   A    2nd   500
   B    2nd   200
",
    header = TRUE,

)

test_data = test_data %>%
    left_join(
        test_data %>%
        group_by(Company) %>%
        summarise(Overall = sum(Profit)),
        by = "Company"
    )

OP:
  Company Term Profit Overall
1       A  1st    300     800
2       B  1st    400     600
3       A  2nd    500     800
4       B  2nd    200     600
</code>```

Body:
I am a beginner of R and I would like to create a new variable "Overall" and "Profit (sum of profits of 1st and 2nd term per company) under each column

Company Term Profit
   A    1st   300
   B    1st   400
   A    2nd   500
   B    2nd   200

Body:
Take a look at my solution.

library(dplyr)

test_data = read.table(
    text = "
Company Term Profit
   A    1st   300
   B    1st   400
   A    2nd   500
   B    2nd   200
",
    header = TRUE,

)

test_data = test_data %>%
    left_join(
        test_data %>%
        group_by(Company) %>%
        summarise(Overall = sum(Profit)),
        by = "Company"
    )

OP:
  Company Term Profit Overall
1       A  1st    300     800
2       B  1st    400     600
3       A  2nd    500     800
4       B  2nd    200     600


问:
Deploy my laravel project to shared hosting with github actions
please I added GitHub action main.yml to my Laravel project to the shared hosting for automated deployment. The deployment worked okay but the project was placed outside public_html because of the path I specified - server_dir: /home5/app/public_html/, I want the project files to be put into the public_html folder. Below is the code:

```<code>name: Glory Deploy Production
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
jobs:
  web-deploy:
    name: Deploying...
    runs-on: ubuntu-latest
    steps:
    - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
      with:
        php-version: '8.0'
    - uses: actions/checkout@v2.3.2
    - name: Copy .env
      run: php -r "file_exists('.env') || copy('.env.example', '.env');"
    - name: Install Dependencies
      run: composer update --ignore-platform-reqs
    - name: Generate key
      run: php artisan key:generate
    - name: Directory Permissions
      run: chmod -R 777 storage bootstrap/cache
    - name:  Sync files
      uses: SamKirkland/FTP-Deploy-Action@4.0.0
      with:
        server: ${{ secrets.server }}
        username: ${{ secrets.username}}
        password: ${{ secrets.password}}
        server_dir: /home5/app/public_html/
</code>```

Please can I modify the path pointing to the public_html? How?

答:
I am considering your ftp user is a default user that has root path

```<code>server_dir: "public_html/"
</code>```

If your user not has the root path you must consider its path until  public_html

Body:
please I added GitHub action main.yml to my Laravel project to the shared hosting for automated deployment. The deployment worked okay but the project was placed outside public_html because of the path I specified - server_dir: /home5/app/public_html/, I want the project files to be put into the public_html folder. Below is the code:

name: Glory Deploy Production
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
jobs:
  web-deploy:
    name: Deploying...
    runs-on: ubuntu-latest
    steps:
    - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
      with:
        php-version: '8.0'
    - uses: actions/checkout@v2.3.2
    - name: Copy .env
      run: php -r "file_exists('.env') || copy('.env.example', '.env');"
    - name: Install Dependencies
      run: composer update --ignore-platform-reqs
    - name: Generate key
      run: php artisan key:generate
    - name: Directory Permissions
      run: chmod -R 777 storage bootstrap/cache
    - name:  Sync files
      uses: SamKirkland/FTP-Deploy-Action@4.0.0
      with:
        server: ${{ secrets.server }}
        username: ${{ secrets.username}}
        password: ${{ secrets.password}}
        server_dir: /home5/app/public_html/

Please can I modify the path pointing to the public_html? How?

Body:
I am considering your ftp user is a default user that has root path

server_dir: "public_html/"

If your user not has the root path you must consider its path until  public_html