I bumped into Failed to lock apt for exclusive operation
issue:
https://github.com/geerlingguy/ansible-role-apache/issues/50
I posted a lot of details in Gi
The answer from @guaka was entirely correct for me. It lacks only one thing-- where to put become: yes
.
In the following, there are three places the become
might go. Only one of them is correct:
- name: setup nginx web server
#1 become: yes
include_role:
name: nginx
#2 become: yes
vars:
ansible_user: "{{ devops_ssh_user }}"
#3 become: yes
In position #2 you will get an unexpected parameter error, because become
is not a parameter for the include_role
module.
In position #3 the play will run, but will not execute as sudo.
Only in position #1 does become: yes
do any good. become
is a parameter for the task, not for the module. It is not a variable like ansible_user
. Just to be clear, here's a working configuration:
- name: setup nginx web server
become: yes
include_role:
name: nginx
vars:
ansible_user: "{{ devops_ssh_user }}"