# Failed to lock apt fgor exclusive operation

**URL:** <https://forum.ansible.com/t/failed-to-lock-apt-fgor-exclusive-operation/33374>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [July 11, 2020, 3:13pm UTC](https://forum.ansible.com/t/failed-to-lock-apt-fgor-exclusive-operation/33374 "2020-07-11T15:13:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [July 11, 2020, 3:13pm UTC](https://forum.ansible.com/t/failed-to-lock-apt-fgor-exclusive-operation/33374/1 "2020-07-11T15:13:25Z")

</div>

I am trying to install httpd on a ubuntu server

but keep getting this error

 ![image.png](https://us1.discourse-cdn.com/ansible/original/2X/9/9fc0cd97f3b2ff73599c651eddbcbfb93bac9574.png)

 ![image.png](https://us1.discourse-cdn.com/ansible/original/2X/c/c212fd012036b5b90cf250a3ce5993b55c963c0a.png)

any idea?

---

<div class="post-metadata">

**Author:** ![Antony\_Stone](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Antony\_Stone](https://forum.ansible.com/u/Antony_Stone)\
**Post date:** [July 11, 2020, 3:28pm UTC](https://forum.ansible.com/t/failed-to-lock-apt-fgor-exclusive-operation/33374/2 "2020-07-11T15:28:46Z")

</div>

Obvious question, but have you checked whether any other process happens to be  
running apt at the same time (eg: a cron job checking for available updates)?

Antony.

---

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [July 11, 2020, 3:40pm UTC](https://forum.ansible.com/t/failed-to-lock-apt-fgor-exclusive-operation/33374/3 "2020-07-11T15:40:34Z")

</div>

I think its something to do with the become method  
when i do it like this it works

 ![image.png](https://us1.discourse-cdn.com/ansible/original/2X/e/e817876a94009c0297ca72cbb86487a2a208be60.png)

using command

ansible-playbook httpd.yml --ask-vault-pass

I want to skip the password prompt but when i use

![image.png](https://us1.discourse-cdn.com/ansible/original/2X/a/ae4fcae3d7db4a50506f6afa0027251c71a5d748.png)

fails

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [July 11, 2020, 3:49pm UTC](https://forum.ansible.com/t/failed-to-lock-apt-fgor-exclusive-operation/33374/4 "2020-07-11T15:49:41Z")

</div>

See  
[https://askubuntu.com/questions/1172016/can-i-keep-the-annoying-dpkg-lock-error-from-coming-back](https://askubuntu.com/questions/1172016/can-i-keep-the-annoying-dpkg-lock-error-from-coming-back)  
[https://askubuntu.com/questions/953779/programmatically-disable-apt-unattended-upgrades](https://askubuntu.com/questions/953779/programmatically-disable-apt-unattended-upgrades)

---

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [July 12, 2020, 12:06am UTC](https://forum.ansible.com/t/failed-to-lock-apt-fgor-exclusive-operation/33374/5 "2020-07-12T00:06:46Z")

</div>

how do I not have to enter my vault password?

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [July 12, 2020, 5:16am UTC](https://forum.ansible.com/t/failed-to-lock-apt-fgor-exclusive-operation/33374/6 "2020-07-12T05:16:52Z")

</div>

> How do I not have to enter my vault password?
> 
> I can only get this playbook to work with  
> ansible-playbook httpd.yml --ask-vault-pass  
> and entering my vault password  
> When I run the playbook with  
> -vault-password-file
> 
> I get  
> [WARNING]: Error in vault password file loading (default): A vault password  
> must be specified to decrypt data  
> ERROR! A vault password must be specified to decrypt data

"--vault-password-file" should work. Is it the leading double dash missing  
which causes the problem?

See "Providing Vault Passwords"  
[https://docs.ansible.com/ansible/latest/user\_guide/vault.html#providing-vault-passwords](https://docs.ansible.com/ansible/latest/user_guide/vault.html#providing-vault-passwords)

For example, export the environment variable ANSIBLE\_VAULT\_PASSWORD\_FILE

&nbsp;&nbsp;\> cat ~/.vault\_pass  
&nbsp;&nbsp;my secret vault password  
&nbsp;&nbsp;\> export ANSIBLE\_VAULT\_PASSWORD\_FILE=~/.vault\_pass

&nbsp;&nbsp;\> cat vault.yml  
&nbsp;&nbsp;test\_var: my decrypted test variable  
&nbsp;&nbsp;\> ansible-vault encrypt vault.yml  
&nbsp;&nbsp;Encryption successful  
&nbsp;&nbsp;\> cat vault.yml  
&nbsp;&nbsp;$ANSIBLE\_VAULT;1.1;AES256  
&nbsp;&nbsp;31396664626266393563666663383564396130373763666461353063393663306661363237323936  
&nbsp;&nbsp;6531356261303835356538386635623232353765393935620a626438303433323139613331303461  
&nbsp;&nbsp;38393263613166383935633065613931386330313138346434343234346439643865343062663230  
&nbsp;&nbsp;3034316462633364630a353639373438633630376536373964346162353438373832326139633330  
&nbsp;&nbsp;33393963383139653930363364393664373638356266663038343961393665636634666433326535  
&nbsp;&nbsp;3462326364393361636232306130393138343635396438383661

&nbsp;&nbsp;\> cat playbook.yml  
&nbsp;&nbsp;- hosts: localhost  
&nbsp;&nbsp;&nbsp;&nbsp;vars\_files:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- vault.yml  
&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var: test\_var  
&nbsp;&nbsp;\> ansible-playbook playbook.yml  
&nbsp;&nbsp;...  
&nbsp;&nbsp;ok: [localhost] =\>  
&nbsp;&nbsp;&nbsp;&nbsp;test\_var: my decrypted test variable

The same decryption shall also work with "--vault-password-file". Let's unset  
the environment variable first

&nbsp;&nbsp;\> unset ANSIBLE\_VAULT\_PASSWORD\_FILE  
&nbsp;&nbsp;\> set | grep ANSIBLE  
&nbsp;&nbsp;\> ansible-playbook playbook.yml --vault-password-file ~/.vault\_pass  
&nbsp;&nbsp;...  
&nbsp;&nbsp;ok: [localhost] =\>  
&nbsp;&nbsp;&nbsp;&nbsp;test\_var: my decrypted test variable

Last option is to configure the path to the file with the vault password in  
the configuration file. See "vault\_password\_file"  
[https://docs.ansible.com/ansible/latest/reference\_appendices/config.html#default-vault-password-file](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-vault-password-file)

HTH,

&nbsp;&nbsp;-vlado
