1

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: adil                                                                                                                      
<192.168.1.15> SSH: EXEC sshpass -d11 ssh -o ServerAliveInterval=100 -o ControlPersist=2m -o 
'User="adil"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/7bf699d458 -tt 
 192.168.1.15 '/bin/sh -c '"'"'/usr/bin/python3 /home/adil/.ansible/tmp/ansible-tmp- 
 1679218469.1440735-1171472-85023283189053/AnsiballZ_command.py && sleep 0'"'"''

And after that it shows no logs, completely stuck. Any ideas?

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.