ansible-community/ppa

ansible=8.6.0-1ppa~jammy fails to install

Closed this issue ยท 30 comments

This minimal Dockerfile reproduces the issue:

# syntax=docker/dockerfile:1.6
FROM ubuntu:jammy AS issue
RUN <<INSTALL_PACKAGES
apt-get update
apt-get --assume-yes install software-properties-common
add-apt-repository --yes --update ppa:ansible/ansible
apt-get --assume-yes install ansible
INSTALL_PACKAGES

Here is a portion of the output including the error:

$ docker buildx build .

...snip...

58.77 Setting up ansible (8.6.0-1ppa~jammy) ...
68.55   File "/usr/lib/python3/dist-packages/ansible_collections/netapp/ontap/plugins/modules/na_ontap_s3_users.py", line 7
68.55     from __future__ import absolute_import, division, print_function
68.55     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
68.55 SyntaxError: from __future__ imports must occur at the beginning of the file
68.56 dpkg: error processing package ansible (--configure):
68.56  installed ansible package post-installation script subprocess returned error exit status 1
68.56 Processing triggers for libc-bin (2.35-0ubuntu3.4) ...
68.65 Errors were encountered while processing:
68.65  ansible
68.67 E: Sub-process /usr/bin/dpkg returned an error code (1)

I'm having the same problem. This didn't happen with 8.5.0-1ppa~jammy, so I initially thought I could downgrade as a temporary workaround, but it seems like that version is no longer available, unfortunately:

circleci@8d516732b7a8:~$ apt list --all-versions ansible
Listing... Done
ansible/jammy,now 8.6.0-1ppa~jammy all [installed]
ansible/jammy 2.10.7+merged+base+2.10.8+dfsg-1 all

circleci@8d516732b7a8:~$

[โ€ฆ] didn't happen with 8.5.0-1ppa~jammy, so I initially thought I could downgrade as a temporary workaround, but it seems like that version is no longer available [โ€ฆ]

Unfortunately Launchpad PPAs are not built in a way that supports keeping multiple versions of the same package for the same Ubuntu code name around.

This can also be reproduced using the provided test dir https://github.com/ansible-community/ppa/tree/main/test

./main.sh -c jammy -p ansible
...
...
Setting up ansible-core (2.15.6-1ppa~jammy) ...
Setting up ansible (8.6.0-1ppa~jammy) ...
  File "/usr/lib/python3/dist-packages/ansible_collections/netapp/ontap/plugins/modules/na_ontap_s3_users.py", line 7
    from __future__ import absolute_import, division, print_function
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: from __future__ imports must occur at the beginning of the file
dpkg: error processing package ansible (--configure):
 installed ansible package post-installation script subprocess returned error exit status 1
Processing triggers for libc-bin (2.35-0ubuntu3.4) ...
Errors were encountered while processing:
 ansible
E: Sub-process /usr/bin/dpkg returned an error code (1)
ansible [core 2.15.6]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True
localhost | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

Same issue installing on PopOS 22.04:

