microsoft.ad.cs_template module – Manage AD Certificate Services certificate templates
Note
This module is part of the microsoft.ad collection (version 1.10.0).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install microsoft.ad.
To use it in a playbook, specify: microsoft.ad.cs_template.
New in microsoft.ad 1.11.0
Synopsis
Create, modify, or remove Active Directory Certificate Services (AD CS) certificate templates.
New templates are created by cloning an existing source template and overriding specific properties such as key size, extended key usages, or validity period.
Templates can optionally be published to (or unpublished from) one or more Enterprise Certificate Authorities.
Parameters
Parameter |
Comments |
|---|---|
List of certificate name flag values to set on the template. Each value can be a well-known name or a raw integer (decimal or hex). Multiple values are combined with bitwise OR. Maps to the Well-known names: |
|
The human-readable display name of the template. Defaults to the value of |
|
The FQDN of the domain controller to target for all AD operations. When not specified, the module will use the default domain controller discovery. |
|
List of enrollment flag values to set on the template. Each value can be a well-known name or a raw integer (decimal or hex). Multiple values are combined with bitwise OR. Maps to the Well-known names: |
|
List of Extended Key Usage (EKU) values. Each value can be a well-known name or a raw OID string. Maps to the Well-known names: |
|
Minimum key size in bits for the certificate. Maps to the |
|
List of key usage flags to set on the template. Maps to the Valid values: |
|
The CN (common name) of the certificate template. This is the unique short name used internally by AD CS (no spaces). |
|
List of private key flag values to set on the template. Each value can be a well-known name or a raw integer (decimal or hex). Multiple values are combined with bitwise OR. Maps to the Well-known names: |
|
List of Enterprise CA short names to which the template should be published. When specified, the module ensures the template is published to exactly the listed CAs and unpublished from any others. An empty list When omitted, publishing state is not managed. |
|
Certificate renewal overlap period in days. Maps to the |
|
Certificate template schema version.
Maps to the Choices:
|
|
The display name of an existing template to clone when creating a new template (e.g. Required when creating a template for the first time. Ignored when the template already exists (updates are applied in-place). |
|
Whether the template should be present or absent. When Choices:
|
|
Certificate validity period in days. Maps to the |
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full |
Can run in check_mode and return changed status prediction without modifying target, if not supported the action will be skipped. |
|
Support: none |
Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode |
|
Platform: windows |
Target OS/families that can be operated against |
Notes
Note
This module must be run on a Windows target host with the ActiveDirectory PowerShell module available.
Enterprise Administrator permissions are required to create or remove certificate templates in the Configuration partition.
Certificate templates are stored in the AD Configuration partition and replicated forest-wide.
Publishing a template requires that at least one Enterprise CA is installed in the forest, but the module does not need to run on the CA server itself.
See Also
See also
- microsoft.ad.object_info
Gather information an Active Directory object.
Examples
- name: Create a certificate template cloned from WebServer with RSA 4096
microsoft.ad.cs_template:
name: Web4096Secure
display_name: Web Server (RSA 4096)
source_template: Web Server
key_size: 4096
extended_key_usages:
- server_authentication
key_usage:
- digital_signature
- key_encipherment
private_key_flag:
- exportable_key
certificate_name_flag:
- enrollee_supplies_subject
validity_period_days: 365
renewal_period_days: 42
state: present
- name: Create a template with specific EKUs for server authentication
microsoft.ad.cs_template:
name: CustomAuth
source_template: Web Server
extended_key_usages:
- server_authentication
- "1.3.6.1.4.1.311.20.2.2"
state: present
- name: Use raw integer flags alongside named flags
microsoft.ad.cs_template:
name: MixedFlags
source_template: Web Server
enrollment_flag:
- auto_enrollment
- publish_to_ds
private_key_flag:
- exportable_key
- 0x00000100
state: present
- name: Update key size on an existing template
microsoft.ad.cs_template:
name: Web4096Secure
key_size: 8192
state: present
- name: Publish a template to a specific CA
microsoft.ad.cs_template:
name: Web4096Secure
publish_to_ca:
- contoso-DC01-CA
state: present
- name: Unpublish a template from all CAs
microsoft.ad.cs_template:
name: Web4096Secure
publish_to_ca: []
state: present
- name: Remove a certificate template
microsoft.ad.cs_template:
name: Web4096Secure
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
The distinguished name of the certificate template object. Returned: always Sample: |
|
The OID of the certificate template. Returned: always Sample: |