Skip to content

Commit

Permalink
New idp management module
Browse files Browse the repository at this point in the history
There is a new netgroup management module placed in the plugins folder:

    plugins/modules/ipaidp.py

The idp module allows to ensure presence or absence of external Identity
Providers.

Here is the documentation for the module:

    README-idp.md

New idp example playbooks:

    # playbooks/idp/idp-present.yml
    # playbooks/idp/idp-absent.yml

New tests for the module:

    tests/idp/test_idp.yml
    tests/idp/test_idp_client_context.yml
  • Loading branch information
t-woerner committed Sep 7, 2023
1 parent 88d4a36 commit 84c2f72
Show file tree
Hide file tree
Showing 8 changed files with 827 additions and 1 deletion.
108 changes: 108 additions & 0 deletions README-idp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
Idp module
============

Description
-----------

The idp module allows to ensure presence and absence of idps.

Features
--------

* Idp management


Supported FreeIPA Versions
--------------------------

FreeIPA versions 4.4.0 and up are supported by the ipaidp module.


Requirements
------------

**Controller**
* Ansible version: 2.8+

**Node**
* Supported FreeIPA version (see above)


Usage
=====

Example inventory file

```ini
[ipaserver]
ipaserver.test.local
```


Example playbook to make sure idp "NAME" is present:

```yaml
---
- name: Playbook to manage IPA idp.
hosts: ipaserver
become: false

tasks:
- ipaidp:
ipaadmin_password: SomeADMINpassword
name: NAME
# Add needed parameters here
```


Example playbook to make sure idp "NAME" is absent:

```yaml
---
- name: Playbook to manage IPA idp.
hosts: ipaserver
become: false

tasks:
- ipaidp:
ipaadmin_password: SomeADMINpassword
name: NAME
state: absent
```
MORE EXAMPLE PLAYBOOKS HERE
Variables
---------
Variable | Description | Required
-------- | ----------- | --------
`ipaadmin_principal` | The admin principal is a string and defaults to `admin` | no
`ipaadmin_password` | The admin password is a string and is required if there is no admin ticket available on the node | no
`ipaapi_context` | The context in which the module will execute. Executing in a server context is preferred. If not provided context will be determined by the execution environment. Valid values are `server` and `client`. | no
`ipaapi_ldap_cache` | Use LDAP cache for IPA connection. The bool setting defaults to true. (bool) | false
`name` \| `cn` | The list of idp name strings. | yes
auth_uri \| ipaidpauthendpoint | OAuth 2.0 authorization endpoint string. | no
dev_auth_uri \| ipaidpdevauthendpoint | Device authorization endpoint string. | no
token_uri \| ipaidptokenendpoint | Token endpoint string. | no
userinfo_uri \| ipaidpuserinfoendpoint | User information endpoint string. | no
keys_uri \| ipaidpkeysendpoint | JWKS endpoint string. | no
issuer_url \| ipaidpissuerurl | The Identity Provider OIDC URL string. | no
client_id \| ipaidpclientid | OAuth 2.0 client identifier string. | no
secret \| ipaidpclientsecret | OAuth 2.0 client secret string. | no
scope \| ipaidpscope | OAuth 2.0 scope string. Multiple scopes separated by space. | no
idp_user_id \| ipaidpsub | Attribute string for user identity in OAuth 2.0 userinfo. | no
provider \| ipaidpprovider | Pre-defined template string. Choices: ["google","github","microsoft","okta","keycloak"] | no
organization \| ipaidporg | Organization ID string or Realm name for IdP provider templates. | no
base_url \| ipaidpbaseurl | Base URL string for IdP provider templates. | no
rename \| new_name | New name for the Identity Provider server object. Only with `state: renamed`. | no
delete_continue \| continue | Continuous mode. Don't stop on errors. Valid only if `state` is `absent`. | no
`state` | The state to ensure. It can be one of `present`, `absent`, `renamed`, default: `present`. | no


Authors
=======

Thomas Woerner
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Features
* Modules for hbacsvcgroup management
* Modules for host management
* Modules for hostgroup management
* Modules for idp management
* Modules for idrange management
* Modules for location management
* Modules for netgroup management
Expand Down Expand Up @@ -450,6 +451,7 @@ Modules in plugin/modules
* [ipahbacsvcgroup](README-hbacsvcgroup.md)
* [ipahost](README-host.md)
* [ipahostgroup](README-hostgroup.md)
* [idp](README-idp.md)
* [idrange](README-idrange.md)
* [ipalocation](README-location.md)
* [ipanetgroup](README-netgroup.md)
Expand Down
11 changes: 11 additions & 0 deletions playbooks/idp/idp-absent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- name: Idp absent example
hosts: ipaserver
become: no

tasks:
- name: Ensure idp NAME is absent
ipaidp:
ipaadmin_password: SomeADMINpassword
name: NAME
state: absent
11 changes: 11 additions & 0 deletions playbooks/idp/idp-present.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- name: Idp present example
hosts: ipaserver
become: no

tasks:
- name: Ensure idp NAME is present
ipaidp:
ipaadmin_password: SomeADMINpassword
name: NAME
# Add needed parameters here
3 changes: 2 additions & 1 deletion plugins/module_utils/ansible_freeipa_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"kinit_password", "kinit_keytab", "run", "DN", "VERSION",
"paths", "tasks", "get_credentials_if_valid", "Encoding",
"DNSName", "getargspec", "certificate_loader",
"write_certificate_list", "boolean"]
"write_certificate_list", "boolean", "template_str"]

import os
# ansible-freeipa requires locale to be C, IPA requires utf-8.
Expand Down Expand Up @@ -90,6 +90,7 @@ def getargspec(func):
except ImportError:
from ipapython.ipautil import kinit_password, kinit_keytab
from ipapython.ipautil import run
from ipapython.ipautil import template_str
from ipapython.dn import DN
from ipapython.version import VERSION
from ipaplatform.paths import paths
Expand Down
Loading

0 comments on commit 84c2f72

Please sign in to comment.