LearnLinuxTV / personal_ansible_desktop_configs

315 stars 96 forks source link

maybe a bug? #1

Closed zombiehoffa closed 1 year ago

zombiehoffa commented 3 years ago

I notice in your pre_tasks in your main local.yml you update the apt cache and specify when: ansible_distribution in ["Debian", "Ubuntu"]

but in your cleanup tasks you specify ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu"]

So does that mean that if you run this on pop os it won't update your cache for popos or is it smart enough to figure out pop os is apt based and run it anyway? Would popos then be redundant in the cleanup phase?

as a side question, for the arch section will manjaro identify as arch there or should that be specified as one of the distributions in both the pre task and clean up tasks specifically if you want to be able to use these sections with manjaro?

LearnLinuxTV commented 3 years ago

As far as the absence of Pop!_OS in the ansible_distribution statement and that potentially not running on Pop!_OS hosts, you're sort of correct. The reason I say "sort of", is because Ansible is normally able to tell when a distribution is based on another, and it "should" run. So if Ansible is behaving properly, I shouldn't need to add Pop!_OS in that statement at all and it should still update the cache. However, I added Pop!_OS everywhere because there's a bug in Ansible and it wasn't honoring that. The bug may have been fixed, I haven't had a chance to check. In addition, Pop!_OS usually refreshes the Apt cache in the background anyway, so you can make a solid argument that clarifying it there isn't necessary.

In regards to Manjaro, that's the same logic as Pop!_OS. When Ansible is working correctly, it can tell that Manjaro is based on Arch and both should run. But the issue with that (and it's the same with Pop!_OS) is that there are notable differences between Manjaro and Arch (much in the same way as there is with Pop!_OS and Ubuntu). Both Manjaro and Pop have additional repositories that include packages that exist in one but not the other. For example, the last time I checked, Lutris was available in Pop!_OS repositories but not Ubuntu's. Thus, I often have to clarify one or the other anyway or the job may fail. I felt it was better to call out every distro, even if it's redundant. That way, I'm not overly worried about pointing out each edge-case.

I hope that clears it up for you.

On Tue, Dec 29, 2020 at 6:28 PM zombiehoffa notifications@github.com wrote:

I notice in your pre_tasks in your main local.yml you update the apt cache and specify when: ansible_distribution in ["Debian", "Ubuntu"]

but in your cleanup tasks you specify ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu"]

So does that mean that if you run this on pop os it won't update your cache for popos or is it smart enough to figure out pop os is apt based and run it anyway? Would popos then be redundant in the cleanup phase?

as a side question, for the arch section will manjaro identify as arch there or should that be specified as one of the distributions in both the pre task and clean up tasks specifically if you want to be able to use these sections with manjaro?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/LearnLinuxTV/personal_ansible_desktop_configs/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIT3PDG4ABNDWMUFXGZZETSXJQ2VANCNFSM4VNW5YJQ .

Hyperling commented 3 years ago

Howdy!

After trying to figure this out myself I'd recommend using the fact ansible_pkg_mgr.

In my recent experience with ansible [2.9.9 (Ubuntu and Pop!_OS 20.10), 2.9.7 (FreeBSD 12.2), 2.7.7 (Debian 10)], ansible_distribution is specific to the distribution and unfortunately will not be smart enough to do this.

After running ansible -m setup localhost > facts.json on my systems:

Here's a quick test of all these fact variables:

- name: Testing Package Cache Refresh
  package:
    update_cache: yes
  when: ansible_os_family == "Debian"

- name: Testing Apt Cache Refresh
  apt: update_cache=yes
  when: ansible_distribution in ["Debian", "Ubuntu"]

- name: Testing Apt Cache Refresh 2
  apt: update_cache=yes
  when: ansible_pkg_mgr == "apt"

Output from Pop!_OS:

TASK [Testing Package Cache Refresh] *******************************************
skipping: [localhost]

TASK [Testing Apt Cache Refresh] ***********************************************
skipping: [localhost]

TASK [Testing Apt Cache Refresh 2] *********************************************
ok: [localhost]

Output from Ubuntu + Debian (both performed identically):

TASK [Testing Package Cache Refresh] *******************************************
ok: [localhost]

TASK [Testing Apt Cache Refresh] ***********************************************
ok: [localhost]

TASK [Testing Apt Cache Refresh 2] *********************************************
ok: [localhost]

I hope this helps! :)

Hype

LearnLinuxTV commented 1 year ago

Closing due to age