diff mbox series

bringup: devconfig: fix python3-apt debian issue

Message ID 20250131-fix-python3-apt-v1-1-bcdb14b149ba@samsung.com (mailing list archive)
State New
Headers show
Series bringup: devconfig: fix python3-apt debian issue | expand

Commit Message

Daniel Gomez Jan. 31, 2025, 9:05 p.m. UTC
Downgrade python3-apt package to 2.9.6 during bringup to avoid Ansible
error with apt module (see below).

Build from source python3-apt using pip, and lock any possible future
upgrades of the package to avoid overwriting the build from source
deployment.

This is a workaround until python3-apt package in Debian testing is
fixed. It will also delay the bringup process considerably depending on
the guest.

The latest python3-apt releases 2.9.8 and 2.9.7 produces the following
error with Ansible:

Error message:

TASK [create_partition : Install partition creation base tools]
fatal: [4da8c431f681-xfs-reflink-4k]: FAILED! => {
    "changed": false
}

MSG:

python3-apt must be installed and visible from /usr/bin/python3.

Tested with Ansible version:

ii  ansible        9.5.1+dfsg-1 all
ii  ansible-core   2.17.1-1

ansible --version
ansible [core 2.17.1]
  ...
  python version = 3.12.6 (main, Sep  7 2024, 14:20:15) [GCC 14.2.0]
(/usr/bin/python3)
  jinja version = 3.1.3
  libyaml = True
ansible-playbook --version
ansible-playbook [core 2.17.1]
  ...
  executable location = /usr/bin/ansible-playbook
  python version = 3.12.6 (main, Sep  7 2024, 14:20:15) [GCC 14.2.0]
(/usr/bin/python3)
  jinja version = 3.1.3
  libyaml = True

Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
Latest versions of python3-apt produces playbook errors when apt or
package Ansible modules are used. Replace the current Debian testing
package with an older working version of python3-apt.

This workaround fixes the current kdevops CI issue in GitHub [1].

[1] https://github.com/linux-kdevops/kdevops/actions/runs/13040775569/job/36420451428

To: Luis Chamberlain <mcgrof@kernel.org>
Cc: kdevops@lists.linux.dev
---
 .../devconfig/tasks/install-deps/debian/main.yml   | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)


---
base-commit: 4da8c431f681d6b8009518c6766c638267d9c61a
change-id: 20250131-fix-python3-apt-227607641858

Best regards,

Comments

Daniel Gomez Feb. 3, 2025, 9:44 a.m. UTC | #1
On Fri, Jan 31, 2025 at 10:05:52PM +0100, Daniel Gomez wrote:
> Downgrade python3-apt package to 2.9.6 during bringup to avoid Ansible
> error with apt module (see below).
> 
> Build from source python3-apt using pip, and lock any possible future
> upgrades of the package to avoid overwriting the build from source
> deployment.
> 
> This is a workaround until python3-apt package in Debian testing is
> fixed. It will also delay the bringup process considerably depending on
> the guest.
> 
> The latest python3-apt releases 2.9.8 and 2.9.7 produces the following
> error with Ansible:
> 
> Error message:
> 
> TASK [create_partition : Install partition creation base tools]
> fatal: [4da8c431f681-xfs-reflink-4k]: FAILED! => {
>     "changed": false
> }
> 
> MSG:
> 
> python3-apt must be installed and visible from /usr/bin/python3.
> 
> Tested with Ansible version:
> 
> ii  ansible        9.5.1+dfsg-1 all
> ii  ansible-core   2.17.1-1
> 
> ansible --version
> ansible [core 2.17.1]
>   ...
>   python version = 3.12.6 (main, Sep  7 2024, 14:20:15) [GCC 14.2.0]
> (/usr/bin/python3)
>   jinja version = 3.1.3
>   libyaml = True
> ansible-playbook --version
> ansible-playbook [core 2.17.1]
>   ...
>   executable location = /usr/bin/ansible-playbook
>   python version = 3.12.6 (main, Sep  7 2024, 14:20:15) [GCC 14.2.0]
> (/usr/bin/python3)
>   jinja version = 3.1.3
>   libyaml = True
> 
> Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
> ---
> Latest versions of python3-apt produces playbook errors when apt or
> package Ansible modules are used. Replace the current Debian testing
> package with an older working version of python3-apt.
> 
> This workaround fixes the current kdevops CI issue in GitHub [1].
> 
> [1] https://github.com/linux-kdevops/kdevops/actions/runs/13040775569/job/36420451428
> 
> To: Luis Chamberlain <mcgrof@kernel.org>
> Cc: kdevops@lists.linux.dev
> ---
>  .../devconfig/tasks/install-deps/debian/main.yml   | 42 ++++++++++++++++++++++
>  1 file changed, 42 insertions(+)
> 
> diff --git a/playbooks/roles/devconfig/tasks/install-deps/debian/main.yml b/playbooks/roles/devconfig/tasks/install-deps/debian/main.yml
> index c8c18bb0d8c75a853cdf86d19b1b57acc4bc29b3..c7d28776d1355ad4368a3feafb1df743363f50be 100644
> --- a/playbooks/roles/devconfig/tasks/install-deps/debian/main.yml
> +++ b/playbooks/roles/devconfig/tasks/install-deps/debian/main.yml
> @@ -1,4 +1,46 @@
>  ---
> +- name: Update package lists
> +  become: true
> +  become_method: sudo
> +  ansible.builtin.shell:
> +    cmd: >
> +      DEBIAN_FRONTEND=noninteractive apt
> +      -o Acquire::Check-Valid-Until=false update
> +  when:
> +    - ansible_os_family == "Debian"
> +  tags: vars_simple
> +  register: apt_update_result
> +  retries: 5
> +  delay: 10
> +  until: apt_update_result.rc == 0
> +
> +- name: Install required packages
> +  become: true
> +  become_method: sudo
> +  ansible.builtin.shell:
> +    cmd: >
> +      DEBIAN_FRONTEND=noninteractive apt install -y
> +      python3-setuptools libapt-pkg-dev python3-pip git
> +  when:
> +    - ansible_os_family == "Debian"
> +  tags: vars_simple
> +
> +- name: Install python-apt from Git with pip3
> +  become: true
> +  become_method: sudo
> +  ansible.builtin.shell:
> +    cmd: pip3 install git+https://salsa.debian.org/apt-team/python-apt.git@2.9.6 --break-system-packages
> +  when:
> +    - ansible_os_family == "Debian"
> +  tags: vars_simple
> +
> +- name: Hold python3-apt package version
> +  become: yes
> +  ansible.builtin.command: apt-mark hold python3-apt
> +  when:
> +    - ansible_os_family == "Debian"
> +  tags: vars_simple
> +
>  - name: Remove unattended-upgrades package
>    become: yes
>    become_flags: 'su - -c'