โžœ ansible sudo apt install ansible
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
ansible-core python3-jmespath python3-kerberos python3-ntlm-auth python3-paramiko python3-requests-kerberos python3-requests-ntlm python3-resolvelib python3-winrm python3-xmltodict
sshpass
Suggested packages:
python3-gssapi python3-invoke
The following NEW packages will be installed:
ansible ansible-core python3-jmespath python3-kerberos python3-ntlm-auth python3-paramiko python3-requests-kerberos python3-requests-ntlm python3-resolvelib python3-winrm
python3-xmltodict sshpass
0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,311 kB/17.8 MB of archives.
After this operation, 299 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://apt.pop-os.org/ubuntu jammy/universe amd64 python3-resolvelib all 0.8.1-1 [23.6 kB]
Get:2 http://apt.pop-os.org/ubuntu jammy/main amd64 python3-jmespath all 0.10.0-1 [21.7 kB]
Get:3 http://apt.pop-os.org/ubuntu jammy/universe amd64 python3-kerberos amd64 1.1.14-3.1build5 [23.0 kB]
Get:4 http://apt.pop-os.org/ubuntu jammy/universe amd64 python3-ntlm-auth all 1.4.0-1 [20.4 kB]
Get:5 http://apt.pop-os.org/ubuntu jammy/main amd64 python3-paramiko all 2.9.3-0ubuntu1 [133 kB]
Get:6 http://apt.pop-os.org/ubuntu jammy/universe amd64 python3-requests-kerberos all 0.12.0-2 [11.9 kB]
Get:7 http://apt.pop-os.org/ubuntu jammy/universe amd64 python3-requests-ntlm all 1.1.0-1.1 [6,160 B]
Get:8 http://apt.pop-os.org/ubuntu jammy/universe amd64 python3-xmltodict all 0.12.0-2 [12.6 kB]
Get:9 http://apt.pop-os.org/ubuntu jammy/universe amd64 python3-winrm all 0.3.0-2 [21.7 kB]
Get:10 http://apt.pop-os.org/ubuntu jammy/universe amd64 sshpass amd64 1.09-1 [11.7 kB]
Get:11 https://ppa.launchpadcontent.net/ansible/ansible/ubuntu jammy/main amd64 ansible-core all 2.15.6-1ppajammy [1,025 kB]
Fetched 1,311 kB in 1s (1,095 kB/s)
Selecting previously unselected package python3-resolvelib.
(Reading database ... 246301 files and directories currently installed.)
Preparing to unpack .../00-python3-resolvelib_0.8.1-1_all.deb ...
Unpacking python3-resolvelib (0.8.1-1) ...
Selecting previously unselected package ansible-core.
Preparing to unpack .../01-ansible-core_2.15.6-1ppa
jammy_all.deb ...
Unpacking ansible-core (2.15.6-1ppajammy) ...
Selecting previously unselected package ansible.
Preparing to unpack .../02-ansible_8.6.0-1ppa
jammy_all.deb ...
Unpacking ansible (8.6.0-1ppajammy) ...
Selecting previously unselected package python3-jmespath.
Preparing to unpack .../03-python3-jmespath_0.10.0-1_all.deb ...
Unpacking python3-jmespath (0.10.0-1) ...
Selecting previously unselected package python3-kerberos.
Preparing to unpack .../04-python3-kerberos_1.1.14-3.1build5_amd64.deb ...
Unpacking python3-kerberos (1.1.14-3.1build5) ...
Selecting previously unselected package python3-ntlm-auth.
Preparing to unpack .../05-python3-ntlm-auth_1.4.0-1_all.deb ...
Unpacking python3-ntlm-auth (1.4.0-1) ...
Selecting previously unselected package python3-paramiko.
Preparing to unpack .../06-python3-paramiko_2.9.3-0ubuntu1_all.deb ...
Unpacking python3-paramiko (2.9.3-0ubuntu1) ...
Selecting previously unselected package python3-requests-kerberos.
Preparing to unpack .../07-python3-requests-kerberos_0.12.0-2_all.deb ...
Unpacking python3-requests-kerberos (0.12.0-2) ...
Selecting previously unselected package python3-requests-ntlm.
Preparing to unpack .../08-python3-requests-ntlm_1.1.0-1.1_all.deb ...
Unpacking python3-requests-ntlm (1.1.0-1.1) ...
Selecting previously unselected package python3-xmltodict.
Preparing to unpack .../09-python3-xmltodict_0.12.0-2_all.deb ...
Unpacking python3-xmltodict (0.12.0-2) ...
Selecting previously unselected package python3-winrm.
Preparing to unpack .../10-python3-winrm_0.3.0-2_all.deb ...
Unpacking python3-winrm (0.3.0-2) ...
Selecting previously unselected package sshpass.
Preparing to unpack .../11-sshpass_1.09-1_amd64.deb ...
Unpacking sshpass (1.09-1) ...
Setting up python3-ntlm-auth (1.4.0-1) ...
Setting up python3-resolvelib (0.8.1-1) ...
Setting up python3-kerberos (1.1.14-3.1build5) ...
Setting up ansible-core (2.15.6-1ppa
jammy) ...
Setting up sshpass (1.09-1) ...
Setting up python3-xmltodict (0.12.0-2) ...
Setting up python3-jmespath (0.10.0-1) ...
Setting up python3-requests-kerberos (0.12.0-2) ...
Setting up ansible (8.6.0-1ppa~jammy) ...
File "/usr/lib/python3/dist-packages/ansible_collections/netapp/ontap/plugins/modules/na_ontap_s3_users.py", line 7
from future import absolute_import, division, print_function
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: from future imports must occur at the beginning of the file
dpkg: error processing package ansible (--configure):
installed ansible package post-installation script subprocess returned error exit status 1
Setting up python3-paramiko (2.9.3-0ubuntu1) ...
Setting up python3-requests-ntlm (1.1.0-1.1) ...
Setting up python3-winrm (0.3.0-2) ...
Processing triggers for man-db (2.10.2-1) ...
Errors were encountered while processing:
ansible
E: Sub-process /usr/bin/dpkg returned an error code (1)

