# How to resolve dependencies of locally downloaded packages, when package A depends on B.

**URL:** <https://forum.ansible.com/t/how-to-resolve-dependencies-of-locally-downloaded-packages-when-package-a-depends-on-b/31531>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [October 23, 2019, 7:40pm UTC](https://forum.ansible.com/t/how-to-resolve-dependencies-of-locally-downloaded-packages-when-package-a-depends-on-b/31531 "2019-10-23T19:40:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_517501](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@john\_517501](https://forum.ansible.com/u/john_517501)\
**Post date:** [October 23, 2019, 7:40pm UTC](https://forum.ansible.com/t/how-to-resolve-dependencies-of-locally-downloaded-packages-when-package-a-depends-on-b/31531/1 "2019-10-23T19:40:50Z")

</div>

I have simple playbook where trying to install the Debian packages downloaded locally in my server. This playbook runs on localhost and install the Debian packages in the same system. But this playbook gives an error **"Dependency is not satisfiable** for some of the packages even tough the dependency package is available in the local repository.

I can download all the dependencies required for the specific package in my local repository using **apt-get install --download-only package\_name**

But in my playbook, i should have a mechanism to install the dependencies first than install the actual package. This task should be dynamic, playbook should resolve the dependencies by itself for any package install.

**_When the package has dependency over another package, How the playbook resolve dynamically._**

Some of the options explored:

Using ordered indexed\_items, using gdebi… Looking for efficient Logic.

**install\_dependencies.yml**

```auto
---
- hosts: localhost
  vars:
    remote_media_directory: "/home/local_repository"
  become: yes
  tasks:
    - name: find all debian Packages
      find:
         paths:
             - "{{ remote_media_directory }}"
         file_type: file
         recurse: yes
         use_regex: yes
         patterns:
           - '.*deb$'
      register: files_matched_subdirectory

    - name: installation debian packages
      apt:
        deb: "{{ item.path }}"
      with_items: "{{ files_matched_subdirectory.files }}"
      when: ansible_distribution == "Ubuntu"

```

> ansible-playbook install\_dependencies.yml

```auto
PLAY [localhost] **********************************************************************************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************************************************************
ok: [localhost]

TASK [find all debian Packages] *******************************************************************************************************************************************************************************
ok: [localhost]

TASK [installation debian packages] ***************************************************************************************************************************************************************************
failed: [localhost] (item={u'uid': 0, u'woth': False, u'mtime': 1571850269.5720358, u'inode': 31195175, u'isgid': False, u'size': 46700, u'roth': True, u'isuid': False, u'isreg': True, u'pw_name': u'root', u'gid': 0, u'ischr': False, u'wusr': True, u'xoth': False, u'rusr': True, u'nlink': 1, u'issock': False, u'rgrp': True, u'gr_name': u'root', u'path': u'/home/local_repository/wireshark_3.0.5-1_amd64.deb', u'xusr': False, u'atime': 1571850391.3553286, u'isdir': False, u'ctime': 1571850312.2437878, u'wgrp': False, u'xgrp': False, u'dev': 2051, u'isblk': False, u'isfifo': False, u'mode': u'0644', u'islnk': False}) => {"changed": false, "item": {"atime": 1571850391.3553286, "ctime": 1571850312.2437878, "dev": 2051, "gid": 0, "gr_name": "root", "inode": 31195175, "isblk": false, "ischr": false, "isdir": false, "isfifo": false, "isgid": false, "islnk": false, "isreg": true, "issock": false, "isuid": false, "mode": "0644", "mtime": 1571850269.5720358, "nlink": 1, "path": "/home/local_repository/wireshark_3.0.5-1_amd64.deb", "pw_name": "root", "rgrp": true, "roth": true, "rusr": true, "size": 46700, "uid": 0, "wgrp": false, "woth": false, "wusr": true, "xgrp": false, "xoth": false, "xusr": false}, "msg": "Dependency is not satisfiable: wireshark-qt (= 3.0.5-1)\n"}
failed: [localhost] (item={u'uid': 0, u'woth': False, u'mtime': 1571850269.4560366, u'inode': 31195174, u'isgid': False, u'size': 3605060, u'roth': True, u'isuid': False, u'isreg': True, u'pw_name': u'root', u'gid': 0, u'ischr': False, u'wusr': True, u'xoth': False, u'rusr': True, u'nlink': 1, u'issock': False, u'rgrp': True, u'gr_name': u'root', u'path': u'/home/local_repository/wireshark-qt_3.0.5-1_amd64.deb', u'xusr': False, u'atime': 1571850394.3993108, u'isdir': False, u'ctime': 1571850312.2437878, u'wgrp': False, u'xgrp': False, u'dev': 2051, u'isblk': False, u'isfifo': False, u'mode': u'0644', u'islnk': False}) => {"changed": false, "item": {"atime": 1571850394.3993108, "ctime": 1571850312.2437878, "dev": 2051, "gid": 0, "gr_name": "root", "inode": 31195174, "isblk": false, "ischr": false, "isdir": false, "isfifo": false, "isgid": false, "islnk": false, "isreg": true, "issock": false, "isuid": false, "mode": "0644", "mtime": 1571850269.4560366, "nlink": 1, "path": "/home/local_repository/wireshark-qt_3.0.5-1_amd64.deb", "pw_name": "root", "rgrp": true, "roth": true, "rusr": true, "size": 3605060, "uid": 0, "wgrp": false, "woth": false, "wusr": true, "xgrp": false, "xoth": false, "xusr": false}, "msg": "Dependency is not satisfiable: libc6 (>= 2.29)\n"}
ok: [localhost] => (item={u'uid': 0, u'woth': False, u'mtime': 1571850217.1323407, u'inode': 31195169, u'isgid': False, u'size': 40654, u'roth': True, u'isuid': False, u'isreg': True, u'pw_name': u'root', u'gid': 0, u'ischr': False, u'wusr': True, u'xoth': False, u'rusr': True, u'nlink': 1, u'issock': False, u'rgrp': True, u'gr_name': u'root', u'path': u'/home/local_repository/tree_1.7.0-5_amd64.deb', u'xusr': False, u'atime': 1571850397.4392931, u'isdir': False, u'ctime': 1571850312.2437878, u'wgrp': False, u'xgrp': False, u'dev': 2051, u'isblk': False, u'isfifo': False, u'mode': u'0644', u'islnk': False})
ok: [localhost] => (item={u'uid': 0, u'woth': False, u'mtime': 1571850217.0163412, u'inode': 31195168, u'isgid': False, u'size': 52132, u'roth': True, u'isuid': False, u'isreg': True, u'pw_name': u'root', u'gid': 0, u'ischr': False, u'wusr': True, u'xoth': False, u'rusr': True, u'nlink': 1, u'issock': False, u'rgrp': True, u'gr_name': u'root', u'path': u'/home/local_repository/dstat_0.7.3-1_all.deb', u'xusr': False, u'atime': 1571850399.3192823, u'isdir': False, u'ctime': 1571850312.2437878, u'wgrp': False, u'xgrp': False, u'dev': 2051, u'isblk': False, u'isfifo': False, u'mode': u'0644', u'islnk': False})
        to retry, use: --limit @/home/upgrade/ansible/install_dependencies.retry

PLAY RECAP ****************************************************************************************************************************************************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=1

```

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [October 23, 2019, 8:44pm UTC](https://forum.ansible.com/t/how-to-resolve-dependencies-of-locally-downloaded-packages-when-package-a-depends-on-b/31531/2 "2019-10-23T20:44:19Z")

</div>

Hii

How about just installing the deb files in the correct order?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [October 23, 2019, 9:03pm UTC](https://forum.ansible.com/t/how-to-resolve-dependencies-of-locally-downloaded-packages-when-package-a-depends-on-b/31531/3 "2019-10-23T21:03:16Z")

</div>

> I have simple playbook where trying to install the Debian packages  
> downloaded locally in my server. This playbook runs on localhost and  
> install the Debian packages in the same system. But this playbook gives an  
> error \*"Dependency is not satisfiable\* for some of the packages even tough  
> the dependency package is available in the local repository.

Sometimes the best solution is to use the commands.

> \*install\_dependencies.yml\*
> 
> ---  
> - hosts: localhost  
> &nbsp;&nbsp;vars:  
> &nbsp;&nbsp;&nbsp;&nbsp;remote\_media\_directory: "/home/local\_repository"  
> &nbsp;&nbsp;become: yes  
> &nbsp;&nbsp;tasks:  
> &nbsp;&nbsp;&nbsp;&nbsp;- name: find all debian Packages  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;find:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;paths:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- "{{ remote\_media\_directory }}"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file\_type: file  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;recurse: yes  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;use\_regex: yes  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;patterns:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- '.\*deb$'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: files\_matched\_subdirectory
> 
> &nbsp;&nbsp;&nbsp;&nbsp;- name: installation debian packages  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;apt:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deb: "{{ item.path }}"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with\_items: "{{ files\_matched\_subdirectory.files }}"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: ansible\_distribution == "Ubuntu"

Both tasks can be replaced by this

- command: dpkg -iR {{ remote\_media\_directory }}

---

<div class="post-metadata">

**Author:** ![john\_517501](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@john\_517501](https://forum.ansible.com/u/john_517501)\
**Post date:** [October 23, 2019, 9:07pm UTC](https://forum.ansible.com/t/how-to-resolve-dependencies-of-locally-downloaded-packages-when-package-a-depends-on-b/31531/4 "2019-10-23T21:07:31Z")

</div>

Thanks for your response.  
I tried installing correct order(This would be more of like manual), what if there are many dependency packages for specific Debian package. I am looking for dynamic solution to resolve this issue.

---

<div class="post-metadata">

**Author:** ![john\_517501](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@john\_517501](https://forum.ansible.com/u/john_517501)\
**Post date:** [October 23, 2019, 9:31pm UTC](https://forum.ansible.com/t/how-to-resolve-dependencies-of-locally-downloaded-packages-when-package-a-depends-on-b/31531/5 "2019-10-23T21:31:31Z")

</div>

Thanks… Can i resolve this issue with any mechanism using tags or roles (meta)
