Answers: <p>Answering those who could face the same problem. I solved the problem, it was due to putting the escalation method in the playbook.</p>
  <pre><code>become_method: su
  </code></pre>
  <p>Rather than it should be this</p>
  <pre><code>become: true
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2023-03-19T12:21:58.827Z
Answers: 2023-03-19T12:21:58.827Z
Answers: Muhammed Adil
Body: <p>I'm new to Ansible, I've made a playbook with only two tasks as shown below:</p>
  <pre><code>- name: Installing Kubernetes for the master node
    connection: ssh
    hosts: x.x.x.x
    become_method: su
  
    tasks:
  
      - name: installing curl 
        ansible.builtin.shell: 
          cmd: sudo apt install --yes apt-transport-https curl
        vars: 
          ansible_persistent_log_messages: True    
        register: update_curl_install_output
  
      - name: update output
        ansible.builtin.debug:
          var: update_curl_install_output.stdout_lines
  </code></pre>
  <p>My ansible.cfg:</p>
  <pre><code>[ssh_connection]
  
  ssh_args = -o ServerAliveInterval=100 -o ControlMaster=auto -o ControlPersist=2m
  enable_task_debugger = True
  </code></pre>
  <p>And running the playbook with the following command:</p>
  <pre><code>ANSIBLE_ENABLE_TASK_DEBUGGER=True ansible-playbook -vvv master-node.yaml -i inventory --extra-vars &quot;ansible_sudo_pass=managed_host_pass&quot;
  </code></pre>
  <p>The remote host is easily getting connected, but the task is getting stuck for a long while. The logs below show nothing atypicality.</p>
  <pre><code>&lt;192.168.1.15&gt; (0, b'', b'')                                                                                                                                                
  &lt;192.168.1.15&gt; ESTABLISH SSH CONNECTION FOR USER: adil                                                                                                                      
  &lt;192.168.1.15&gt; SSH: EXEC sshpass -d11 ssh -o ServerAliveInterval=100 -o ControlPersist=2m -o 
  'User=&quot;adil&quot;' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/7bf699d458 -tt 
   192.168.1.15 '/bin/sh -c '&quot;'&quot;'/usr/bin/python3 /home/adil/.ansible/tmp/ansible-tmp- 
   1679218469.1440735-1171472-85023283189053/AnsiballZ_command.py &amp;&amp; sleep 0'&quot;'&quot;''
  </code></pre>
  <p>And after that it shows no logs, completely stuck. Any ideas?</p>
  
Tags: <ansible><ubuntu>
Title: Why is Ansible task getting stuck for so long?
UserDisplayName: Muhammed Adil
ThreadText: # Why is Ansible task getting stuck for so long?
  
  (Asked by: username_0 on 2023-03-19)
  
  I'm new to Ansible, I've made a playbook with only two tasks as shown below:
  
  ```
  - name: Installing Kubernetes for the master node
    connection: ssh
    hosts: x.x.x.x
    become_method: su
  
    tasks:
  
      - name: installing curl 
        ansible.builtin.shell: 
          cmd: sudo apt install --yes apt-transport-https curl
        vars: 
          ansible_persistent_log_messages: True    
        register: update_curl_install_output
  
      - name: update output
        ansible.builtin.debug:
          var: update_curl_install_output.stdout_lines
  
  ```
  
  My ansible.cfg:
  
  ```
  [ssh_connection]
  
  ssh_args = -o ServerAliveInterval=100 -o ControlMaster=auto -o ControlPersist=2m
  enable_task_debugger = True
  
  ```
  
  And running the playbook with the following command:
  
  ```
  ANSIBLE_ENABLE_TASK_DEBUGGER=True ansible-playbook -vvv master-node.yaml -i inventory --extra-vars "ansible_sudo_pass=managed_host_pass"
  
  ```
  
  The remote host is easily getting connected, but the task is getting stuck for a long while. The logs below show nothing atypicality.
  
  ```
  <192.168.1.15> (0, b'', b'')                                                                                                                                                
  <192.168.1.15> ESTABLISH SSH CONNECTION FOR USER: username_0                                                                                                                      
  <192.168.1.15> SSH: EXEC sshpass -d11 ssh -o ServerAliveInterval=100 -o ControlPersist=2m -o 
  'User="username_0"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/7bf699d458 -tt 
   192.168.1.15 '/bin/sh -c '"'"'/usr/bin/python3 /home/username_0/.ansible/tmp/ansible-tmp- 
   1679218469.1440735-1171472-85023283189053/AnsiballZ_command.py && sleep 0'"'"''
  
  ```
  
  And after that it shows no logs, completely stuck. Any ideas?
  
  **Tags:** ansible, ubuntu
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2023-03-19. Score: 1
  
  Answering those who could face the same problem. I solved the problem, it was due to putting the escalation method in the playbook.
  
  ```
  become_method: su
  
  ```
  
  Rather than it should be this
  
  ```
  become: true
  
  ```
  
  
  ---
  
  