community.general.ipa_otptoken – Manage FreeIPA OTPs

Note

This plugin is part of the community.general collection (version 2.5.1).

To install it use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.ipa_otptoken.

New in version 2.5.0: of community.general

Synopsis

  • Add, modify, and delete One Time Passwords in IPA.

Parameters

Parameter Choices/Defaults Comments
algorithm
string
    Choices:
  • sha1
  • sha256
  • sha384
  • sha512
Token hash algorithm.
Note: Cannot be modified after OTP is created.
counter
integer
Initial counter for the HOTP token.
Note: Cannot be modified after OTP is created.
description
string
Description of the token (informational only).
digits
integer
    Choices:
  • 6
  • 8
Number of digits each token code will have.
Note: Cannot be modified after OTP is created.
enabled
boolean
    Choices:
  • no
  • yes ←
Mark the token as enabled (default true).
interval
integer
Length of TOTP token code validity in seconds.
Note: Cannot be modified after OTP is created.
ipa_host
string
Default:
"ipa.example.com"
IP or hostname of IPA server.
If the value is not specified in the task, the value of environment variable IPA_HOST will be used instead.
If both the environment variable IPA_HOST and the value are not specified in the task, then DNS will be used to try to discover the FreeIPA server.
The relevant entry needed in FreeIPA is the 'ipa-ca' entry.
If neither the DNS entry, nor the environment IPA_HOST, nor the value are available in the task, then the default value will be used.
Environment variable fallback mechanism is added in Ansible 2.5.
ipa_pass
string
Password of administrative user.
If the value is not specified in the task, the value of environment variable IPA_PASS will be used instead.
Note that if the 'urllib_gssapi' library is available, it is possible to use GSSAPI to authenticate to FreeIPA.
If the environment variable KRB5CCNAME is available, the module will use this kerberos credentials cache to authenticate to the FreeIPA server.
If the environment variable KRB5_CLIENT_KTNAME is available, and KRB5CCNAME is not; the module will use this kerberos keytab to authenticate.
If GSSAPI is not available, the usage of 'ipa_pass' is required.
Environment variable fallback mechanism is added in Ansible 2.5.
ipa_port
integer
Default:
443
Port of FreeIPA / IPA server.
If the value is not specified in the task, the value of environment variable IPA_PORT will be used instead.
If both the environment variable IPA_PORT and the value are not specified in the task, then default value is set.
Environment variable fallback mechanism is added in Ansible 2.5.
ipa_prot
string
    Choices:
  • http
  • https ←
Protocol used by IPA server.
If the value is not specified in the task, the value of environment variable IPA_PROT will be used instead.
If both the environment variable IPA_PROT and the value are not specified in the task, then default value is set.
Environment variable fallback mechanism is added in Ansible 2.5.
ipa_timeout
integer
Default:
10
Specifies idle timeout (in seconds) for the connection.
For bulk operations, you may want to increase this in order to avoid timeout from IPA server.
If the value is not specified in the task, the value of environment variable IPA_TIMEOUT will be used instead.
If both the environment variable IPA_TIMEOUT and the value are not specified in the task, then default value is set.
ipa_user
string
Default:
"admin"
Administrative account used on IPA server.
If the value is not specified in the task, the value of environment variable IPA_USER will be used instead.
If both the environment variable IPA_USER and the value are not specified in the task, then default value is set.
Environment variable fallback mechanism is added in Ansible 2.5.
model
string
Token model (informational only).
newuniqueid
string
If specified, the unique id specified will be changed to this.
notafter
string
Last date/time the token can be used.
In the format YYYYMMddHHmmss.
For example, 20200121182022 will allow the token to be used until 21 January 2020 at 18:20:22.
notbefore
string
First date/time the token can be used.
In the format YYYYMMddHHmmss.
For example, 20180121182022 will allow the token to be used starting on 21 January 2018 at 18:20:22.
offset
integer
TOTP token / IPA server time difference.
Note: Cannot be modified after OTP is created.
otptype
string
    Choices:
  • totp
  • hotp
Type of OTP.
Note: Cannot be modified after OTP is created.
owner
string
Assigned user of the token.
secretkey
string
Token secret (Base64).
If OTP is created and this is not specified, a random secret will be generated by IPA.
Note: Cannot be modified after OTP is created.
serial
string
Token serial (informational only).
state
string
    Choices:
  • present ←
  • absent
State to ensure.
uniqueid
string / required
Unique ID of the token in IPA.

aliases: name
validate_certs
boolean
    Choices:
  • no
  • yes ←
This only applies if ipa_prot is https.
If set to no, the SSL certificates will not be validated.
This should only set to no used on personally controlled sites using self-signed certificates.
vendor
string
Token vendor name (informational only).

Examples

- name: Create a totp for pinky, allowing the IPA server to generate using defaults
  community.general.ipa_otptoken:
    uniqueid: Token123
    otptype: totp
    owner: pinky
    ipa_host: ipa.example.com
    ipa_user: admin
    ipa_pass: topsecret

- name: Create a 8 digit hotp for pinky with sha256 with specified validity times
  community.general.ipa_otptoken:
    uniqueid: Token123
    enabled: true
    otptype: hotp
    digits: 8
    secretkey: UMKSIER00zT2T2tWMUlTRmNlekRCbFQvWFBVZUh2dElHWGR6T3VUR3IzK2xjaFk9
    algorithm: sha256
    notbefore: 20180121182123
    notafter: 20220121182123
    owner: pinky
    ipa_host: ipa.example.com
    ipa_user: admin
    ipa_pass: topsecret

- name: Update Token123 to indicate a vendor, model, serial number (info only), and description
  community.general.ipa_otptoken:
    uniqueid: Token123
    vendor: Acme
    model: acme101
    serial: SerialNumber1
    description: Acme OTP device
    ipa_host: ipa.example.com
    ipa_user: admin
    ipa_pass: topsecret

- name: Disable Token123
  community.general.ipa_otptoken:
    uniqueid: Token123
    enabled: false
    ipa_host: ipa.example.com
    ipa_user: admin
    ipa_pass: topsecret

- name: Rename Token123 to TokenABC and enable it
  community.general.ipa_otptoken:
    uniqueid: Token123
    newuniqueid: TokenABC
    enabled: true
    ipa_host: ipa.example.com
    ipa_user: admin
    ipa_pass: topsecret

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
otptoken
dictionary
always
OTP Token as returned by IPA API



Authors

  • justchris1 (@justchris1)