title: Ansible error Shared connection to myhost1 closed. when using raw module
body: <p>My ansible target server is SunOS.</p>
  <p>I get Ansible error <code>Shared connection to myhost1 closed.</code> when using raw module.</p>
  <p>The error does not show when i change module to <code>shell</code> however, the execution of script <code>start.sh</code> does not happen (evident from outout of <code>ps</code> command) hence i wish to use <code>raw</code></p>
  <pre><code>- name: &quot;START ADP SERVICES&quot;
    raw: &quot;source ~/.profile; sh /web/external_products/springboot/{{ vars[ environ + '_folder'] }}/veladpservice/bin/start.sh veladpservice.jar {{ vars[ environ + '_folder'] }} {{ allpass }}&quot;
  </code></pre>
  <p>Output when using <code>shell</code> module:</p>
  <pre><code>TASK [START ADAPTER SERVICES] **************************************************
  task path: /web/playbooks/automation/veladp/va_action.yml:32
  changed: [myhost1] =&gt; {&quot;changed&quot;: true, &quot;cmd&quot;: &quot;source ~/.profile; sh /web/external_products/springboot/stg/veladpservice/bin/start.sh veladpservice.jar stg WEB_USER apps_user_2021_2378 MSPW435 MSPW435 MSPW445 MSPW445 PETWEB440 Temp_45678 MSPW460 Temp_3456789012 MSPW430 Temp_1234567890 MSPW455 Temp_09876&quot;, &quot;delta&quot;: &quot;0:00:01.009433&quot;, &quot;end&quot;: &quot;2021-10-28 05:47:51.277868&quot;, &quot;rc&quot;: 0, &quot;start&quot;: &quot;2021-10-28 05:47:50.268435&quot;, &quot;stderr&quot;: &quot;&quot;, &quot;stderr_lines&quot;: [], &quot;stdout&quot;: &quot;&quot;, &quot;stdout_lines&quot;: []}
  </code></pre>
  <p>When using <code>raw</code> module:</p>
  <pre><code>TASK [START adp SERVICES] *********************************************************************************
  task path: /web/playbooks/automation/veladprestart/va_action.yml:32
  &lt;myhost1&gt; ESTABLISH SSH CONNECTION FOR USER: myuser1
  &lt;myhost1&gt; SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User=&quot;myuser1&quot;' -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPath=/home/myuser1/.ansible/cp/cc89a5347e -tt myhost1 'source ~/.profile; /web/external_products/springboot/stg/veladpservice/bin/start.sh veladpservice.jar stg MSP_WEB_USER Marsh_apps_user_2021_2378 MSPW435 MSPW435 MSPW445 MSPW445 PETWEB440 Temp_345678 MSPW460 Temp_3456789012 MSPW430 Temp_1234567890 MSPW455 Temp_0987654321'
  &lt;myhost1&gt; (0, b'', b&quot;OpenSSH_8.4p1 (CentrifyDC build 5.7.1-346) , OpenSSL 1.1.1g  21 Apr 2020\r\ndebug1: Reading configuration data /etc/centrifydc/ssh/ssh_config\r\ndebug1: /etc/centrifydc/ssh/ssh_config line 3: Applying options for *\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -&gt; '/home/myuser1/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -&gt; '/home/myuser1/.ssh/known_hosts2'\r\ndebug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\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_client_request_alive: done pid = 21893\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to myhost1 closed.\r\n&quot;)
  changed: [myhost1] =&gt; {
      &quot;changed&quot;: true,
      &quot;rc&quot;: 0,
      &quot;stderr&quot;: &quot;OpenSSH_8.4p1 (CentrifyDC build 5.7.1-346) , OpenSSL 1.1.1g  21 Apr 2020\r\ndebug1: Reading configuration data /etc/centrifydc/ssh/ssh_config\r\ndebug1: /etc/centrifydc/ssh/ssh_config line 3: Applying options for *\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -&gt; '/home/myuser1/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -&gt; '/home/myuser1/.ssh/known_hosts2'\r\ndebug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\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_client_request_alive: done pid = 21893\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to myhost1 closed.\r\n&quot;,
      &quot;stderr_lines&quot;: [
          &quot;OpenSSH_8.4p1 (CentrifyDC build 5.7.1-346) , OpenSSL 1.1.1g  21 Apr 2020&quot;,
          &quot;debug1: Reading configuration data /etc/centrifydc/ssh/ssh_config&quot;,
          &quot;debug1: /etc/centrifydc/ssh/ssh_config line 3: Applying options for *&quot;,
          &quot;debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -&gt; '/home/myuser1/.ssh/known_hosts'&quot;,
          &quot;debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -&gt; '/home/myuser1/.ssh/known_hosts2'&quot;,
          &quot;debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling&quot;,
          &quot;debug1: auto-mux: Trying existing master&quot;,
          &quot;debug2: fd 3 setting O_NONBLOCK&quot;,
          &quot;debug2: mux_client_hello_exchange: master version 4&quot;,
          &quot;debug3: mux_client_forwards: request forwardings: 0 local, 0 remote&quot;,
          &quot;debug3: mux_client_request_session: entering&quot;,
          &quot;debug3: mux_client_request_alive: entering&quot;,
          &quot;debug3: mux_client_request_alive: done pid = 21893&quot;,
          &quot;debug3: mux_client_request_session: session request sent&quot;,
          &quot;debug1: mux_client_request_session: master session id: 2&quot;,
          &quot;debug3: mux_client_read_packet: read header failed: Broken pipe&quot;,
          &quot;debug2: Received exit status from master 0&quot;,
          &quot;Shared connection to myhost1 closed.&quot;
      ],
      &quot;stdout&quot;: &quot;&quot;,
      &quot;stdout_lines&quot;: []
  }
  </code></pre>
  <p>Update post suggestion:</p>
  <p>I also tried detaching the process using <code>disown</code> like below but the <code>ps</code> still does not show the process running:</p>
  <pre><code>- name: &quot;START ADAPTER SERVICES&quot;
    shell: &quot;source ~/.profile &amp;&amp; sh /web/external_products/springboot/{{ vars[ environ + '_folder'] }}/velocityadapterservice/bin/start.sh velocityadapterservice.jar {{ vars[ environ + '_folder'] }} {{ allpass }} &amp;; disown %%&quot;
  </code></pre>
  <p><code>~/.profile</code> &amp; <code>start.sh</code> but have 744 permissions and the owner is <code>myuser1</code></p>
  <p>Note: Running the same process as is manually works!!</p>
  <p>Can you please suggest?</p>