# Migrating playbook from ubuntu to amazon linux 2 - throws error missing dependency: python-apt

**URL:** <https://forum.ansible.com/t/migrating-playbook-from-ubuntu-to-amazon-linux-2-throws-error-missing-dependency-python-apt/32138>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [February 5, 2020, 1:08am UTC](https://forum.ansible.com/t/migrating-playbook-from-ubuntu-to-amazon-linux-2-throws-error-missing-dependency-python-apt/32138 "2020-02-05T01:08:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Work\_Email](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@Work\_Email](https://forum.ansible.com/u/Work_Email)\
**Post date:** [February 5, 2020, 1:08am UTC](https://forum.ansible.com/t/migrating-playbook-from-ubuntu-to-amazon-linux-2-throws-error-missing-dependency-python-apt/32138/1 "2020-02-05T01:08:01Z")

</div>

Hello,  
Do you recommend Migrating playbook from ubuntu to amazon Linux 2 (as it uses **yum instead of apt** ). If so, how can I check if missing add a package to a new instance to make sure it installs python-apt\*\*?\*\*  
**Ansible-Playbook**

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [February 5, 2020, 8:06am UTC](https://forum.ansible.com/t/migrating-playbook-from-ubuntu-to-amazon-linux-2-throws-error-missing-dependency-python-apt/32138/2 "2020-02-05T08:06:22Z")

</div>

> Hello,  
> Do you recommend Migrating playbook from ubuntu to amazon Linux 2 (as it uses \*yum instead of apt\*). If so, how can I  
> check if missing add a package to a new instance to make sure it installs python-apt\*?\*  
> \*Ansible-Playbook\*

If Amazon Linux2 is a RedHat based distribution (as the usage of yum suggests) it makes no sense to  
use python-apt as it caters to Debian based distributions.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<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:** [February 5, 2020, 8:26am UTC](https://forum.ansible.com/t/migrating-playbook-from-ubuntu-to-amazon-linux-2-throws-error-missing-dependency-python-apt/32138/3 "2020-02-05T08:26:53Z")

</div>

Also, the package management isn't the only difference between Debian  
and Redhat based distros.  
So if you have any other playbooks that have implicitly Debianisms you  
will need to rewrite those as well.  
Things that come to mind are the ways packages themselves are  
configured - config file location and inclusion structure, the init  
system etc.

---

<div class="post-metadata">

**Author:** ![Darkhan](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Darkhan](https://forum.ansible.com/u/Darkhan)\
**Post date:** [February 5, 2020, 8:48am UTC](https://forum.ansible.com/t/migrating-playbook-from-ubuntu-to-amazon-linux-2-throws-error-missing-dependency-python-apt/32138/4 "2020-02-05T08:48:01Z")

</div>

Why are you using the command module?

Use the package module. Then it will not matter what package manager the distro is running.  
If you have ansible module available for what you want to do, never use command. I would rewrite the entire play.

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [February 5, 2020, 9:26am UTC](https://forum.ansible.com/t/migrating-playbook-from-ubuntu-to-amazon-linux-2-throws-error-missing-dependency-python-apt/32138/5 "2020-02-05T09:26:34Z")

</div>

> Why are you using the command module?
> 
> Use the package module. Then it will not matter what package manager the distro is running.  
> If you have ansible module available for what you want to do, never use command. I would rewrite the entire play.

You can use the package module, but it will not be able to list packages and the names of packages might  
differ between different distros etc.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Work\_Email](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@Work\_Email](https://forum.ansible.com/u/Work_Email)\
**Post date:** [February 5, 2020, 10:07pm UTC](https://forum.ansible.com/t/migrating-playbook-from-ubuntu-to-amazon-linux-2-throws-error-missing-dependency-python-apt/32138/6 "2020-02-05T22:07:00Z")

</div>

So, I am breaking it down in the playbook - **it doesn’t like spaces in name of the package?**  
**playbook:**

---

<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:** [February 5, 2020, 10:52pm UTC](https://forum.ansible.com/t/migrating-playbook-from-ubuntu-to-amazon-linux-2-throws-error-missing-dependency-python-apt/32138/7 "2020-02-05T22:52:05Z")

</div>

Correct.  
There is no package called "yum update".

---

<div class="post-metadata">

**Author:** ![Work\_Email](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@Work\_Email](https://forum.ansible.com/u/Work_Email)\
**Post date:** [February 5, 2020, 11:28pm UTC](https://forum.ansible.com/t/migrating-playbook-from-ubuntu-to-amazon-linux-2-throws-error-missing-dependency-python-apt/32138/8 "2020-02-05T23:28:26Z")

</div>

Thanks for the update. I was able to figure it out!

---

<div class="post-metadata">

**Author:** ![Darkhan](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Darkhan](https://forum.ansible.com/u/Darkhan)\
**Post date:** [February 6, 2020, 1:44pm UTC](https://forum.ansible.com/t/migrating-playbook-from-ubuntu-to-amazon-linux-2-throws-error-missing-dependency-python-apt/32138/9 "2020-02-06T13:44:43Z")

</div>

You can use package facts for that:  
[https://docs.ansible.com/ansible/latest/modules/package\_facts\_module.html](https://docs.ansible.com/ansible/latest/modules/package_facts_module.html)
