# Chrome repository setup failing on Linux Mint

**URL:** <https://forum.ansible.com/t/chrome-repository-setup-failing-on-linux-mint/4294>\
**Category:** Get Help\
**Created:** [March 10, 2024, 12:49pm UTC](https://forum.ansible.com/t/chrome-repository-setup-failing-on-linux-mint/4294 "2024-03-10T12:49:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zoliky](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/zoliky/32/2507_2.png) [@zoliky](https://forum.ansible.com/u/zoliky)\
**Post date:** [March 10, 2024, 12:49pm UTC](https://forum.ansible.com/t/chrome-repository-setup-failing-on-linux-mint/4294/1 "2024-03-10T12:49:07Z")

</div>

Hello,  
I have this code to add the Chrome repository:

```auto
- name: Add Chrome repository
  become: true
  ansible.builtin.apt_repository:
    repo: deb [arch=amd64 signed-by=/etc/apt/keyrings/linux_signing_key.pub] http://dl.google.com/linux/chrome/deb/ stable main
    state: present
    filename: google-chrome

```

It works fine on Debian 12 Bookworm but on a fresh Linux Mint install it gives this error:

> fatal [localhost]: FAILED! = {“changed”: false, “msg”: “Failed to lock directory /var/lib/apt/lists/: E: Could not get lock /var/lib/apt/lists/lock. It is held by process 42190 (python3)”

The error message is self-explanatory, however, I want to mention that this is a fresh Mint installation with only Ansible installed. Encountering such an error is concerning because the user who will execute the process may lack the expertise to troubleshoot Linux. I want the automation to ensure that everything is configured correctly immediately after installation. Is there a way to address the lock issue directly through Ansible?

Thank you.

---

<div class="post-metadata">

**Author:** ![Dustin](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dustin/32/2573_2.png) [@Dustin](https://forum.ansible.com/u/Dustin)\
**Post date:** [March 11, 2024, 11:22am UTC](https://forum.ansible.com/t/chrome-repository-setup-failing-on-linux-mint/4294/2 "2024-03-11T11:22:59Z")

</div>

Is it locked because another instance of Ansible is currently using the apt process? If so, you could do something similar to this [Stack Exchange Solution](https://stackoverflow.com/questions/44134642/how-to-retry-ansible-task-that-may-fail).

Excerpt

```yaml
- command: /usr/bin/false
  retries: 3
  delay: 3
  register: result
  until: result.rc == 0

```

Basically, run the command, register the result, and loop till the result code is 0. Or as the comments in the link suggest `until: result is not failed`.

```yaml
- name: Add Chrome repository
  become: true
  ansible.builtin.apt_repository:
    repo: deb [arch=amd64 signed-by=/etc/apt/keyrings/linux_signing_key.pub] http://dl.google.com/linux/chrome/deb/ stable main
    state: present
    filename: google-chrome
  retries: 3
  delay: 30
  register: result
  until: result is not failed

```

That will retry 3 times, waiting 30 seconds between each try. That would give other processes up to 2 minutes to finish and free up the lock.