I'm making this specific to Debian trixie.

--- a/playbooks/roles/devconfig/tasks/install-deps/debian/main.yml
+++ b/playbooks/roles/devconfig/tasks/install-deps/debian/main.yml
@@ -8,6 +8,7 @@
       -o Acquire::Check-Valid-Until=false update
   when:
     - ansible_os_family == "Debian"
+    - ansible_distribution_release == "trixie"
   tags: vars_simple
   register: apt_update_result
   retries: 5
@@ -23,15 +24,20 @@
       python3-setuptools libapt-pkg-dev python3-pip git
   when:
     - ansible_os_family == "Debian"
+    - ansible_distribution_release == "trixie"
   tags: vars_simple

 - name: Install python-apt from Git with pip3
   become: true
   become_method: sudo
   ansible.builtin.shell:
-    cmd: pip3 install git+https://salsa.debian.org/apt-team/python-apt.git@2.9.6 --break-system-packages
+    cmd: >
+      pip3 install
+      git+https://salsa.debian.org/apt-team/python-apt.git@2.9.6
+      --break-system-packages
   when:
     - ansible_os_family == "Debian"
+    - ansible_distribution_release == "trixie"
   tags: vars_simple

 - name: Hold python3-apt package version

Since this is needed to fix CI, I'll push this to let gh continue and
see if there's any other errors in the rest of the pipeline. Please,
revert if/when proper fix is found.


> 
> ---
> base-commit: 4da8c431f681d6b8009518c6766c638267d9c61a
> change-id: 20250131-fix-python3-apt-227607641858
> 
> Best regards,
> -- 
> Daniel Gomez <da.gomez@samsung.com>
>
diff mbox series

Patch

diff --git a/playbooks/roles/devconfig/tasks/install-deps/debian/main.yml b/playbooks/roles/devconfig/tasks/install-deps/debian/main.yml
index c8c18bb0d8c75a853cdf86d19b1b57acc4bc29b3..c7d28776d1355ad4368a3feafb1df743363f50be 100644
--- a/playbooks/roles/devconfig/tasks/install-deps/debian/main.yml
+++ b/playbooks/roles/devconfig/tasks/install-deps/debian/main.yml
@@ -1,4 +1,46 @@ 
 ---
+- name: Update package lists
+  become: true
+  become_method: sudo
+  ansible.builtin.shell:
+    cmd: >
+      DEBIAN_FRONTEND=noninteractive apt
+      -o Acquire::Check-Valid-Until=false update
+  when:
+    - ansible_os_family == "Debian"
+  tags: vars_simple
+  register: apt_update_result
+  retries: 5
+  delay: 10
+  until: apt_update_result.rc == 0
+
+- name: Install required packages
+  become: true
+  become_method: sudo
+  ansible.builtin.shell:
+    cmd: >
+      DEBIAN_FRONTEND=noninteractive apt install -y
+      python3-setuptools libapt-pkg-dev python3-pip git
+  when:
+    - ansible_os_family == "Debian"
+  tags: vars_simple
+
+- name: Install python-apt from Git with pip3
+  become: true
+  become_method: sudo
+  ansible.builtin.shell:
+    cmd: pip3 install git+https://salsa.debian.org/apt-team/python-apt.git@2.9.6 --break-system-packages
+  when:
+    - ansible_os_family == "Debian"
+  tags: vars_simple
+
+- name: Hold python3-apt package version
+  become: yes
+  ansible.builtin.command: apt-mark hold python3-apt
+  when:
+    - ansible_os_family == "Debian"
+  tags: vars_simple
+
 - name: Remove unattended-upgrades package
   become: yes
   become_flags: 'su - -c'