Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch to fix: "ANXS.apt : APT | Install Packages failed with No package(s) matching '['python3-apt'' available" error #18

Open
ianheggie opened this issue Jun 10, 2023 · 2 comments

Comments

@ianheggie
Copy link

ianheggie commented Jun 10, 2023

I refactored out the combining of the two lists (see patch below) and that fixed the problem for me!

Environment:

  • roles/ANXS.apt/version: v2.1.0
  • ansible --version: ansible [core 2.14.6]
  • ansible_python_interpreter: /usr/bin/python3
  • os-release (host and target): VERSION="22.04.2 LTS (Jammy Jellyfish)"
  • defaults/main.yml vars not overriden

Log from ansible:

TASK [ANXS.apt : APT | Reset the sources list (/etc/apt/sources.list)] ************************************************************************************************************************************************************************************************************
skipping: [staging3.server.tld]

TASK [ANXS.apt : APT | Update the apt cache] **************************************************************************************************************************************************************************************************************************************
ok: [staging3.server.tld]

TASK [ANXS.apt : APT | Remove packages that are no longer needed for dependencies] ************************************************************************************************************************************************************************************************
ok: [staging3.server.tld]

TASK [ANXS.apt : APT | Remove .deb files for packages no longer on your system] ***************************************************************************************************************************************************************************************************
ok: [staging3.server.tld]

TASK [ANXS.apt : APT | Check for cached .deb files] *******************************************************************************************************************************************************************************************************************************
skipping: [staging3.server.tld]

TASK [ANXS.apt : APT | Remove all cached .deb files] ******************************************************************************************************************************************************************************************************************************
skipping: [staging3.server.tld]

TASK [ANXS.apt : APT | Update the general configuration (/etc/apt/apt.conf.d/10general)] ******************************************************************************************************************************************************************************************
ok: [staging3.server.tld]

TASK [ANXS.apt : APT | Make sure the required packages are installed 20.04 and above] *********************************************************************************************************************************************************************************************
ok: [staging3.server.tld]

TASK [ANXS.apt : APT | Make sure the required packages are installed 19.10 and below] *********************************************************************************************************************************************************************************************
skipping: [staging3.server.tld]

TASK [ANXS.apt : APT | Install Packages] ******************************************************************************************************************************************************************************************************************************************
failed: [staging3.server.tld] (item=['python3-apt', 'unattended-upgrades', 'apt-transport-https', 'curl', 'ca-certificates', 'software-properties-common'] + ['python3-apt']) => {"ansible_loop_var": "item", "changed": false, "item": "['python3-apt', 'unattended-upgrades', 'apt-transport-https', 'curl', 'ca-certificates', 'software-properties-common'] + ['python3-apt']", "msg": "No package(s) matching '['python3-apt'' available"}
	to retry, use: --limit @/home/ianh/Projects/Xbase/provision/tmp/ansible-retry/site.retry

PLAY RECAP ************************************************************************************************************************************************************************************************************************************************************************
staging3.server.tld        : ok=6    changed=0    unreachable=0    failed=1    skipped=4    rescued=0    ignored=0   

Patch that fixed the problem for me (personally prefer running apt on default separately from version specific list anyway)

diff --git a/roles/ANXS.apt/tasks/main.yml b/roles/ANXS.apt/tasks/main.yml
index c7382dc..a4a9d2c 100644
--- a/roles/ANXS.apt/tasks/main.yml
+++ b/roles/ANXS.apt/tasks/main.yml
@@ -43,17 +43,19 @@
     group: root
     mode: 0644
 
+- name: APT | Install Default Packages
+  apt:
+    pkg: "{{apt_default_packages}}"
+    state: present
+
 - name: APT | Make sure the required packages are installed 20.04 and above
-  set_fact:
-    apt_packages_list: "{{ apt_default_packages }} + {{ apt_default_packages_post20 }}"
+  apt:
+    pkg: "{{apt_default_packages_post20}}"
+    state: present
   when: ansible_facts['distribution_version'] is version('20.04', '>=')
 
 - name: APT | Make sure the required packages are installed 19.10 and below
-  set_fact:
-    apt_packages_list: "{{ apt_default_packages }} + {{ apt_default_packages_pre20 }}"
+  apt:
+    pkg: "{{apt_default_packages_pre20}}"
+    state: present
   when: ansible_facts['distribution_version'] is version('20.04', '<')
-
-- name: APT | Install Packages
-  apt:
-    pkg: "{{apt_packages_list}}"
-    state: present
@ianheggie ianheggie changed the title ANXS.apt : APT | Install Packages failed with No package(s) matching '['python3-apt'' available Patch to fix: "ANXS.apt : APT | Install Packages failed with No package(s) matching '['python3-apt'' available" error Jun 10, 2023
@nekeal
Copy link

nekeal commented Jul 7, 2023

@ianheggie actually the issue is related to changed arithmetic and concatenation operations outside of the jinja template.
The solution is to change this {{ apt_default_packages }} + {{ apt_default_packages_pre20 }} to this {{ apt_default_packages + apt_default_packages_pre20 }}

edit: I've just realized that the fix is already merged ;)

@ianheggie
Copy link
Author

@ianheggie actually the issue is related to changed arithmetic and concatenation operations outside of the jinja template. The solution is to change this {{ apt_default_packages }} + {{ apt_default_packages_pre20 }} to this {{ apt_default_packages + apt_default_packages_pre20 }}

edit: I've just realized that the fix is already merged ;)

Thanks for your feedback - I didn't twig to that being the issue. I was just reading about "egg of Columbus" and your solution fits!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants