become sudo does not works
- name: Example
hosts: rpi-server
become: yes
become_method: sudo
gather_facts: false
tasks:
- name: "Update APT repositories and cache"
apt:
update_cache: yes
force_apt_get: yes
cache_valid_time: 3600
Seems to run the update without becoming root (using sudo) Inventory configuration already set the "sudo credentials"
How to make it works? I'm trying to update an RPI where sudo su (with user pi), get root with no password
Regards and well done for the nice work
I have a similar problem, "become: yes" does not work below is my configuration
# Hosts: where our play will run and options it will run with
hosts: lab
become: yes
tasks:
- name: User test 1
become: yes
command: id -un
register: login
- debug: msg="Logged in as user {{ login.stdout }}"
- name: user test 2
command: sudo id -un
register: login
- debug: msg="Logged in as user {{ login.stdout }}"
result:
TASK [debug] *******************************************************************
ok: [lab1] => {
"msg": "Logged in as user ubuntu"
}
TASK [user test 2] *************************************************************
changed: [lab1]
TASK [debug] *******************************************************************
ok: [lab1] => {
"msg": "Logged in as user root"
}
Inventory:
[lab]
lab1 ansible_ssh_host=192.168.100.1 ansible_port=22 ansible_ssh_user=ubuntu
[lab:vars]
ansible_connection=ssh
ansible_user=ubuntu
ansible_ssh_password=1
ansible_port=22
ansible_become_password=1
I have the exact same issue as described above. The role I'm trying to deploy works just fine on another Ansible install, but not in semaphore.
I faced the same problem.
The work around for me was to clean the "Sudo Credentials" form from the related inventory, then i added ansible_become_password="{{ sudo_password_defined_in_a_vaulted_var }}" to the host vars in said inventory.
Hope this bug will be solved soon enough !
I faced the same problem! @RphCos: Thanks for sharing your solution - it worked for me.
same issue here....