Failed to lock apt fgor exclusive operation

I am trying to install httpd on a ubuntu server

but keep getting this error

any idea?

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.

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

using command

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

I want to skip the password prompt but when i use

image.png

fails

See
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

how do I not have to enter my vault password?

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

For example, export the environment variable ANSIBLE_VAULT_PASSWORD_FILE

  > cat ~/.vault_pass
  my secret vault password
  > export ANSIBLE_VAULT_PASSWORD_FILE=~/.vault_pass

  > cat vault.yml
  test_var: my decrypted test variable
  > ansible-vault encrypt vault.yml
  Encryption successful
  > cat vault.yml
  $ANSIBLE_VAULT;1.1;AES256
  31396664626266393563666663383564396130373763666461353063393663306661363237323936
  6531356261303835356538386635623232353765393935620a626438303433323139613331303461
  38393263613166383935633065613931386330313138346434343234346439643865343062663230
  3034316462633364630a353639373438633630376536373964346162353438373832326139633330
  33393963383139653930363364393664373638356266663038343961393665636634666433326535
  3462326364393361636232306130393138343635396438383661

  > cat playbook.yml
  - hosts: localhost
    vars_files:
      - vault.yml
    tasks:
      - debug:
          var: test_var
  > ansible-playbook playbook.yml
  ...
  ok: [localhost] =>
    test_var: my decrypted test variable

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

  > unset ANSIBLE_VAULT_PASSWORD_FILE
  > set | grep ANSIBLE
  > ansible-playbook playbook.yml --vault-password-file ~/.vault_pass
  ...
  ok: [localhost] =>
    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

HTH,

  -vlado