module cc_apt_configure must make sure gnupg is installed

Bug #1855432 reported by do3meli
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Expired
Medium
Unassigned

Bug Description

when using the module cc_apt_configure we need to make sure that gnupg is installed before using apt-key add to add a certain apt key.

The most recent debian 10 cloud image from https://cdimage.debian.org/cdimage/openstack/10.2.0/ is for example not really happy when using the below config:

#cloud-config
apt:
  http_proxy: http://10.0.0.2:3128/
  https_proxy: http://10.0.0.2:3128/
  sources:
    saltstack:
      source: "deb http://repo.saltstack.com/py3/debian/10/amd64/latest buster main"
      key: |
                -----BEGIN PGP PUBLIC KEY BLOCK-----
                Version: GnuPG v2

                mQENBFOpvpgBCADkP656H41i8fpplEEB8IeLhugyC2rTEwwSclb8tQNYtUiGdna9
                m38kb0OS2DDrEdtdQb2hWCnswxaAkUunb2qq18vd3dBvlnI+C4/xu5ksZZkRj+fW
                tArNR18V+2jkwcG26m8AxIrT+m4M6/bgnSfHTBtT5adNfVcTHqiT1JtCbQcXmwVw
                WbqS6v/LhcsBE//SHne4uBCK/GHxZHhQ5jz5h+3vWeV4gvxS3Xu6v1IlIpLDwUts
                kT1DumfynYnnZmWTGc6SYyIFXTPJLtnoWDb9OBdWgZxXfHEcBsKGha+bXO+m2tHA
                gNneN9i5f8oNxo5njrL8jkCckOpNpng18BKXABEBAAG0MlNhbHRTdGFjayBQYWNr
                YWdpbmcgVGVhbSA8cGFja2FnaW5nQHNhbHRzdGFjay5jb20+iQE4BBMBAgAiBQJT
                qb6YAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRAOCKFJ3le/vhkqB/0Q
                WzELZf4d87WApzolLG+zpsJKtt/ueXL1W1KA7JILhXB1uyvVORt8uA9FjmE083o1
                yE66wCya7V8hjNn2lkLXboOUd1UTErlRg1GYbIt++VPscTxHxwpjDGxDB1/fiX2o
                nK5SEpuj4IeIPJVE/uLNAwZyfX8DArLVJ5h8lknwiHlQLGlnOu9ulEAejwAKt9CU
                4oYTszYM4xrbtjB/fR+mPnYh2fBoQO4d/NQiejIEyd9IEEMd/03AJQBuMux62tjA
                /NwvQ9eqNgLw9NisFNHRWtP4jhAOsshv1WW+zPzu3ozoO+lLHixUIz7fqRk38q8Q
                9oNR31KvrkSNrFbA3D89uQENBFOpvpgBCADJ79iH10AfAfpTBEQwa6vzUI3Eltqb
                9aZ0xbZV8V/8pnuU7rqM7Z+nJgldibFk4gFG2bHCG1C5aEH/FmcOMvTKDhJSFQUx
                uhgxttMArXm2c22OSy1hpsnVG68G32Nag/QFEJ++3hNnbyGZpHnPiYgej3FrerQJ
                zv456wIsxRDMvJ1NZQB3twoCqwapC6FJE2hukSdWB5yCYpWlZJXBKzlYz/gwD/Fr
                GL578WrLhKw3UvnJmlpqQaDKwmV2s7MsoZogC6wkHE92kGPG2GmoRD3ALjmCvN1E
                PsIsQGnwpcXsRpYVCoW7e2nW4wUf7IkFZ94yOCmUq6WreWI4NggRcFC5ABEBAAGJ
                AR8EGAECAAkFAlOpvpgCGwwACgkQDgihSd5Xv74/NggA08kEdBkiWWwJZUZEy7cK
                WWcgjnRuOHd4rPeT+vQbOWGu6x4bxuVf9aTiYkf7ZjVF2lPn97EXOEGFWPZeZbH4
                vdRFH9jMtP+rrLt6+3c9j0M8SIJYwBL1+CNpEC/BuHj/Ra/cmnG5ZNhYebm76h5f
                T9iPW9fFww36FzFka4VPlvA4oB7ebBtquFg3sdQNU/MmTVV4jPFWXxh4oRDDR+8N
                1bcPnbB11b5ary99F/mqr7RgQ+YFF0uKRE3SKa7a+6cIuHEZ7Za+zhPaQlzAOZlx
                fuBmScum8uQTrEF5+Um5zkwC7EXTdH1co/+/V/fpOtxIg4XO4kcugZefVm5ERfVS
                MA==
                =dtMN
                -----END PGP PUBLIC KEY BLOCK-----

It will then throw the following errors:

[ 21.870823] cloud-init[494]: 2019-12-06 11:26:16,967 - cc_apt_configure.py[ERROR]: failed to add apt GPG Key to apt keyring
[ 21.875126] cloud-init[494]: Traceback (most recent call last):
[ 21.877629] cloud-init[494]: File "/usr/lib/python3/dist-packages/cloudinit/config/cc_apt_configure.py", line 551, in add_apt_key_raw
[ 21.881435] cloud-init[494]: util.subp(['apt-key', 'add', '-'], data=key.encode(), target=target)
[ 21.884155] cloud-init[494]: File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 2027, in subp
[ 21.886831] cloud-init[494]: cmd=args)
[ 21.888611] cloud-init[494]: cloudinit.util.ProcessExecutionError: Unexpected error while running command.
[ 21.891311] cloud-init[494]: Command: ['apt-key', 'add', '-']
[ 21.893090] cloud-init[494]: Exit code: 255
[ 21.894566] cloud-init[494]: Reason: -
[ 21.895819] cloud-init[494]: Stdout:
[ 21.897109] cloud-init[494]: Stderr: E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation
[ 21.899870] cloud-init[494]: 2019-12-06 11:26:16,973 - util.py[WARNING]: Running module apt-configure (<module 'cloudinit.config.cc_apt_configure' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_apt_configure.py'>) failed

do3meli (d-info-e)
description: updated
Ryan Harper (raharper)
Changed in cloud-init:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
James Falcon (falcojr) wrote :
Changed in cloud-init:
status: Triaged → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.