2020-03-09 13:11:34 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2022-07-21 05:27:26 +00:00
|
|
|
# Copyright (c) 2018 Felix Fontein <felix@fontein.de>
|
|
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2020-03-09 13:11:34 +00:00
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
---
|
|
|
|
module: acme_account_info
|
|
|
|
author: "Felix Fontein (@felixfontein)"
|
|
|
|
short_description: Retrieves information on ACME accounts
|
|
|
|
description:
|
2022-11-06 20:10:56 +00:00
|
|
|
- "Allows to retrieve information on accounts a CA supporting the
|
|
|
|
L(ACME protocol,https://tools.ietf.org/html/rfc8555),
|
|
|
|
such as L(Let's Encrypt,https://letsencrypt.org/)."
|
|
|
|
- "This module only works with the ACME v2 protocol."
|
2020-03-09 13:11:34 +00:00
|
|
|
notes:
|
2022-11-06 20:10:56 +00:00
|
|
|
- "The M(community.crypto.acme_account) module allows to modify, create and delete ACME
|
|
|
|
accounts."
|
|
|
|
- "This module was called C(acme_account_facts) before Ansible 2.8. The usage
|
|
|
|
did not change."
|
|
|
|
extends_documentation_fragment:
|
Revert all non-bugfixes merged since the last release.
Revert "Fix documentation. (#751)"
Revert "ACME modules: simplify code, refactor argspec handling code, move csr/csr_content to own docs fragment (#750)"
Revert "Refactor and extend argument spec helper, use for ACME modules (#749)"
Revert "Avoid exception if certificate has no AKI in acme_certificate. (#748)"
Revert "ACME: improve acme_certificate docs, include cert_id in acme_certificate_renewal_info return value (#747)"
Revert "Add acme_certificate_renewal_info module (#746)"
Revert "Refactor time code, add tests, fix bug when parsing absolute timestamps that omit seconds (#745)"
Revert "Add tests for acme_certificate_deactivate_authz module. (#744)"
Revert "Create acme_certificate_deactivate_authz module (#741)"
Revert "acme_certificate: allow to request renewal of a certificate according to ARI (#739)"
Revert "Implement basic acme_ari_info module. (#732)"
Revert "Add function for retrieval of ARI information. (#738)"
Revert "acme module utils: add functions for parsing Retry-After header values and computation of ARI certificate IDs (#737)"
Revert "Implement certificate information retrieval code in the ACME backends. (#736)"
Revert "Split up the default acme docs fragment to allow modules ot not need account data. (#735)"
This reverts commits 5e59c5261e7664c9f823ff2633c67d4d5de931b5, aa82575a786ec0ab79fe549db6bdd77b325767c2,
f3c9cb7a8ac37a7b2565934ff5c4fc63f087407a, f82b33591614fa8013259762865b69b6e7e537ac, 553ab45f46cf5af6bed5867e447e4c9878cf8e68,
59606d48ad26e0a72c64c10eccaca04bf67db548, 0a15be101758333bafce41f11189852d210f4194, 9501a28a934653d61329c8c271879b09cf6b7c27,
d906914737c40b60b23928f3929ff34d25d25c35, 33d278ad8fafedd01591351bbd584f458bb6f1c0, 6d4fc589aee55b81bb0717eed6dd12401785f20c,
9614b09f7a5b744ebb59e9a1b82cb301dc3859cd, af5f4b57f8afa61082e9a24b6218cbc970939e80, c6fbe58382b4a67fb8d86aaec11f89f7445f15ea,
and afe7f7522c34a0b08199dac39501aa041ce5fc57.
2024-05-11 14:06:52 +00:00
|
|
|
- community.crypto.acme
|
2022-11-06 20:10:56 +00:00
|
|
|
- community.crypto.attributes
|
|
|
|
- community.crypto.attributes.actiongroup_acme
|
|
|
|
- community.crypto.attributes.info_module
|
2020-03-09 13:11:34 +00:00
|
|
|
options:
|
|
|
|
retrieve_orders:
|
|
|
|
description:
|
|
|
|
- "Whether to retrieve the list of order URLs or order objects, if provided
|
|
|
|
by the ACME server."
|
2023-06-24 08:00:56 +00:00
|
|
|
- "A value of V(ignore) will not fetch the list of orders."
|
|
|
|
- "If the value is not V(ignore) and the ACME server supports orders, the RV(order_uris)
|
|
|
|
return value is always populated. The RV(orders) return value is only returned
|
|
|
|
if this option is set to V(object_list)."
|
|
|
|
- "Currently, Let's Encrypt does not return orders, so the RV(orders) result
|
2020-03-09 13:11:34 +00:00
|
|
|
will always be empty."
|
|
|
|
type: str
|
|
|
|
choices:
|
|
|
|
- ignore
|
|
|
|
- url_list
|
|
|
|
- object_list
|
|
|
|
default: ignore
|
|
|
|
seealso:
|
2020-06-17 08:29:18 +00:00
|
|
|
- module: community.crypto.acme_account
|
2020-03-09 13:11:34 +00:00
|
|
|
description: Allows to create, modify or delete an ACME account.
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
- name: Check whether an account with the given account key exists
|
2020-03-31 14:23:45 +00:00
|
|
|
community.crypto.acme_account_info:
|
2020-03-09 13:11:34 +00:00
|
|
|
account_key_src: /etc/pki/cert/private/account.key
|
2022-01-03 20:38:37 +00:00
|
|
|
register: account_data
|
2020-03-09 13:11:34 +00:00
|
|
|
- name: Verify that account exists
|
2023-05-15 19:41:18 +00:00
|
|
|
ansible.builtin.assert:
|
2020-03-09 13:11:34 +00:00
|
|
|
that:
|
|
|
|
- account_data.exists
|
|
|
|
- name: Print account URI
|
2020-12-12 17:19:49 +00:00
|
|
|
ansible.builtin.debug:
|
|
|
|
var: account_data.account_uri
|
2020-03-09 13:11:34 +00:00
|
|
|
- name: Print account contacts
|
2020-12-12 17:19:49 +00:00
|
|
|
ansible.builtin.debug:
|
|
|
|
var: account_data.account.contact
|
2020-03-09 13:11:34 +00:00
|
|
|
|
|
|
|
- name: Check whether the account exists and is accessible with the given account key
|
|
|
|
acme_account_info:
|
|
|
|
account_key_content: "{{ acme_account_key }}"
|
|
|
|
account_uri: "{{ acme_account_uri }}"
|
2022-01-03 20:38:37 +00:00
|
|
|
register: account_data
|
2020-03-09 13:11:34 +00:00
|
|
|
- name: Verify that account exists
|
2023-05-15 19:41:18 +00:00
|
|
|
ansible.builtin.assert:
|
2020-03-09 13:11:34 +00:00
|
|
|
that:
|
|
|
|
- account_data.exists
|
|
|
|
- name: Print account contacts
|
2020-12-12 17:19:49 +00:00
|
|
|
ansible.builtin.debug:
|
|
|
|
var: account_data.account.contact
|
2020-03-09 13:11:34 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
RETURN = '''
|
|
|
|
exists:
|
|
|
|
description: Whether the account exists.
|
|
|
|
returned: always
|
|
|
|
type: bool
|
|
|
|
|
|
|
|
account_uri:
|
|
|
|
description: ACME account URI, or None if account does not exist.
|
|
|
|
returned: always
|
|
|
|
type: str
|
|
|
|
|
|
|
|
account:
|
|
|
|
description: The account information, as retrieved from the ACME server.
|
|
|
|
returned: if account exists
|
|
|
|
type: dict
|
|
|
|
contains:
|
|
|
|
contact:
|
|
|
|
description: the challenge resource that must be created for validation
|
|
|
|
returned: always
|
|
|
|
type: list
|
|
|
|
elements: str
|
2022-08-04 18:02:56 +00:00
|
|
|
sample: ['mailto:me@example.com', 'tel:00123456789']
|
2020-03-09 13:11:34 +00:00
|
|
|
status:
|
|
|
|
description: the account's status
|
|
|
|
returned: always
|
|
|
|
type: str
|
|
|
|
choices: ['valid', 'deactivated', 'revoked']
|
|
|
|
sample: valid
|
|
|
|
orders:
|
|
|
|
description:
|
|
|
|
- A URL where a list of orders can be retrieved for this account.
|
2023-06-24 08:00:56 +00:00
|
|
|
- Use the O(retrieve_orders) option to query this URL and retrieve the
|
2020-03-09 13:11:34 +00:00
|
|
|
complete list of orders.
|
|
|
|
returned: always
|
|
|
|
type: str
|
|
|
|
sample: https://example.ca/account/1/orders
|
|
|
|
public_account_key:
|
|
|
|
description: the public account key as a L(JSON Web Key,https://tools.ietf.org/html/rfc7517).
|
|
|
|
returned: always
|
|
|
|
type: str
|
|
|
|
sample: '{"kty":"EC","crv":"P-256","x":"MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4","y":"4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM"}'
|
|
|
|
|
|
|
|
orders:
|
|
|
|
description:
|
|
|
|
- "The list of orders."
|
|
|
|
type: list
|
2021-10-16 19:00:48 +00:00
|
|
|
elements: dict
|
2023-06-24 08:00:56 +00:00
|
|
|
returned: if account exists, O(retrieve_orders) is V(object_list), and server supports order listing
|
2020-03-09 13:11:34 +00:00
|
|
|
contains:
|
|
|
|
status:
|
|
|
|
description: The order's status.
|
|
|
|
type: str
|
|
|
|
choices:
|
|
|
|
- pending
|
|
|
|
- ready
|
|
|
|
- processing
|
|
|
|
- valid
|
|
|
|
- invalid
|
|
|
|
expires:
|
|
|
|
description:
|
|
|
|
- When the order expires.
|
|
|
|
- Timestamp should be formatted as described in RFC3339.
|
2023-06-24 08:00:56 +00:00
|
|
|
- Only required to be included in result when RV(orders[].status) is V(pending) or V(valid).
|
2020-03-09 13:11:34 +00:00
|
|
|
type: str
|
|
|
|
returned: when server gives expiry date
|
|
|
|
identifiers:
|
|
|
|
description:
|
|
|
|
- List of identifiers this order is for.
|
|
|
|
type: list
|
|
|
|
elements: dict
|
|
|
|
contains:
|
|
|
|
type:
|
2023-06-24 08:00:56 +00:00
|
|
|
description: Type of identifier.
|
2020-03-09 13:11:34 +00:00
|
|
|
type: str
|
2023-06-24 08:00:56 +00:00
|
|
|
choices:
|
|
|
|
- dns
|
|
|
|
- ip
|
2020-03-09 13:11:34 +00:00
|
|
|
value:
|
|
|
|
description: Name of identifier. Hostname or IP address.
|
|
|
|
type: str
|
|
|
|
wildcard:
|
2023-06-24 08:00:56 +00:00
|
|
|
description: "Whether RV(orders[].identifiers[].value) is actually a wildcard. The wildcard
|
|
|
|
prefix C(*.) is not included in RV(orders[].identifiers[].value) if this is V(true)."
|
2020-03-09 13:11:34 +00:00
|
|
|
type: bool
|
|
|
|
returned: required to be included if the identifier is wildcarded
|
|
|
|
notBefore:
|
|
|
|
description:
|
|
|
|
- The requested value of the C(notBefore) field in the certificate.
|
|
|
|
- Date should be formatted as described in RFC3339.
|
|
|
|
- Server is not required to return this.
|
|
|
|
type: str
|
|
|
|
returned: when server returns this
|
|
|
|
notAfter:
|
|
|
|
description:
|
|
|
|
- The requested value of the C(notAfter) field in the certificate.
|
|
|
|
- Date should be formatted as described in RFC3339.
|
|
|
|
- Server is not required to return this.
|
|
|
|
type: str
|
|
|
|
returned: when server returns this
|
|
|
|
error:
|
|
|
|
description:
|
|
|
|
- In case an error occurred during processing, this contains information about the error.
|
|
|
|
- The field is structured as a problem document (RFC7807).
|
|
|
|
type: dict
|
|
|
|
returned: when an error occurred
|
|
|
|
authorizations:
|
|
|
|
description:
|
|
|
|
- A list of URLs for authorizations for this order.
|
|
|
|
type: list
|
|
|
|
elements: str
|
|
|
|
finalize:
|
|
|
|
description:
|
|
|
|
- A URL used for finalizing an ACME order.
|
|
|
|
type: str
|
|
|
|
certificate:
|
|
|
|
description:
|
|
|
|
- The URL for retrieving the certificate.
|
|
|
|
type: str
|
|
|
|
returned: when certificate was issued
|
2021-01-27 08:03:34 +00:00
|
|
|
|
|
|
|
order_uris:
|
|
|
|
description:
|
|
|
|
- "The list of orders."
|
2023-06-24 08:00:56 +00:00
|
|
|
- "If O(retrieve_orders) is V(url_list), this will be a list of URLs."
|
|
|
|
- "If O(retrieve_orders) is V(object_list), this will be a list of objects."
|
2021-01-27 08:03:34 +00:00
|
|
|
type: list
|
|
|
|
elements: str
|
2023-06-24 08:00:56 +00:00
|
|
|
returned: if account exists, O(retrieve_orders) is not V(ignore), and server supports order listing
|
2021-01-27 08:03:34 +00:00
|
|
|
version_added: 1.5.0
|
2020-03-09 13:11:34 +00:00
|
|
|
'''
|
|
|
|
|
Revert all non-bugfixes merged since the last release.
Revert "Fix documentation. (#751)"
Revert "ACME modules: simplify code, refactor argspec handling code, move csr/csr_content to own docs fragment (#750)"
Revert "Refactor and extend argument spec helper, use for ACME modules (#749)"
Revert "Avoid exception if certificate has no AKI in acme_certificate. (#748)"
Revert "ACME: improve acme_certificate docs, include cert_id in acme_certificate_renewal_info return value (#747)"
Revert "Add acme_certificate_renewal_info module (#746)"
Revert "Refactor time code, add tests, fix bug when parsing absolute timestamps that omit seconds (#745)"
Revert "Add tests for acme_certificate_deactivate_authz module. (#744)"
Revert "Create acme_certificate_deactivate_authz module (#741)"
Revert "acme_certificate: allow to request renewal of a certificate according to ARI (#739)"
Revert "Implement basic acme_ari_info module. (#732)"
Revert "Add function for retrieval of ARI information. (#738)"
Revert "acme module utils: add functions for parsing Retry-After header values and computation of ARI certificate IDs (#737)"
Revert "Implement certificate information retrieval code in the ACME backends. (#736)"
Revert "Split up the default acme docs fragment to allow modules ot not need account data. (#735)"
This reverts commits 5e59c5261e7664c9f823ff2633c67d4d5de931b5, aa82575a786ec0ab79fe549db6bdd77b325767c2,
f3c9cb7a8ac37a7b2565934ff5c4fc63f087407a, f82b33591614fa8013259762865b69b6e7e537ac, 553ab45f46cf5af6bed5867e447e4c9878cf8e68,
59606d48ad26e0a72c64c10eccaca04bf67db548, 0a15be101758333bafce41f11189852d210f4194, 9501a28a934653d61329c8c271879b09cf6b7c27,
d906914737c40b60b23928f3929ff34d25d25c35, 33d278ad8fafedd01591351bbd584f458bb6f1c0, 6d4fc589aee55b81bb0717eed6dd12401785f20c,
9614b09f7a5b744ebb59e9a1b82cb301dc3859cd, af5f4b57f8afa61082e9a24b6218cbc970939e80, c6fbe58382b4a67fb8d86aaec11f89f7445f15ea,
and afe7f7522c34a0b08199dac39501aa041ce5fc57.
2024-05-11 14:06:52 +00:00
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
|
2021-03-21 08:40:25 +00:00
|
|
|
from ansible_collections.community.crypto.plugins.module_utils.acme.acme import (
|
|
|
|
create_backend,
|
Revert all non-bugfixes merged since the last release.
Revert "Fix documentation. (#751)"
Revert "ACME modules: simplify code, refactor argspec handling code, move csr/csr_content to own docs fragment (#750)"
Revert "Refactor and extend argument spec helper, use for ACME modules (#749)"
Revert "Avoid exception if certificate has no AKI in acme_certificate. (#748)"
Revert "ACME: improve acme_certificate docs, include cert_id in acme_certificate_renewal_info return value (#747)"
Revert "Add acme_certificate_renewal_info module (#746)"
Revert "Refactor time code, add tests, fix bug when parsing absolute timestamps that omit seconds (#745)"
Revert "Add tests for acme_certificate_deactivate_authz module. (#744)"
Revert "Create acme_certificate_deactivate_authz module (#741)"
Revert "acme_certificate: allow to request renewal of a certificate according to ARI (#739)"
Revert "Implement basic acme_ari_info module. (#732)"
Revert "Add function for retrieval of ARI information. (#738)"
Revert "acme module utils: add functions for parsing Retry-After header values and computation of ARI certificate IDs (#737)"
Revert "Implement certificate information retrieval code in the ACME backends. (#736)"
Revert "Split up the default acme docs fragment to allow modules ot not need account data. (#735)"
This reverts commits 5e59c5261e7664c9f823ff2633c67d4d5de931b5, aa82575a786ec0ab79fe549db6bdd77b325767c2,
f3c9cb7a8ac37a7b2565934ff5c4fc63f087407a, f82b33591614fa8013259762865b69b6e7e537ac, 553ab45f46cf5af6bed5867e447e4c9878cf8e68,
59606d48ad26e0a72c64c10eccaca04bf67db548, 0a15be101758333bafce41f11189852d210f4194, 9501a28a934653d61329c8c271879b09cf6b7c27,
d906914737c40b60b23928f3929ff34d25d25c35, 33d278ad8fafedd01591351bbd584f458bb6f1c0, 6d4fc589aee55b81bb0717eed6dd12401785f20c,
9614b09f7a5b744ebb59e9a1b82cb301dc3859cd, af5f4b57f8afa61082e9a24b6218cbc970939e80, c6fbe58382b4a67fb8d86aaec11f89f7445f15ea,
and afe7f7522c34a0b08199dac39501aa041ce5fc57.
2024-05-11 14:06:52 +00:00
|
|
|
get_default_argspec,
|
2021-03-21 08:40:25 +00:00
|
|
|
ACMEClient,
|
|
|
|
)
|
|
|
|
|
|
|
|
from ansible_collections.community.crypto.plugins.module_utils.acme.account import (
|
2020-03-09 13:11:34 +00:00
|
|
|
ACMEAccount,
|
2021-03-21 08:40:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
from ansible_collections.community.crypto.plugins.module_utils.acme.errors import ModuleFailException
|
|
|
|
|
|
|
|
from ansible_collections.community.crypto.plugins.module_utils.acme.utils import (
|
2020-03-09 13:11:34 +00:00
|
|
|
process_links,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-03-21 08:40:25 +00:00
|
|
|
def get_orders_list(module, client, orders_url):
|
2020-03-09 13:11:34 +00:00
|
|
|
'''
|
|
|
|
Retrieves orders list (handles pagination).
|
|
|
|
'''
|
|
|
|
orders = []
|
|
|
|
while orders_url:
|
|
|
|
# Get part of orders list
|
2021-03-21 08:40:25 +00:00
|
|
|
res, info = client.get_request(orders_url, parse_json_result=True, fail_on_error=True)
|
2020-03-09 13:11:34 +00:00
|
|
|
if not res.get('orders'):
|
|
|
|
if orders:
|
|
|
|
module.warn('When retrieving orders list part {0}, got empty result list'.format(orders_url))
|
|
|
|
break
|
|
|
|
# Add order URLs to result list
|
|
|
|
orders.extend(res['orders'])
|
|
|
|
# Extract URL of next part of results list
|
|
|
|
new_orders_url = []
|
|
|
|
|
|
|
|
def f(link, relation):
|
|
|
|
if relation == 'next':
|
|
|
|
new_orders_url.append(link)
|
|
|
|
|
|
|
|
process_links(info, f)
|
|
|
|
new_orders_url.append(None)
|
|
|
|
previous_orders_url, orders_url = orders_url, new_orders_url.pop(0)
|
|
|
|
if orders_url == previous_orders_url:
|
|
|
|
# Prevent infinite loop
|
|
|
|
orders_url = None
|
|
|
|
return orders
|
|
|
|
|
|
|
|
|
2021-03-21 08:40:25 +00:00
|
|
|
def get_order(client, order_url):
|
2020-03-09 13:11:34 +00:00
|
|
|
'''
|
|
|
|
Retrieve order data.
|
|
|
|
'''
|
2021-03-21 08:40:25 +00:00
|
|
|
return client.get_request(order_url, parse_json_result=True, fail_on_error=True)[0]
|
2020-03-09 13:11:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
Revert all non-bugfixes merged since the last release.
Revert "Fix documentation. (#751)"
Revert "ACME modules: simplify code, refactor argspec handling code, move csr/csr_content to own docs fragment (#750)"
Revert "Refactor and extend argument spec helper, use for ACME modules (#749)"
Revert "Avoid exception if certificate has no AKI in acme_certificate. (#748)"
Revert "ACME: improve acme_certificate docs, include cert_id in acme_certificate_renewal_info return value (#747)"
Revert "Add acme_certificate_renewal_info module (#746)"
Revert "Refactor time code, add tests, fix bug when parsing absolute timestamps that omit seconds (#745)"
Revert "Add tests for acme_certificate_deactivate_authz module. (#744)"
Revert "Create acme_certificate_deactivate_authz module (#741)"
Revert "acme_certificate: allow to request renewal of a certificate according to ARI (#739)"
Revert "Implement basic acme_ari_info module. (#732)"
Revert "Add function for retrieval of ARI information. (#738)"
Revert "acme module utils: add functions for parsing Retry-After header values and computation of ARI certificate IDs (#737)"
Revert "Implement certificate information retrieval code in the ACME backends. (#736)"
Revert "Split up the default acme docs fragment to allow modules ot not need account data. (#735)"
This reverts commits 5e59c5261e7664c9f823ff2633c67d4d5de931b5, aa82575a786ec0ab79fe549db6bdd77b325767c2,
f3c9cb7a8ac37a7b2565934ff5c4fc63f087407a, f82b33591614fa8013259762865b69b6e7e537ac, 553ab45f46cf5af6bed5867e447e4c9878cf8e68,
59606d48ad26e0a72c64c10eccaca04bf67db548, 0a15be101758333bafce41f11189852d210f4194, 9501a28a934653d61329c8c271879b09cf6b7c27,
d906914737c40b60b23928f3929ff34d25d25c35, 33d278ad8fafedd01591351bbd584f458bb6f1c0, 6d4fc589aee55b81bb0717eed6dd12401785f20c,
9614b09f7a5b744ebb59e9a1b82cb301dc3859cd, af5f4b57f8afa61082e9a24b6218cbc970939e80, c6fbe58382b4a67fb8d86aaec11f89f7445f15ea,
and afe7f7522c34a0b08199dac39501aa041ce5fc57.
2024-05-11 14:06:52 +00:00
|
|
|
argument_spec = get_default_argspec()
|
|
|
|
argument_spec.update(dict(
|
2020-03-09 13:11:34 +00:00
|
|
|
retrieve_orders=dict(type='str', default='ignore', choices=['ignore', 'url_list', 'object_list']),
|
Revert all non-bugfixes merged since the last release.
Revert "Fix documentation. (#751)"
Revert "ACME modules: simplify code, refactor argspec handling code, move csr/csr_content to own docs fragment (#750)"
Revert "Refactor and extend argument spec helper, use for ACME modules (#749)"
Revert "Avoid exception if certificate has no AKI in acme_certificate. (#748)"
Revert "ACME: improve acme_certificate docs, include cert_id in acme_certificate_renewal_info return value (#747)"
Revert "Add acme_certificate_renewal_info module (#746)"
Revert "Refactor time code, add tests, fix bug when parsing absolute timestamps that omit seconds (#745)"
Revert "Add tests for acme_certificate_deactivate_authz module. (#744)"
Revert "Create acme_certificate_deactivate_authz module (#741)"
Revert "acme_certificate: allow to request renewal of a certificate according to ARI (#739)"
Revert "Implement basic acme_ari_info module. (#732)"
Revert "Add function for retrieval of ARI information. (#738)"
Revert "acme module utils: add functions for parsing Retry-After header values and computation of ARI certificate IDs (#737)"
Revert "Implement certificate information retrieval code in the ACME backends. (#736)"
Revert "Split up the default acme docs fragment to allow modules ot not need account data. (#735)"
This reverts commits 5e59c5261e7664c9f823ff2633c67d4d5de931b5, aa82575a786ec0ab79fe549db6bdd77b325767c2,
f3c9cb7a8ac37a7b2565934ff5c4fc63f087407a, f82b33591614fa8013259762865b69b6e7e537ac, 553ab45f46cf5af6bed5867e447e4c9878cf8e68,
59606d48ad26e0a72c64c10eccaca04bf67db548, 0a15be101758333bafce41f11189852d210f4194, 9501a28a934653d61329c8c271879b09cf6b7c27,
d906914737c40b60b23928f3929ff34d25d25c35, 33d278ad8fafedd01591351bbd584f458bb6f1c0, 6d4fc589aee55b81bb0717eed6dd12401785f20c,
9614b09f7a5b744ebb59e9a1b82cb301dc3859cd, af5f4b57f8afa61082e9a24b6218cbc970939e80, c6fbe58382b4a67fb8d86aaec11f89f7445f15ea,
and afe7f7522c34a0b08199dac39501aa041ce5fc57.
2024-05-11 14:06:52 +00:00
|
|
|
))
|
|
|
|
module = AnsibleModule(
|
|
|
|
argument_spec=argument_spec,
|
|
|
|
required_one_of=(
|
|
|
|
['account_key_src', 'account_key_content'],
|
|
|
|
),
|
|
|
|
mutually_exclusive=(
|
|
|
|
['account_key_src', 'account_key_content'],
|
|
|
|
),
|
|
|
|
supports_check_mode=True,
|
2020-03-09 13:11:34 +00:00
|
|
|
)
|
2021-03-21 08:40:25 +00:00
|
|
|
backend = create_backend(module, True)
|
2020-03-09 13:11:34 +00:00
|
|
|
|
|
|
|
try:
|
2021-03-21 08:40:25 +00:00
|
|
|
client = ACMEClient(module, backend)
|
|
|
|
account = ACMEAccount(client)
|
2020-03-09 13:11:34 +00:00
|
|
|
# Check whether account exists
|
|
|
|
created, account_data = account.setup_account(
|
|
|
|
[],
|
|
|
|
allow_creation=False,
|
|
|
|
remove_account_uri_if_not_exists=True,
|
|
|
|
)
|
|
|
|
if created:
|
|
|
|
raise AssertionError('Unwanted account creation')
|
|
|
|
result = {
|
|
|
|
'changed': False,
|
2021-03-21 08:40:25 +00:00
|
|
|
'exists': client.account_uri is not None,
|
|
|
|
'account_uri': client.account_uri,
|
2020-03-09 13:11:34 +00:00
|
|
|
}
|
2021-03-21 08:40:25 +00:00
|
|
|
if client.account_uri is not None:
|
2020-03-09 13:11:34 +00:00
|
|
|
# Make sure promised data is there
|
|
|
|
if 'contact' not in account_data:
|
|
|
|
account_data['contact'] = []
|
2021-03-21 08:40:25 +00:00
|
|
|
account_data['public_account_key'] = client.account_key_data['jwk']
|
2020-03-09 13:11:34 +00:00
|
|
|
result['account'] = account_data
|
|
|
|
# Retrieve orders list
|
|
|
|
if account_data.get('orders') and module.params['retrieve_orders'] != 'ignore':
|
2021-03-21 08:40:25 +00:00
|
|
|
orders = get_orders_list(module, client, account_data['orders'])
|
2021-01-27 08:03:34 +00:00
|
|
|
result['order_uris'] = orders
|
|
|
|
if module.params['retrieve_orders'] == 'object_list':
|
2021-03-21 08:40:25 +00:00
|
|
|
result['orders'] = [get_order(client, order) for order in orders]
|
2020-03-09 13:11:34 +00:00
|
|
|
module.exit_json(**result)
|
|
|
|
except ModuleFailException as e:
|
|
|
|
e.do_fail(module)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|