EDIT: disregard the hacky workaround below, the one at https://github.com/Agoric/agoric-sdk/pull/8515/files#diff-84818aa4a21021181fdaea864b2e47775e28ecc7b5dee63dc7ad9b571e5aa621 is better:

if apt-get install -y ansible; then : # success
else
  # Failed to install Ansible, try workaround based on
  # https://github.com/ansible-community/ppa/issues/77#issuecomment-1802847056
  sed -i -e '1s/^[^#]*//' /usr/lib/python3/dist-packages/ansible_collections/netapp/ontap/plugins/modules/na_ontap_s3_users.py
  apt-get install -y --fix-broken
fi
hacky workaround

Oh, I found that in my case, the installation exiting with a non-zero status code doesn't seem to actually prevent ansible from running, so I was able to work around it in my scripts by adding || true after the installation command, e.g.

sudo apt-get -y install ansible || true
d3al commented

I had the same issue. I had 22.8.0 collection installed so I tried updating the collection to 22.8.1 which didn't fix the issue.

ansible-galaxy collection install -U netapp.ontap

Open this file.
/usr/lib/python3/dist-packages/ansible_collections/netapp/ontap/plugins/modules/na_ontap_s3_users.py

Top line was had the word "git" for some reason.
git #!/usr/bin/python

I removed "git", saved and was able to install ansible.

Also ran into this issue. Like @d3al I opened up the file in the error message

sudo nano /usr/lib/python3/dist-packages/ansible_collections/netapp/ontap/plugins/modules/na_ontap_s3_users.py

And removed the word git including the space from the first line, right before the shebang. After that a quick

sudo apt install --fix-broken

finished the installation of Ansible properly.

Also having this issue on Jammy (22.04.3 LTS). Ill try the workaround @rmbleeker suggested, but hope this gets fixed officially soon.

Addendum- above worked and installation completed.

On further testing, even if you fix the problem of the word git in the first line of the na_ontap_s3_users file, there still seems to be an issue with the netapp.ontap collection. For example, it was saying that space.snapshot.autodelete is an invalid field in one of our NetApp playbooks.

