Anyone here managed to get the addition of the Hashicorp apt repos baked into cloud-init? The current config I have, which I havent touched for a long while, appears to have stopped working. Here is what I have in my cloud-init currently:
# setup the Hashicorp Debian repo https://learn.hashicorp.com/tutorials/vault/getting-started-install
source: "deb [arch=amd64] https://apt.releases.hashicorp.com focal main"
----BEGIN PGP PUBLIC KEY BLOCK-----
Cloud-init reports the following error though:
2023-10-23 23:32:27,334 - util.py[WARNING]: Gpg error, failed to add key: ----BEGIN PGP PUBLIC KEY BLOCK-----
The page at Official Packaging Guide describes some scripted steps to setup the repo on the Ubuntu VM. Im wondering if anyone here has achieved the same outcome using cloud-init. Cloud-init docs ref Cloud config examples - cloud-init 23.3.1 documentation
Earlier this year (in April) the original signing key for this repository was revoked because we were unable to prove that its private counterpart wasn’t exposed by a CircleCI security incident. If the last time this was working for you was during or before April then this might be the cause of the problem.
However, I can see that the first three lines of the public key block you shared match the public key I just fetched from the server, so this might not actually be the problem. I suggest fetching the current key (linked from the Official Packaging Guide you already found) and checking whether the whole thing matches what’s in your cloud-config YAML file.
Unfortunately at the moment I don’t have any other ideas to share. I’m not familiar with this specific technique, and the documentation for this
apt cloud-config module didn’t give me any clues: what you’ve shared seems consistent with what’s mentioned in the documentation for
sources, although the formatting of that part of the docs is currently a little hard to read.
Thanks for replying (again) @apparentlymart.
I can confirm the key I am using is the current correct one.
I have found a couple of references to known bugs with cloud-init assuming that the
gpg binary is available on the machine during this part of its flow, when in fact it is not. My plan is to first chase things down that rabbit hole and see what I find. Failing that, I think im just going replicate the scripted steps in the Hashicorp docs under a
runcmd: section in the YAML and move on with my life.
The cloud-init docs are… something. There is a lot of them, there are a lot of examples, yet cloud-init can still be difficult to deal with. Like a lot of Hashicorp’s doco and products if im honest.
I’ll post back here with what I find. In the meantime, hopefully someone else here has solved this?
Okay, I went with a little of column A and B.
First up, in the
cloud-config.yaml I add Hashicorp’s public PGP key like this:
- path: /usr/share/keyrings/hashicorp.asc
-----BEGIN PGP PUBLIC KEY BLOCK-----
And then, I add the Hashicorp repo like this:
source: "deb [arch=amd64 signed-by=/usr/share/keyrings/hashicorp.asc] https://apt.releases.hashicorp.com focal main"
That seems to have done the trick and cloud-init does its thing correctly now.