Ansible 1.9.4 : Failed to lock apt for exclusive operation

前端 未结 8 2608
庸人自扰
庸人自扰 2021-02-18 15:23

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

8条回答
  •  不要未来只要你来
    2021-02-18 15:56

    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 }}"
    

提交回复
热议问题