I installed 2.8.1 to fix it this way (note that I'm running as root):

# ansible-galaxy collection install -p /usr/lib/python3/dist-packages/ --force netapp.ontap

limfjm commented

The same issue using the ansible_local on Vagrant.

`Setting up python3-requests-kerberos (0.12.0-2) ...
Setting up python3-paramiko (2.9.3-0ubuntu1) ...
Setting up python3-requests-ntlm (1.1.0-1.1) ...
Setting up ansible-core (2.15.6-1ppajammy) ...
Setting up python3-winrm (0.3.0-2) ...
Setting up ansible (8.6.0-1ppa
jammy) ...
File "/usr/lib/python3/dist-packages/ansible_collections/netapp/ontap/plugins/modules/na_ontap_s3_users.py", line 7
from future import absolute_import, division, print_function
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: from future imports must occur at the beginning of the file
dpkg: error processing package ansible (--configure):
installed ansible package post-installation script subprocess returned error exit status 1
Processing triggers for man-db (2.10.2-1) ...
Errors were encountered while processing:
ansible
needrestart is being skipped since dpkg has failed

Stderr from the command:

E: Sub-process /usr/bin/dpkg returned an error code (1)`

Same for me under Ubuntu 22.04 and Debian 12. Under Debian12 i found in

:~# cd /var/cache/apt/archives

the older Versions so i can do an downgrade to the prior Version.

:~# apt-get install ./ansible_8.5.0-1ppa~jammy_all.deb
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'ansible' instead of './ansible_8.5.0-1ppa~jammy_all.deb'
The following packages will be DOWNGRADED:
  ansible
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/16.4 MB of archives.
After this operation, 14.6 MB disk space will be freed.
Do you want to continue? [Y/n]
dpkg: warning: downgrading ansible from 8.6.0-1ppa~jammy to 8.5.0-1ppa~jammy
(Reading database ... 72948 files and directories currently installed.)
Preparing to unpack .../ansible_8.5.0-1ppa~jammy_all.deb ...
Unpacking ansible (8.5.0-1ppa~jammy) over (8.6.0-1ppa~jammy) ...
Setting up ansible (8.5.0-1ppa~jammy) ...

Also ran into this issue. Like @d3al I opened up the file in the error message

sudo nano /usr/lib/python3/dist-packages/ansible_collections/netapp/ontap/plugins/modules/na_ontap_s3_users.py

And removed the word git including the space from the first line, right before the shebang. After that a quick

sudo apt install --fix-broken

finished the installation of Ansible properly.

Did this in my vagrant machine that I suddenly could not recreate, and it worked. Thanks!

Seems like its just this broken shebang causing it.

Same with 8.6.0-1ppa~lunar

Also an issue in Jammy. What's fix for this in the Ansible PPA? Looking at the source file at https://github.com/ansible-collections/netapp.ontap/blame/main/plugins/modules/na_ontap_s3_users.py it doesn't look like the she-bang line has been modified in a year, so this issue crept in somewhere else...

Can we get a rebuild with clean source trees?

Looking into the PPA github workflow, I don't see how this could have happened without the sources for na_ontap_s3_users.py reflecting the change. But I'm also not able to figure out where the workflow is that does the deb package build so I can't run it manually on my system to see if I can reproduce it.

I got the same issue with 8.6.0-1ppa~jammy
Does anyone found a solution to this issue?

Would it make sense to have some form of automated test, like "does the package successfully install" before uploading to the PPA?

This would've been caught by ansible-test's validate-modules tests, as well as import tests, according to an ansible core dev- ansible-collections/netapp.ontap#190 (comment)

rit001 commented

I got the same issue with 8.6.0-1ppa~jammy Does anyone found a solution to this issue?

The workaround I posted here did not work, something I missed as my environment fell back to using the stock version that is included in Ubuntu.

This leaves using pip as the solution for installing a versioned release of Ansible, which is documented here

https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html

If you are currently using the command

 add-apt-repository -y --update ppa:ansible/ansible

You can change it to

 add-apt-repository -y --update ppa:ansible/ansible-8.5

This will cause the installation of version 8.5, which is the last known good release

This did not work,

ERROR: ppa 'ansible/ansible-8.5' not found (use --login if private)

and as evidenced by earlier comments

[โ€ฆ] didn't happen with 8.5.0-1ppa~jammy, so I initially thought I could downgrade as a temporary workaround, but it seems like that version is no longer available [โ€ฆ]

Unfortunately Launchpad PPAs are not built in a way that supports keeping multiple versions of the same package for the same Ubuntu code name around.

The workaround I used:

  • install python3
  • install pip
  • install ansible 8.5 from pip, python3 -m pip install --user ansible==8.5.0
    • adjust PATH to have ansible* executables available

we are looking into the best way to remediate this, in the meantime, I would suggest following @rmbleeker's #77 (comment)

Sorry about this we've pushed out a fix for this on galaxy
https://galaxy.ansible.com/ui/repo/staging/netapp/ontap/?version=22.8.2

Explanation on what happened and what we are doing to prevent this again is our repo ansible-collections/netapp.ontap#190

@carchi8py I still see the issue with the following sytle of installation for 8.6.0-1ppa~jammy
add-apt-repository -y --update ppa:ansible/ansible
apt-get install -y ansible

Should it wait until ppa take your fix?

I think https://github.com/ansible/ansible will need to push out a 8.6.1 for the fix to appear. Let me go over there and ping Gundalow

For reference, it looks like there was an issue opened there, and has some more details on who to contact: ansible/ansible#82177 (comment)

We are working on a hottfix 8.6.1 release. Once it's released to PyPI, the PPA can pick it up.

Ansible 8.6.1 has been released. It contains the netapp.ontap 2.8.2 update that fixes this issue.

the PPA builds are in progress... ๐Ÿคž it'll be available within an hour

This now succeeds:

$ docker buildx build .
[+] Building 77.7s (8/8) FINISHED                                                                                                                                                                                                                                                                               docker:default
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                                         0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                                                                           0.0s
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                                      0.0s
 => => transferring dockerfile: 299B                                                                                                                                                                                                                                                                                      0.0s
 => resolve image config for docker.io/docker/dockerfile:1.6                                                                                                                                                                                                                                                              0.5s
 => CACHED docker-image://docker.io/docker/dockerfile:1.6@sha256:ac85f380a63b13dfcefa89046420e1781752bab202122f8f50032edf31be0021                                                                                                                                                                                         0.0s
 => [internal] load metadata for docker.io/library/ubuntu:jammy                                                                                                                                                                                                                                                           0.0s
 => CACHED [1/2] FROM docker.io/library/ubuntu:jammy                                                                                                                                                                                                                                                                      0.0s
 => [2/2] RUN <<INSTALL_PACKAGES (apt-get update...)                                                                                                                                                                                                                                                                     73.5s
 => exporting to image                                                                                                                                                                                                                                                                                                    3.3s 
 => => exporting layers                                                                                                                                                                                                                                                                                                   3.3s 
 => => writing image sha256:74ef76b57bd9b29a86bcc9e55df535e2d79ce874730d0b76d5393f88b56e5bdf  

Awesome - thanks!