diff --git a/changelogs/fragments/221-acme-meta.yml b/changelogs/fragments/221-acme-meta.yml new file mode 100644 index 00000000..aa1e660f --- /dev/null +++ b/changelogs/fragments/221-acme-meta.yml @@ -0,0 +1,2 @@ +bugfixes: +- "acme_* modules - avoid crashing for ACME servers where the ``meta`` directory key is not present (https://github.com/ansible-collections/community.crypto/issues/220, https://github.com/ansible-collections/community.crypto/pull/221)." diff --git a/plugins/module_utils/acme/acme.py b/plugins/module_utils/acme/acme.py index 854f6552..4deb653d 100644 --- a/plugins/module_utils/acme/acme.py +++ b/plugins/module_utils/acme/acme.py @@ -82,6 +82,9 @@ class ACMEDirectory(object): for key in ('newNonce', 'newAccount', 'newOrder'): if key not in self.directory: raise ModuleFailException("ACME directory does not seem to follow protocol ACME v2") + # Make sure that 'meta' is always available + if 'meta' not in self.directory: + self.directory['meta'] = {} def __getitem__(self, key): return self.directory[key]