mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-03-28 22:33:05 +00:00
Compare commits
91 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16a4eb81ce | ||
|
|
cd16490531 | ||
|
|
7b6bc32fa0 | ||
|
|
6b3fb78db6 | ||
|
|
67df9e83c7 | ||
|
|
14be339af0 | ||
|
|
76251ead2c | ||
|
|
74028bd36c | ||
|
|
43217b9e70 | ||
|
|
96209f6945 | ||
|
|
7eac30127a | ||
|
|
719d1cd056 | ||
|
|
832d44d986 | ||
|
|
82f403c0de | ||
|
|
fa4a90e628 | ||
|
|
c38ff9b78c | ||
|
|
85b1c54ce1 | ||
|
|
6d5f3f3274 | ||
|
|
1dba4ba408 | ||
|
|
e867373fc0 | ||
|
|
c5c8cb3b04 | ||
|
|
8944999657 | ||
|
|
b7a04bc49b | ||
|
|
935bef4b9f | ||
|
|
8e139e2fe9 | ||
|
|
332d41dc46 | ||
|
|
ab94ff07a0 | ||
|
|
5a5b3c1655 | ||
|
|
74663b877a | ||
|
|
2f06f194f1 | ||
|
|
3148c10480 | ||
|
|
f4187a1453 | ||
|
|
7126dec0f3 | ||
|
|
3d241e55b4 | ||
|
|
173acf282b | ||
|
|
39ba225784 | ||
|
|
b7ccd8fed5 | ||
|
|
ef94b703df | ||
|
|
0dc58be3f6 | ||
|
|
b64da1dbb7 | ||
|
|
84b5d33c62 | ||
|
|
5ac7143f42 | ||
|
|
07d91e02d1 | ||
|
|
127d758100 | ||
|
|
4ff6e35c28 | ||
|
|
a1230cabc6 | ||
|
|
411f5f3467 | ||
|
|
8779384614 | ||
|
|
2cc1484ad7 | ||
|
|
77c1d206d3 | ||
|
|
52241fe233 | ||
|
|
f53ca3ad39 | ||
|
|
60905ef5bf | ||
|
|
0d48da060d | ||
|
|
5cdbcf6442 | ||
|
|
08b0fc02ba | ||
|
|
6cec03eb15 | ||
|
|
65a1fd7804 | ||
|
|
bcb6a68230 | ||
|
|
8f8a16f815 | ||
|
|
bfcc62a27f | ||
|
|
8ba32bfc26 | ||
|
|
69306a6177 | ||
|
|
967a2d8e56 | ||
|
|
2626715db6 | ||
|
|
2166a9f7a2 | ||
|
|
8b4bb631a5 | ||
|
|
f17f83d6bd | ||
|
|
a3517a3a23 | ||
|
|
5aa1c7cb57 | ||
|
|
15e9201dab | ||
|
|
6caa58e8be | ||
|
|
5c61f14cc1 | ||
|
|
b3a74e616a | ||
|
|
cbff802d13 | ||
|
|
4ceb6aa05d | ||
|
|
35614d7a88 | ||
|
|
7a9ea832a1 | ||
|
|
2804ec3f83 | ||
|
|
bef748cfdc | ||
|
|
c24e8b498e | ||
|
|
fe16df8a6c | ||
|
|
d804dc470e | ||
|
|
8fa3daece8 | ||
|
|
0cad1fa879 | ||
|
|
780e6b1436 | ||
|
|
216a5d4f9d | ||
|
|
f8ff833b03 | ||
|
|
b92da82661 | ||
|
|
ce05b5e137 | ||
|
|
a826bf1781 |
2
.github/workflows/ansible-test.yml
vendored
2
.github/workflows/ansible-test.yml
vendored
@@ -8,7 +8,7 @@ jobs:
|
||||
name: Verify ansible-test sanity
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.1.0
|
||||
- uses: actions/checkout@v4.1.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Run ansible-test
|
||||
|
||||
24
.github/workflows/docs.yml
vendored
24
.github/workflows/docs.yml
vendored
@@ -8,10 +8,10 @@ jobs:
|
||||
name: Check Ansible Documentation with ansible-core 2.13.
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.1.0
|
||||
- uses: actions/checkout@v4.1.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-python@v4.3.0
|
||||
fetch-depth: 1
|
||||
- uses: actions/setup-python@v5.1.0
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Install Ansible 2.13
|
||||
@@ -25,10 +25,10 @@ jobs:
|
||||
name: Check Ansible Documentation with ansible-core 2.14.
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.1.0
|
||||
- uses: actions/checkout@v4.1.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-python@v4.3.0
|
||||
fetch-depth: 1
|
||||
- uses: actions/setup-python@v5.1.0
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Install Ansible 2.14
|
||||
@@ -42,10 +42,10 @@ jobs:
|
||||
name: Check Ansible Documentation with ansible-core 2.15.
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.1.0
|
||||
- uses: actions/checkout@v4.1.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-python@v4.3.0
|
||||
fetch-depth: 1
|
||||
- uses: actions/setup-python@v5.1.0
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Install Ansible 2.15
|
||||
@@ -59,10 +59,10 @@ jobs:
|
||||
name: Check Ansible Documentation with latest Ansible version.
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.1.0
|
||||
- uses: actions/checkout@v4.1.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-python@v4.3.0
|
||||
fetch-depth: 1
|
||||
- uses: actions/setup-python@v5.1.0
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Install Ansible-latest
|
||||
|
||||
34
.github/workflows/lint.yml
vendored
34
.github/workflows/lint.yml
vendored
@@ -8,15 +8,15 @@ jobs:
|
||||
name: Verify ansible-lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.1.0
|
||||
- uses: actions/checkout@v4.1.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-python@v4.3.0
|
||||
- uses: actions/setup-python@v5.1.0
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Run ansible-lint
|
||||
run: |
|
||||
pip install "ansible-core>=2.16,<2.17" 'ansible-lint>=6.22'
|
||||
pip install "ansible-core>=2.16,<2.17" 'ansible-lint==6.22'
|
||||
utils/build-galaxy-release.sh -ki
|
||||
cd .galaxy-build
|
||||
ansible-lint --profile production --exclude tests/integration/ --exclude tests/unit/ --parseable --nocolor
|
||||
@@ -25,10 +25,10 @@ jobs:
|
||||
name: Verify yamllint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.1.0
|
||||
- uses: actions/checkout@v4.1.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-python@v4.3.0
|
||||
fetch-depth: 1
|
||||
- uses: actions/setup-python@v5.1.0
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Run yaml-lint
|
||||
@@ -38,10 +38,10 @@ jobs:
|
||||
name: Verify pydocstyle
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.1.0
|
||||
- uses: actions/checkout@v4.1.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-python@v4.3.0
|
||||
fetch-depth: 1
|
||||
- uses: actions/setup-python@v5.1.0
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Run pydocstyle
|
||||
@@ -53,10 +53,10 @@ jobs:
|
||||
name: Verify flake8
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.1.0
|
||||
- uses: actions/checkout@v4.1.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-python@v4.3.0
|
||||
fetch-depth: 1
|
||||
- uses: actions/setup-python@v5.1.0
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Run flake8
|
||||
@@ -68,10 +68,10 @@ jobs:
|
||||
name: Verify pylint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.1.0
|
||||
- uses: actions/checkout@v4.1.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-python@v4.3.0
|
||||
fetch-depth: 1
|
||||
- uses: actions/setup-python@v5.1.0
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Run pylint
|
||||
@@ -83,8 +83,8 @@ jobs:
|
||||
name: Shellcheck
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.1.0
|
||||
- uses: actions/checkout@v4.1.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-depth: 1
|
||||
- name: Run ShellCheck
|
||||
uses: ludeeus/action-shellcheck@master
|
||||
|
||||
4
.github/workflows/readme.yml
vendored
4
.github/workflows/readme.yml
vendored
@@ -8,9 +8,9 @@ jobs:
|
||||
name: Verify readme
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.1.0
|
||||
- uses: actions/checkout@v4.1.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-depth: 1
|
||||
- name: Run readme test
|
||||
run: |
|
||||
error=0
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
repos:
|
||||
- repo: https://github.com/ansible/ansible-lint.git
|
||||
rev: v6.22.0
|
||||
rev: v24.5.0
|
||||
hooks:
|
||||
- id: ansible-lint
|
||||
always_run: false
|
||||
@@ -21,20 +21,20 @@ repos:
|
||||
--parseable
|
||||
--nocolor
|
||||
- repo: https://github.com/adrienverge/yamllint.git
|
||||
rev: v1.32.0
|
||||
rev: v1.35.1
|
||||
hooks:
|
||||
- id: yamllint
|
||||
files: \.(yaml|yml)$
|
||||
- repo: https://github.com/pycqa/flake8
|
||||
rev: 6.0.0
|
||||
rev: 7.0.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
- repo: https://github.com/pycqa/pydocstyle
|
||||
rev: 6.0.0
|
||||
rev: 6.3.0
|
||||
hooks:
|
||||
- id: pydocstyle
|
||||
- repo: https://github.com/pycqa/pylint
|
||||
rev: v3.0.2
|
||||
rev: v3.2.2
|
||||
hooks:
|
||||
- id: pylint
|
||||
args:
|
||||
|
||||
@@ -22,7 +22,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -21,7 +21,7 @@ FreeIPA versions 4.4.0 and up are supported by the ipaautomountkey module.
|
||||
Requirements
|
||||
------------
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -21,7 +21,7 @@ FreeIPA versions 4.4.0 and up are supported by the ipaautomountlocation module.
|
||||
Requirements
|
||||
------------
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -21,7 +21,7 @@ FreeIPA versions 4.4.0 and up are supported by the ipaautomountmap module.
|
||||
Requirements
|
||||
------------
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -25,7 +25,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
* Some tool to generate a certificate signing request (CSR) might be needed, like `openssl`.
|
||||
|
||||
**Node**
|
||||
|
||||
@@ -25,7 +25,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -23,7 +23,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -22,7 +22,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -21,7 +21,7 @@ FreeIPA versions 4.4.0 and up are supported by the ipadnsforwardzone module.
|
||||
Requirements
|
||||
------------
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -22,7 +22,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -23,7 +23,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
|
||||
**Node**
|
||||
@@ -135,7 +135,7 @@ Example playbook to enable a zone:
|
||||
|
||||
Example playbook to allow per-zone privilege delegation:
|
||||
|
||||
``` yaml
|
||||
```yaml
|
||||
---
|
||||
- name: Playbook to enable per-zone privilege delegation
|
||||
hosts: ipaserver
|
||||
|
||||
@@ -29,7 +29,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
@@ -158,7 +158,7 @@ Several groups can also be renamed with a single task, as in the example playboo
|
||||
gather_facts: false
|
||||
|
||||
tasks:
|
||||
- name Rename group1 to newgroup1 and group2 to newgroup2
|
||||
- name: Rename group1 to newgroup1 and group2 to newgroup2
|
||||
ipagroup:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
groups:
|
||||
|
||||
@@ -22,7 +22,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -22,7 +22,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -22,7 +22,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -24,7 +24,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -26,7 +26,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -29,7 +29,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -29,7 +29,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -22,7 +22,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -37,7 +37,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -29,7 +29,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
106
README-inventory-plugin-freeipa.md
Normal file
106
README-inventory-plugin-freeipa.md
Normal file
@@ -0,0 +1,106 @@
|
||||
Inventory plugin
|
||||
================
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
|
||||
The inventory plugin compiles a dynamic inventory from IPA domain. The servers can be filtered by their role(s).
|
||||
|
||||
This plugin is using the Python requests binding, that is only available for Python 3.7 and up.
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
* Dynamic inventory
|
||||
|
||||
|
||||
Supported FreeIPA Versions
|
||||
--------------------------
|
||||
|
||||
FreeIPA versions 4.6.0 and up are supported by the inventory plugin.
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
The inventory plugin is automatically enabled from the Ansible collection or from the top directory of the git repo if the `plugins` folder is linked to `~/.ansible`.
|
||||
|
||||
If `ansible.cfg` was modified to point to the roles and modules with `roles_path`, `library` and `module_utils` tag, then it is needed to set `inventory_plugins` also:
|
||||
|
||||
```
|
||||
inventory_plugins = /my/dir/ansible-freeipa/plugins/inventory
|
||||
```
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
Example inventory file "freeipa.yml":
|
||||
|
||||
```yml
|
||||
---
|
||||
plugin: freeipa
|
||||
server: server.ipa.local
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
```
|
||||
|
||||
Example inventory file "freeipa.yml" with server TLS certificate verification using local copy of `/etc/ipa/ca.crt` from the server:
|
||||
|
||||
```yml
|
||||
---
|
||||
plugin: freeipa
|
||||
server: server.ipa.local
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
verify: ca.crt
|
||||
```
|
||||
|
||||
|
||||
How to use the plugin
|
||||
---------------------
|
||||
|
||||
With the `ansible-inventory` command it is possible to show the generated inventorey:
|
||||
|
||||
```bash
|
||||
ansible-inventory -v -i freeipa.yml --graph
|
||||
```
|
||||
|
||||
Example inventory file "freeipa.yml" for use with `playbooks/config/retrieve-config.yml`:
|
||||
|
||||
```yml
|
||||
---
|
||||
plugin: freeipa
|
||||
server: server.ipa.local
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
inventory_group: ipaserver
|
||||
```
|
||||
|
||||
```bash
|
||||
ansible-playbook -u root -i ipa.yml playbooks/config/retrieve-config.yml
|
||||
```
|
||||
|
||||
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
|
||||
`server` | The FQDN of server to start the scan. (string) | yes
|
||||
`verify` | The server TLS certificate file for verification (/etc/ipa/ca.crt). Turned off if not set. (string) | yes
|
||||
`role` | The role(s) of the server. If several roles are given, only servers that have all the roles are returned. (list of strings) (choices: "IPA master", "CA server", "KRA server", "DNS server", "AD trust controller", "AD trust agent") | no
|
||||
`inventory_group` | The inventory group to create. The default group name is "ipaservers". | no
|
||||
|
||||
Authors
|
||||
=======
|
||||
|
||||
- Thomas Woerner
|
||||
@@ -22,7 +22,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -22,7 +22,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -22,7 +22,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -22,7 +22,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -22,7 +22,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -25,7 +25,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -23,7 +23,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -22,7 +22,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -25,7 +25,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FReeIPA version (see above)
|
||||
@@ -282,6 +282,65 @@ Example playbook to allow users, groups, hosts or hostgroups to retrieve a keyta
|
||||
```
|
||||
|
||||
|
||||
Example playbook to ensure presence of serveral services in a single task:
|
||||
|
||||
```yaml
|
||||
---
|
||||
- name: Playbook to manage IPA service.
|
||||
hosts: ipaserver
|
||||
|
||||
tasks:
|
||||
- name: Ensure services are present
|
||||
ipaservice:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
services:
|
||||
- name: HTTP/www.example.com
|
||||
principal:
|
||||
- host/host1.example.com
|
||||
- name: mysvc/www.example.com
|
||||
pac_type: NONE
|
||||
ok_as_delegate: yes
|
||||
ok_to_auth_as_delegate: yes
|
||||
- name: HTTP/www.example.com
|
||||
allow_create_keytab_user:
|
||||
- user01
|
||||
- user02
|
||||
allow_create_keytab_group:
|
||||
- group01
|
||||
- group02
|
||||
allow_create_keytab_host:
|
||||
- host1.example.com
|
||||
- host2.example.com
|
||||
allow_create_keytab_hostgroup:
|
||||
- hostgroup01
|
||||
- hostgroup02
|
||||
- name: mysvc/host2.example.com
|
||||
auth_ind: otp,radius
|
||||
```
|
||||
|
||||
|
||||
Example playbook to ensure presence of serveral services in a single task with `member` `action`:
|
||||
|
||||
```yaml
|
||||
---
|
||||
- name: Playbook to manage IPA service.
|
||||
hosts: ipaserver
|
||||
become: true
|
||||
gather_facts: false
|
||||
|
||||
tasks:
|
||||
- name: Ensure service host members are present
|
||||
ipaservice:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
services:
|
||||
- name: HTTP/www1.example.com
|
||||
host: host1.example.com
|
||||
- name: HTTP/www2.example.com
|
||||
host: host2.example.com
|
||||
action: member
|
||||
```
|
||||
|
||||
|
||||
Variables
|
||||
---------
|
||||
|
||||
@@ -291,7 +350,15 @@ Variable | Description | Required
|
||||
`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 yes. (bool) | no
|
||||
`name` \| `service` | The list of service name strings. | yes
|
||||
`name` \| `service` | The list of service name strings. `name` with *service variables* or `services` containing *service variables* need to be used. | no
|
||||
`action` | Work on service or member level. It can be on of `member` or `service` and defaults to `service`. | no
|
||||
`state` | The state to ensure. It can be one of `present`, `absent`, or `disabled`, default: `present`. | no
|
||||
|
||||
|
||||
**Service Variables:**
|
||||
|
||||
Variable | Description | Required
|
||||
-------- | ----------- | --------
|
||||
`certificate` \| `usercertificate` | Base-64 encoded service certificate. | no
|
||||
`pac_type` \| `ipakrbauthzdata` | Supported PAC type. It can be one of `MS-PAC`, `PAD`, or `NONE`. Use empty string to reset pac_type to the initial value. | no
|
||||
`auth_ind` \| `krbprincipalauthind` | Defines an allow list for Authentication Indicators. It can be any of `otp`, `radius`, `pkinit`, `hardened`, `idp` or `""`. An additional check ensures that only types can be used that are supported by the IPA version. Use empty string to reset auth_ind to the initial value. | no
|
||||
@@ -310,11 +377,9 @@ Variable | Description | Required
|
||||
`allow_retrieve_keytab_group` \| `ipaallowedtoperform_read_keys_group` | Groups allowed to retrieve a keytab of this host. | no
|
||||
`allow_retrieve_keytab_host` \| `ipaallowedtoperform_read_keys_host` | Hosts allowed to retrieve a keytab from of host. | no
|
||||
`allow_retrieve_keytab_hostgroup` \| `ipaallowedtoperform_read_keys_hostgroup` | Host groups allowed to retrieve a keytab of this host. | no
|
||||
`continue` | Continuous mode: don't stop on errors. Valid only if `state` is `absent`. Default: `no` (bool) | no
|
||||
`smb` | Service is an SMB service. If set, `cifs/` will be prefixed to the service name if needed. | no
|
||||
`netbiosname` | NETBIOS name for the SMB service. Only with `smb: yes`. | no
|
||||
`action` | Work on service or member level. It can be on of `member` or `service` and defaults to `service`. | no
|
||||
`state` | The state to ensure. It can be one of `present`, `absent`, or `disabled`, default: `present`. | no
|
||||
`continue` \| `delete_continue` | Continuous mode: don't stop on errors. Valid only if `state` is `absent`. Default: `no` (bool) | no
|
||||
|
||||
|
||||
Authors
|
||||
|
||||
@@ -24,7 +24,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -24,7 +24,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -24,7 +24,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -24,7 +24,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -22,7 +22,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -22,7 +22,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -21,7 +21,7 @@ Requirements
|
||||
|
||||
**Controller**
|
||||
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
@@ -311,7 +311,7 @@ Example playbook to rename users:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
name: pinky
|
||||
rename: reddy
|
||||
state: enabled
|
||||
state: renamed
|
||||
```
|
||||
|
||||
Example playbook to unlock users:
|
||||
|
||||
@@ -24,7 +24,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
15
README.md
15
README.md
@@ -13,6 +13,7 @@ Features
|
||||
* Repair mode for clients
|
||||
* Backup and restore, also to and from controller
|
||||
* Smartcard setup for servers and clients
|
||||
* Inventory plugin freeipa
|
||||
* Modules for automembership rule management
|
||||
* Modules for automount key management
|
||||
* Modules for automount location management
|
||||
@@ -73,7 +74,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
@@ -108,9 +109,10 @@ You can use the roles directly within the top directory of the git repo, but to
|
||||
You can either adapt ansible.cfg:
|
||||
|
||||
```
|
||||
roles_path = /my/dir/ansible-freeipa/roles
|
||||
library = /my/dir/ansible-freeipa/plugins/modules
|
||||
module_utils = /my/dir/ansible-freeipa/plugins/module_utils
|
||||
roles_path = /my/dir/ansible-freeipa/roles
|
||||
library = /my/dir/ansible-freeipa/plugins/modules
|
||||
module_utils = /my/dir/ansible-freeipa/plugins/module_utils
|
||||
inventory_plugins = /my/dir/ansible-freeipa/plugins/inventory
|
||||
```
|
||||
|
||||
Or you can link the directories:
|
||||
@@ -470,3 +472,8 @@ Modules in plugin/modules
|
||||
* [ipavault](README-vault.md)
|
||||
|
||||
If you want to write a new module please read [writing a new module](plugins/modules/README.md).
|
||||
|
||||
Inventory plugins in plugin/inventory
|
||||
=====================================
|
||||
|
||||
* [freeipa](README-inventory-plugin-freeipa.md)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
---
|
||||
requires_ansible: ">=2.13"
|
||||
requires_ansible: ">=2.15.0"
|
||||
|
||||
@@ -56,5 +56,5 @@ options:
|
||||
Continuous mode. Don't stop on errors. Valid only if `state` is `absent`.
|
||||
aliases: ["continue"]
|
||||
type: bool
|
||||
default: True
|
||||
default: true
|
||||
"""
|
||||
|
||||
191
plugins/inventory/freeipa.py
Normal file
191
plugins/inventory/freeipa.py
Normal file
@@ -0,0 +1,191 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Authors:
|
||||
# Thomas Woerner <twoerner@redhat.com>
|
||||
#
|
||||
# Copyright (C) 2024 Red Hat
|
||||
# see file 'COPYING' for use and warranty information
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
ANSIBLE_METADATA = {
|
||||
"metadata_version": "1.0",
|
||||
"supported_by": "community",
|
||||
"status": ["preview"],
|
||||
}
|
||||
|
||||
DOCUMENTATION = """
|
||||
---
|
||||
name: freeipa
|
||||
version_added: "1.13.0"
|
||||
short_description: Compiles a dynamic inventory from IPA domain
|
||||
description: |
|
||||
Compiles a dynamic inventory from IPA domain, filters servers by role(s).
|
||||
options:
|
||||
plugin:
|
||||
description: Marks this as an instance of the "freeipa" plugin.
|
||||
required: True
|
||||
choices: ["freeipa"]
|
||||
ipaadmin_principal:
|
||||
description: The admin principal.
|
||||
default: admin
|
||||
type: str
|
||||
ipaadmin_password:
|
||||
description: The admin password.
|
||||
required: true
|
||||
type: str
|
||||
server:
|
||||
description: FQDN of server to start the scan.
|
||||
type: str
|
||||
required: true
|
||||
verify:
|
||||
description: |
|
||||
The server TLS certificate file for verification (/etc/ipa/ca.crt).
|
||||
Turned off if not set.
|
||||
type: str
|
||||
required: false
|
||||
role:
|
||||
description: |
|
||||
The role(s) of the server. If several roles are given, only servers
|
||||
that have all the roles are returned.
|
||||
type: list
|
||||
elements: str
|
||||
choices: ["IPA master", "CA server", "KRA server", "DNS server",
|
||||
"AD trust controller", "AD trust agent"]
|
||||
required: false
|
||||
inventory_group:
|
||||
description: |
|
||||
The inventory group to create. The default group name is "ipaservers".
|
||||
type: str
|
||||
default: ipaservers
|
||||
author:
|
||||
- Thomas Woerner (@t-woerner)
|
||||
"""
|
||||
|
||||
EXAMPLES = """
|
||||
# inventory.config file in YAML format
|
||||
plugin: freeipa
|
||||
server: ipaserver-01.ipa.local
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
|
||||
# inventory.config file in YAML format with server TLS certificate verification
|
||||
plugin: freeipa
|
||||
server: ipaserver-01.ipa.local
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
verify: ca.crt
|
||||
"""
|
||||
|
||||
import os
|
||||
try:
|
||||
import requests
|
||||
except ImportError:
|
||||
requests = None
|
||||
try:
|
||||
import urllib3
|
||||
except ImportError:
|
||||
urllib3 = None
|
||||
|
||||
from ansible import constants
|
||||
from ansible.errors import AnsibleParserError
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible.plugins.inventory import BaseInventoryPlugin
|
||||
from ansible.module_utils.six.moves.urllib.parse import quote
|
||||
|
||||
|
||||
class InventoryModule(BaseInventoryPlugin):
|
||||
|
||||
NAME = 'freeipa'
|
||||
|
||||
def verify_file(self, path):
|
||||
# pylint: disable=super-with-arguments
|
||||
if super(InventoryModule, self).verify_file(path):
|
||||
_name, ext = os.path.splitext(path)
|
||||
if ext in constants.YAML_FILENAME_EXTENSIONS:
|
||||
return True
|
||||
return False
|
||||
|
||||
def parse(self, inventory, loader, path, cache=False):
|
||||
# pylint: disable=super-with-arguments
|
||||
super(InventoryModule, self).parse(inventory, loader, path,
|
||||
cache=cache)
|
||||
self._read_config_data(path) # This also loads the cache
|
||||
|
||||
self.get_option("plugin")
|
||||
|
||||
if requests is None:
|
||||
raise AnsibleParserError("The required Python library "
|
||||
"'requests' could not be imported.")
|
||||
|
||||
ipaadmin_principal = self.get_option("ipaadmin_principal")
|
||||
ipaadmin_password = self.get_option("ipaadmin_password")
|
||||
server = self.get_option("server")
|
||||
verify = self.get_option("verify")
|
||||
role = self.get_option("role")
|
||||
inventory_group = self.get_option("inventory_group")
|
||||
|
||||
if verify is not None:
|
||||
if not os.path.exists(verify):
|
||||
raise AnsibleParserError("ERROR: Could not load %s" % verify)
|
||||
else:
|
||||
verify = False
|
||||
# Disable certificate verification warning without certificate
|
||||
# as long as urllib3 could have been loaded.
|
||||
if urllib3 is not None:
|
||||
urllib3.disable_warnings(
|
||||
urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
self.inventory.add_group(inventory_group)
|
||||
|
||||
ipa_url = "https://%s/ipa" % server
|
||||
|
||||
s = requests.Session()
|
||||
s.headers.update({"referer": ipa_url})
|
||||
s.headers.update({"Content-Type":
|
||||
"application/x-www-form-urlencoded"})
|
||||
s.headers.update({"Accept": "text/plain"})
|
||||
|
||||
data = 'user=%s&password=%s' % (quote(ipaadmin_principal, safe=''),
|
||||
quote(ipaadmin_password, safe=''))
|
||||
response = s.post("%s/session/login_password" % ipa_url,
|
||||
data=data, verify=verify)
|
||||
|
||||
# Now use json API
|
||||
s.headers.update({"Content-Type": "application/json"})
|
||||
|
||||
kw_args = {}
|
||||
if role is not None:
|
||||
kw_args["servrole"] = role
|
||||
json_data = {
|
||||
"method" : "server_find",
|
||||
"params": [[], kw_args],
|
||||
"id": 0
|
||||
}
|
||||
response = s.post("%s/session/json" % ipa_url, json=json_data,
|
||||
verify=verify)
|
||||
json_res = response.json()
|
||||
|
||||
error = json_res.get("error")
|
||||
if error is not None:
|
||||
raise AnsibleParserError("ERROR: %s" % to_native(error))
|
||||
|
||||
if "result" in json_res and "result" in json_res["result"]:
|
||||
res = json_res["result"].get("result")
|
||||
if isinstance(res, list):
|
||||
for server in res:
|
||||
self.inventory.add_host(server["cn"][0],
|
||||
group=inventory_group)
|
||||
@@ -25,13 +25,24 @@ from __future__ import (absolute_import, division, print_function)
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
__all__ = ["gssapi", "netaddr", "api", "ipalib_errors", "Env",
|
||||
__all__ = ["DEBUG_COMMAND_ALL", "DEBUG_COMMAND_LIST",
|
||||
"DEBUG_COMMAND_COUNT", "DEBUG_COMMAND_BATCH",
|
||||
"gssapi", "netaddr", "api", "ipalib_errors", "Env",
|
||||
"DEFAULT_CONFIG", "LDAP_GENERALIZED_TIME_FORMAT",
|
||||
"kinit_password", "kinit_keytab", "run", "DN", "VERSION",
|
||||
"paths", "tasks", "get_credentials_if_valid", "Encoding",
|
||||
"DNSName", "getargspec", "certificate_loader",
|
||||
"write_certificate_list", "boolean", "template_str",
|
||||
"urlparse"]
|
||||
"urlparse", "normalize_sshpubkey"]
|
||||
|
||||
DEBUG_COMMAND_ALL = 0b1111
|
||||
# Print the while command list:
|
||||
DEBUG_COMMAND_LIST = 0b0001
|
||||
# Print the number of commands:
|
||||
DEBUG_COMMAND_COUNT = 0b0010
|
||||
# Print information about the batch slice size and currently executed batch
|
||||
# slice:
|
||||
DEBUG_COMMAND_BATCH = 0b0100
|
||||
|
||||
import os
|
||||
# ansible-freeipa requires locale to be C, IPA requires utf-8.
|
||||
@@ -43,7 +54,9 @@ import tempfile
|
||||
import shutil
|
||||
import socket
|
||||
import base64
|
||||
import binascii
|
||||
import ast
|
||||
import time
|
||||
from datetime import datetime
|
||||
from contextlib import contextmanager
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
@@ -87,9 +100,13 @@ try:
|
||||
from ipalib.constants import DEFAULT_CONFIG, LDAP_GENERALIZED_TIME_FORMAT
|
||||
|
||||
try:
|
||||
from ipalib.install.kinit import kinit_password, kinit_keytab
|
||||
from ipalib.kinit import kinit_password, kinit_keytab
|
||||
except ImportError:
|
||||
from ipapython.ipautil import kinit_password, kinit_keytab
|
||||
try:
|
||||
from ipalib.install.kinit import kinit_password, kinit_keytab
|
||||
except ImportError:
|
||||
# pre 4.5.0
|
||||
from ipapython.ipautil import kinit_password, kinit_keytab
|
||||
from ipapython.ipautil import run
|
||||
from ipapython.ipautil import template_str
|
||||
from ipapython.dn import DN
|
||||
@@ -153,6 +170,8 @@ try:
|
||||
except ImportError:
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||
|
||||
from ipalib.util import normalize_sshpubkey
|
||||
|
||||
except ImportError as _err:
|
||||
ANSIBLE_FREEIPA_MODULE_IMPORT_ERROR = str(_err)
|
||||
|
||||
@@ -481,7 +500,10 @@ def module_params_get(module, name, allow_empty_list_item=False):
|
||||
# Ansible issue https://github.com/ansible/ansible/issues/77108
|
||||
if isinstance(value, list):
|
||||
for val in value:
|
||||
if isinstance(val, (str, unicode)) and not val:
|
||||
if (
|
||||
isinstance(val, (str, unicode)) # pylint: disable=W0012,E0606
|
||||
and not val
|
||||
):
|
||||
if not allow_empty_list_item:
|
||||
module.fail_json(
|
||||
msg="Parameter '%s' contains an empty string" %
|
||||
@@ -623,6 +645,7 @@ def encode_certificate(cert):
|
||||
Encode a certificate using base64.
|
||||
|
||||
It also takes FreeIPA and Python versions into account.
|
||||
This is used to convert the certificates returned by find and show.
|
||||
"""
|
||||
if isinstance(cert, (str, unicode, bytes)):
|
||||
encoded = base64.b64encode(cert)
|
||||
@@ -633,6 +656,33 @@ def encode_certificate(cert):
|
||||
return encoded
|
||||
|
||||
|
||||
def convert_input_certificates(module, certs, state):
|
||||
"""
|
||||
Convert certificates.
|
||||
|
||||
Remove all newlines and white spaces from the certificates.
|
||||
This is used on input parameter certificates of modules.
|
||||
"""
|
||||
if certs is None:
|
||||
return None
|
||||
|
||||
_certs = []
|
||||
for cert in certs:
|
||||
try:
|
||||
_cert = base64.b64encode(base64.b64decode(cert)).decode("ascii")
|
||||
except (TypeError, binascii.Error) as e:
|
||||
# Idempotency: Do not fail for an invalid cert for state absent.
|
||||
# The invalid certificate can not be set in FreeIPA.
|
||||
if state == "absent":
|
||||
continue
|
||||
module.fail_json(
|
||||
msg="Certificate %s: Base64 decoding failed: %s" %
|
||||
(repr(cert), str(e)))
|
||||
_certs.append(_cert)
|
||||
|
||||
return _certs
|
||||
|
||||
|
||||
def load_cert_from_str(cert):
|
||||
cert = cert.strip()
|
||||
if not cert.startswith("-----BEGIN CERTIFICATE-----"):
|
||||
@@ -1309,7 +1359,8 @@ class IPAAnsibleModule(AnsibleModule):
|
||||
def execute_ipa_commands(self, commands, result_handler=None,
|
||||
exception_handler=None,
|
||||
fail_on_member_errors=False,
|
||||
**handlers_user_args):
|
||||
batch=False, batch_slice_size=100, debug=False,
|
||||
keeponly=None, **handlers_user_args):
|
||||
"""
|
||||
Execute IPA API commands from command list.
|
||||
|
||||
@@ -1326,6 +1377,16 @@ class IPAAnsibleModule(AnsibleModule):
|
||||
Returns True to continue to next command, else False
|
||||
fail_on_member_errors: bool
|
||||
Use default member error handler handler member_error_handler
|
||||
batch: bool
|
||||
Enable batch command use to speed up processing
|
||||
batch_slice_size: integer
|
||||
Maximum mumber of commands processed in a slice with the batch
|
||||
command
|
||||
keeponly: list of string
|
||||
The attributes to keep in the results returned from the commands
|
||||
Default: None (Keep all)
|
||||
debug: integer
|
||||
Enable debug output for the exection using DEBUG_COMMAND_*
|
||||
handlers_user_args: dict (user args mapping)
|
||||
The user args to pass to result_handler and exception_handler
|
||||
functions
|
||||
@@ -1395,34 +1456,123 @@ class IPAAnsibleModule(AnsibleModule):
|
||||
if "errors" in argspec.args:
|
||||
handlers_user_args["errors"] = _errors
|
||||
|
||||
if debug & DEBUG_COMMAND_LIST:
|
||||
self.tm_warn("commands: %s" % repr(commands))
|
||||
if debug & DEBUG_COMMAND_COUNT:
|
||||
self.tm_warn("#commands: %s" % len(commands))
|
||||
|
||||
# Turn off batch use for server context when it lacks the keeponly
|
||||
# option as it lacks https://github.com/freeipa/freeipa/pull/7335
|
||||
# This is an important fix about reporting errors in the batch
|
||||
# (example: "no modifications to be performed") that results in
|
||||
# aborted processing of the batch and an error about missing
|
||||
# attribute principal. FreeIPA issue #9583
|
||||
batch_has_keeponly = "keeponly" in api.Command.batch.options
|
||||
if batch and api.env.in_server and not batch_has_keeponly:
|
||||
self.debug(
|
||||
"Turning off batch processing for batch missing keeponly")
|
||||
batch = False
|
||||
|
||||
changed = False
|
||||
for name, command, args in commands:
|
||||
try:
|
||||
if name is None:
|
||||
result = self.ipa_command_no_name(command, args)
|
||||
else:
|
||||
result = self.ipa_command(command, name, args)
|
||||
if batch:
|
||||
# batch processing
|
||||
batch_args = []
|
||||
for ci, (name, command, args) in enumerate(commands):
|
||||
if len(batch_args) < batch_slice_size:
|
||||
batch_args.append({
|
||||
"method": command,
|
||||
"params": ([name], args)
|
||||
})
|
||||
|
||||
if "completed" in result:
|
||||
if result["completed"] > 0:
|
||||
changed = True
|
||||
else:
|
||||
changed = True
|
||||
|
||||
# If result_handler is not None, call it with user args
|
||||
# defined in **handlers_user_args
|
||||
if result_handler is not None:
|
||||
result_handler(self, result, command, name, args,
|
||||
**handlers_user_args)
|
||||
|
||||
except Exception as e:
|
||||
if exception_handler is not None and \
|
||||
exception_handler(self, e, **handlers_user_args):
|
||||
if len(batch_args) < batch_slice_size and \
|
||||
ci < len(commands) - 1:
|
||||
# fill in more commands untill batch slice size is reached
|
||||
# or final slice of commands
|
||||
continue
|
||||
self.fail_json(msg="%s: %s: %s" % (command, name, str(e)))
|
||||
|
||||
if debug & DEBUG_COMMAND_BATCH:
|
||||
self.tm_warn("batch %d (size %d/%d)" %
|
||||
(ci / batch_slice_size, len(batch_args),
|
||||
batch_slice_size))
|
||||
|
||||
# run the batch command
|
||||
if batch_has_keeponly:
|
||||
result = api.Command.batch(batch_args, keeponly=keeponly)
|
||||
else:
|
||||
result = api.Command.batch(batch_args)
|
||||
|
||||
if len(batch_args) != result["count"]:
|
||||
self.fail_json(
|
||||
"Result size %d does not match batch size %d" % (
|
||||
result["count"], len(batch_args)))
|
||||
if result["count"] > 0:
|
||||
for ri, res in enumerate(result["results"]):
|
||||
_res = res.get("result", None)
|
||||
if not batch_has_keeponly and keeponly is not None \
|
||||
and isinstance(_res, dict):
|
||||
res["result"] = dict(
|
||||
filter(lambda x: x[0] in keeponly,
|
||||
_res.items())
|
||||
)
|
||||
|
||||
if "error" not in res or res["error"] is None:
|
||||
if result_handler is not None:
|
||||
result_handler(
|
||||
self, res,
|
||||
batch_args[ri]["method"],
|
||||
batch_args[ri]["params"][0][0],
|
||||
batch_args[ri]["params"][1],
|
||||
**handlers_user_args)
|
||||
changed = True
|
||||
else:
|
||||
_errors.append(
|
||||
"%s: %s: %s" %
|
||||
(batch_args[ri]["method"],
|
||||
str(batch_args[ri]["params"][0][0]),
|
||||
res["error"]))
|
||||
# clear batch command list (python2 compatible)
|
||||
del batch_args[:]
|
||||
else:
|
||||
# no batch processing
|
||||
for name, command, args in commands:
|
||||
try:
|
||||
if name is None:
|
||||
result = self.ipa_command_no_name(command, args)
|
||||
else:
|
||||
result = self.ipa_command(command, name, args)
|
||||
|
||||
if "completed" in result:
|
||||
if result["completed"] > 0:
|
||||
changed = True
|
||||
else:
|
||||
changed = True
|
||||
|
||||
# Handle keeponly
|
||||
res = result.get("result", None)
|
||||
if keeponly is not None and isinstance(res, dict):
|
||||
result["result"] = dict(
|
||||
filter(lambda x: x[0] in keeponly, res.items())
|
||||
)
|
||||
|
||||
# If result_handler is not None, call it with user args
|
||||
# defined in **handlers_user_args
|
||||
if result_handler is not None:
|
||||
result_handler(self, result, command, name, args,
|
||||
**handlers_user_args)
|
||||
|
||||
except Exception as e:
|
||||
if exception_handler is not None and \
|
||||
exception_handler(self, e, **handlers_user_args):
|
||||
continue
|
||||
self.fail_json(msg="%s: %s: %s" % (command, name, str(e)))
|
||||
|
||||
# Fail on errors from result_handler and exception_handler
|
||||
if len(_errors) > 0:
|
||||
self.fail_json(msg=", ".join(_errors))
|
||||
|
||||
return changed
|
||||
|
||||
def tm_warn(self, warning):
|
||||
ts = time.time()
|
||||
# pylint: disable=super-with-arguments
|
||||
super(IPAAnsibleModule, self).warn("%f %s" % (ts, warning))
|
||||
|
||||
@@ -450,6 +450,10 @@ def main():
|
||||
commands = []
|
||||
|
||||
for name in names:
|
||||
_type = None
|
||||
inclusive_add, inclusive_del = [], []
|
||||
exclusive_add, exclusive_del = [], []
|
||||
|
||||
# Make sure automember rule exists
|
||||
res_find = find_automember(ansible_module, name, automember_type)
|
||||
|
||||
@@ -495,16 +499,12 @@ def main():
|
||||
transform_conditions(inclusive),
|
||||
res_find.get("automemberinclusiveregex", [])
|
||||
)
|
||||
else:
|
||||
inclusive_add, inclusive_del = [], []
|
||||
|
||||
if exclusive is not None:
|
||||
exclusive_add, exclusive_del = gen_add_del_lists(
|
||||
transform_conditions(exclusive),
|
||||
res_find.get("automemberexclusiveregex", [])
|
||||
)
|
||||
else:
|
||||
exclusive_add, exclusive_del = [], []
|
||||
|
||||
elif action == "member":
|
||||
if res_find is None:
|
||||
@@ -512,9 +512,7 @@ def main():
|
||||
msg="No automember '%s'" % name)
|
||||
|
||||
inclusive_add = transform_conditions(inclusive or [])
|
||||
inclusive_del = []
|
||||
exclusive_add = transform_conditions(exclusive or [])
|
||||
exclusive_del = []
|
||||
|
||||
for _inclusive in inclusive_add:
|
||||
key, regex = _inclusive.split("=", 1)
|
||||
|
||||
@@ -34,7 +34,7 @@ ANSIBLE_METADATA = {
|
||||
DOCUMENTATION = """
|
||||
---
|
||||
module: ipacert
|
||||
short description: Manage FreeIPA certificates
|
||||
short_description: Manage FreeIPA certificates
|
||||
description: Manage FreeIPA certificates
|
||||
extends_documentation_fragment:
|
||||
- ipamodule_base_docs
|
||||
@@ -67,6 +67,10 @@ options:
|
||||
description: Name of the issuing certificate authority.
|
||||
type: str
|
||||
required: false
|
||||
chain:
|
||||
description: Include certificate chain in output.
|
||||
type: bool
|
||||
required: false
|
||||
serial_number:
|
||||
description: |
|
||||
Certificate serial number. Cannot be used with `state: requested`.
|
||||
@@ -102,7 +106,6 @@ options:
|
||||
required: true
|
||||
type: str
|
||||
author:
|
||||
authors:
|
||||
- Sam Morris (@yrro)
|
||||
- Rafael Guterres Jeffman (@rjeffman)
|
||||
"""
|
||||
|
||||
@@ -250,6 +250,8 @@ def main():
|
||||
operation = "add"
|
||||
|
||||
invalid = []
|
||||
wants_enable = False
|
||||
|
||||
if state in ["enabled", "disabled"]:
|
||||
if action == "member":
|
||||
ansible_module.fail_json(
|
||||
|
||||
@@ -1605,6 +1605,8 @@ def main():
|
||||
|
||||
res_find = find_dnsrecord(ansible_module, zone_name, name)
|
||||
|
||||
cmds = []
|
||||
|
||||
if state == 'present':
|
||||
cmds = define_commands_for_present_state(
|
||||
ansible_module, zone_name, entry, res_find)
|
||||
|
||||
@@ -663,7 +663,11 @@ def main():
|
||||
|
||||
check_parameters(ansible_module, state, action)
|
||||
|
||||
elif isinstance(group_name, (str, unicode)):
|
||||
elif (
|
||||
isinstance(
|
||||
group_name, (str, unicode) # pylint: disable=W0012,E0606
|
||||
)
|
||||
):
|
||||
name = group_name
|
||||
else:
|
||||
ansible_module.fail_json(msg="Group '%s' is not valid" %
|
||||
@@ -900,7 +904,7 @@ def main():
|
||||
|
||||
# Execute commands
|
||||
changed = ansible_module.execute_ipa_commands(
|
||||
commands, fail_on_member_errors=True)
|
||||
commands, batch=True, keeponly=[], fail_on_member_errors=True)
|
||||
|
||||
# Done
|
||||
|
||||
|
||||
@@ -509,7 +509,9 @@ host:
|
||||
|
||||
from ansible.module_utils.ansible_freeipa_module import \
|
||||
IPAAnsibleModule, compare_args_ipa, gen_add_del_lists, \
|
||||
encode_certificate, is_ipv4_addr, is_ipv6_addr, ipalib_errors
|
||||
encode_certificate, is_ipv4_addr, is_ipv6_addr, ipalib_errors, \
|
||||
gen_add_list, gen_intersection_list, normalize_sshpubkey, \
|
||||
convert_input_certificates
|
||||
from ansible.module_utils import six
|
||||
if six.PY3:
|
||||
unicode = str
|
||||
@@ -533,6 +535,11 @@ def find_host(module, name):
|
||||
if certs is not None:
|
||||
_res["usercertificate"] = [encode_certificate(cert) for
|
||||
cert in certs]
|
||||
# krbprincipalname is returned as ipapython.kerberos.Principal, convert
|
||||
# to string
|
||||
principals = _res.get("krbprincipalname")
|
||||
if principals is not None:
|
||||
_res["krbprincipalname"] = [str(princ) for princ in principals]
|
||||
return _res
|
||||
|
||||
|
||||
@@ -677,7 +684,7 @@ def check_authind(module, auth_ind):
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def result_handler(module, result, command, name, args, errors, exit_args,
|
||||
def result_handler(module, result, command, name, args, exit_args,
|
||||
single_host):
|
||||
if "random" in args and command in ["host_add", "host_mod"] \
|
||||
and "randompassword" in result["result"]:
|
||||
@@ -688,41 +695,6 @@ def result_handler(module, result, command, name, args, errors, exit_args,
|
||||
exit_args.setdefault(name, {})["randompassword"] = \
|
||||
result["result"]["randompassword"]
|
||||
|
||||
# All "already a member" and "not a member" failures in the
|
||||
# result are ignored. All others are reported.
|
||||
if "failed" in result and len(result["failed"]) > 0:
|
||||
for item in result["failed"]:
|
||||
failed_item = result["failed"][item]
|
||||
for member_type in failed_item:
|
||||
for member, failure in failed_item[member_type]:
|
||||
if "already a member" in failure \
|
||||
or "not a member" in failure:
|
||||
continue
|
||||
errors.append("%s: %s %s: %s" % (
|
||||
command, member_type, member, failure))
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def exception_handler(module, ex, errors, exit_args, single_host):
|
||||
msg = str(ex)
|
||||
if "already contains" in msg \
|
||||
or "does not contain" in msg:
|
||||
return True
|
||||
|
||||
# The canonical principal name may not be removed
|
||||
if "equal to the canonical principal name must" in msg:
|
||||
return True
|
||||
|
||||
# Host is already disabled, ignore error
|
||||
if "This entry is already disabled" in msg:
|
||||
return True
|
||||
|
||||
# Ignore no modification error.
|
||||
if "no modifications to be performed" in msg:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
host_spec = dict(
|
||||
@@ -916,6 +888,12 @@ def main():
|
||||
auth_ind, requires_pre_auth, ok_as_delegate, ok_to_auth_as_delegate,
|
||||
force, reverse, ip_address, update_dns, update_password)
|
||||
|
||||
certificate = convert_input_certificates(ansible_module, certificate,
|
||||
state)
|
||||
|
||||
if sshpubkey is not None:
|
||||
sshpubkey = [str(normalize_sshpubkey(key)) for key in sshpubkey]
|
||||
|
||||
# Use hosts if names is None
|
||||
if hosts is not None:
|
||||
names = hosts
|
||||
@@ -999,7 +977,16 @@ def main():
|
||||
ok_to_auth_as_delegate, force, reverse, ip_address,
|
||||
update_dns, update_password)
|
||||
|
||||
elif isinstance(host, (str, unicode)):
|
||||
certificate = convert_input_certificates(ansible_module,
|
||||
certificate, state)
|
||||
|
||||
if sshpubkey is not None:
|
||||
sshpubkey = [str(normalize_sshpubkey(key)) for
|
||||
key in sshpubkey]
|
||||
|
||||
elif (
|
||||
isinstance(host, (str, unicode)) # pylint: disable=W0012,E0606
|
||||
):
|
||||
name = host
|
||||
else:
|
||||
ansible_module.fail_json(msg="Host '%s' is not valid" %
|
||||
@@ -1074,6 +1061,17 @@ def main():
|
||||
args["krbprincipalauthind"] == ['']:
|
||||
del args["krbprincipalauthind"]
|
||||
|
||||
# Ignore sshpubkey if it is empty (for resetting)
|
||||
# and not set for the host
|
||||
if "ipasshpubkey" not in res_find and \
|
||||
"ipasshpubkey" in args and \
|
||||
args["ipasshpubkey"] == []:
|
||||
del args["ipasshpubkey"]
|
||||
|
||||
# Ignore updatedns if it is the only arg
|
||||
if "updatedns" in args and len(args) == 1:
|
||||
del args["updatedns"]
|
||||
|
||||
# For all settings is args, check if there are
|
||||
# different settings in the find result.
|
||||
# If yes: modify
|
||||
@@ -1106,7 +1104,7 @@ def main():
|
||||
gen_add_del_lists(managedby_host,
|
||||
res_find.get("managedby_host"))
|
||||
principal_add, principal_del = gen_add_del_lists(
|
||||
principal, res_find.get("principal"))
|
||||
principal, res_find.get("krbprincipalname"))
|
||||
# Principals are not returned as utf8 for IPA using
|
||||
# python2 using host_show, therefore we need to
|
||||
# convert the principals that we should remove.
|
||||
@@ -1174,50 +1172,115 @@ def main():
|
||||
gen_add_del_lists(
|
||||
dnsrecord_args.get("aaaarecord"),
|
||||
_dnsrec.get("aaaarecord"))
|
||||
else:
|
||||
certificate_add = certificate or []
|
||||
certificate_del = []
|
||||
managedby_host_add = managedby_host or []
|
||||
managedby_host_del = []
|
||||
principal_add = principal or []
|
||||
principal_del = []
|
||||
allow_create_keytab_user_add = \
|
||||
allow_create_keytab_user or []
|
||||
allow_create_keytab_user_del = []
|
||||
allow_create_keytab_group_add = \
|
||||
allow_create_keytab_group or []
|
||||
allow_create_keytab_group_del = []
|
||||
allow_create_keytab_host_add = \
|
||||
allow_create_keytab_host or []
|
||||
allow_create_keytab_host_del = []
|
||||
allow_create_keytab_hostgroup_add = \
|
||||
allow_create_keytab_hostgroup or []
|
||||
allow_create_keytab_hostgroup_del = []
|
||||
allow_retrieve_keytab_user_add = \
|
||||
allow_retrieve_keytab_user or []
|
||||
allow_retrieve_keytab_user_del = []
|
||||
allow_retrieve_keytab_group_add = \
|
||||
allow_retrieve_keytab_group or []
|
||||
allow_retrieve_keytab_group_del = []
|
||||
allow_retrieve_keytab_host_add = \
|
||||
allow_retrieve_keytab_host or []
|
||||
allow_retrieve_keytab_host_del = []
|
||||
allow_retrieve_keytab_hostgroup_add = \
|
||||
allow_retrieve_keytab_hostgroup or []
|
||||
allow_retrieve_keytab_hostgroup_del = []
|
||||
_dnsrec = res_find_dnsrecord or {}
|
||||
dnsrecord_a_add = gen_add_list(
|
||||
dnsrecord_args.get("arecord"),
|
||||
_dnsrec.get("arecord"))
|
||||
dnsrecord_a_del = []
|
||||
dnsrecord_aaaa_add = gen_add_list(
|
||||
dnsrecord_args.get("aaaarecord"),
|
||||
_dnsrec.get("aaaarecord"))
|
||||
dnsrecord_aaaa_del = []
|
||||
|
||||
else:
|
||||
# action member
|
||||
if res_find is None:
|
||||
ansible_module.fail_json(
|
||||
msg="No host '%s'" % name)
|
||||
|
||||
if action != "host" or (action == "host" and res_find is None):
|
||||
certificate_add = certificate or []
|
||||
certificate_add = gen_add_list(
|
||||
certificate, res_find.get("usercertificate"))
|
||||
certificate_del = []
|
||||
managedby_host_add = managedby_host or []
|
||||
managedby_host_add = gen_add_list(
|
||||
managedby_host, res_find.get("managedby_host"))
|
||||
managedby_host_del = []
|
||||
principal_add = principal or []
|
||||
principal_add = gen_add_list(
|
||||
principal, res_find.get("krbprincipalname"))
|
||||
principal_del = []
|
||||
allow_create_keytab_user_add = \
|
||||
allow_create_keytab_user or []
|
||||
allow_create_keytab_user_add = gen_add_list(
|
||||
allow_create_keytab_user,
|
||||
res_find.get(
|
||||
"ipaallowedtoperform_write_keys_user"))
|
||||
allow_create_keytab_user_del = []
|
||||
allow_create_keytab_group_add = \
|
||||
allow_create_keytab_group or []
|
||||
allow_create_keytab_group_add = gen_add_list(
|
||||
allow_create_keytab_group,
|
||||
res_find.get(
|
||||
"ipaallowedtoperform_write_keys_group"))
|
||||
allow_create_keytab_group_del = []
|
||||
allow_create_keytab_host_add = \
|
||||
allow_create_keytab_host or []
|
||||
allow_create_keytab_host_add = gen_add_list(
|
||||
allow_create_keytab_host,
|
||||
res_find.get(
|
||||
"ipaallowedtoperform_write_keys_host"))
|
||||
allow_create_keytab_host_del = []
|
||||
allow_create_keytab_hostgroup_add = \
|
||||
allow_create_keytab_hostgroup or []
|
||||
allow_create_keytab_hostgroup_add = gen_add_list(
|
||||
allow_create_keytab_hostgroup,
|
||||
res_find.get(
|
||||
"ipaallowedtoperform_write_keys_hostgroup"))
|
||||
allow_create_keytab_hostgroup_del = []
|
||||
allow_retrieve_keytab_user_add = \
|
||||
allow_retrieve_keytab_user or []
|
||||
allow_retrieve_keytab_user_add = gen_add_list(
|
||||
allow_retrieve_keytab_user,
|
||||
res_find.get(
|
||||
"ipaallowedtoperform_read_keys_user"))
|
||||
allow_retrieve_keytab_user_del = []
|
||||
allow_retrieve_keytab_group_add = \
|
||||
allow_retrieve_keytab_group or []
|
||||
allow_retrieve_keytab_group_add = gen_add_list(
|
||||
allow_retrieve_keytab_group,
|
||||
res_find.get(
|
||||
"ipaallowedtoperform_read_keys_group"))
|
||||
allow_retrieve_keytab_group_del = []
|
||||
allow_retrieve_keytab_host_add = \
|
||||
allow_retrieve_keytab_host or []
|
||||
allow_retrieve_keytab_host_add = gen_add_list(
|
||||
allow_retrieve_keytab_host,
|
||||
res_find.get(
|
||||
"ipaallowedtoperform_read_keys_host"))
|
||||
allow_retrieve_keytab_host_del = []
|
||||
allow_retrieve_keytab_hostgroup_add = \
|
||||
allow_retrieve_keytab_hostgroup or []
|
||||
allow_retrieve_keytab_hostgroup_add = gen_add_list(
|
||||
allow_retrieve_keytab_hostgroup,
|
||||
res_find.get(
|
||||
"ipaallowedtoperform_read_keys_hostgroup"))
|
||||
allow_retrieve_keytab_hostgroup_del = []
|
||||
dnsrecord_a_add = dnsrecord_args.get("arecord") or []
|
||||
_dnsrec = res_find_dnsrecord or {}
|
||||
dnsrecord_a_add = gen_add_list(
|
||||
dnsrecord_args.get("arecord"),
|
||||
_dnsrec.get("arecord"))
|
||||
dnsrecord_a_del = []
|
||||
dnsrecord_aaaa_add = dnsrecord_args.get("aaaarecord") or []
|
||||
dnsrecord_aaaa_add = gen_add_list(
|
||||
dnsrecord_args.get("aaaarecord"),
|
||||
_dnsrec.get("aaaarecord"))
|
||||
dnsrecord_aaaa_del = []
|
||||
|
||||
# Remove canonical principal from principal_del
|
||||
canonical_principal = "host/" + name + "@" + server_realm
|
||||
# canonical_principal is also in find_res["krbcanonicalname"]
|
||||
if canonical_principal in principal_del and \
|
||||
action == "host" and (principal is not None or
|
||||
canonical_principal not in principal):
|
||||
@@ -1398,8 +1461,10 @@ def main():
|
||||
# the removal of non-existing entries.
|
||||
|
||||
# Remove certificates
|
||||
if certificate is not None:
|
||||
for _certificate in certificate:
|
||||
certificate_del = gen_intersection_list(
|
||||
certificate, res_find.get("usercertificate"))
|
||||
if certificate_del is not None:
|
||||
for _certificate in certificate_del:
|
||||
commands.append([name, "host_remove_cert",
|
||||
{
|
||||
"usercertificate":
|
||||
@@ -1412,8 +1477,10 @@ def main():
|
||||
# the removal of non-existing entries.
|
||||
|
||||
# Remove managedby_hosts
|
||||
if managedby_host is not None:
|
||||
for _managedby_host in managedby_host:
|
||||
managedby_host_del = gen_intersection_list(
|
||||
managedby_host, res_find.get("managedby_host"))
|
||||
if managedby_host_del is not None:
|
||||
for _managedby_host in managedby_host_del:
|
||||
commands.append([name, "host_remove_managedby",
|
||||
{
|
||||
"host":
|
||||
@@ -1426,8 +1493,10 @@ def main():
|
||||
# the removal of non-existing entries.
|
||||
|
||||
# Remove principals
|
||||
if principal is not None:
|
||||
for _principal in principal:
|
||||
principal_del = gen_intersection_list(
|
||||
principal, res_find.get("krbprincipalname"))
|
||||
if principal_del is not None:
|
||||
for _principal in principal_del:
|
||||
commands.append([name, "host_remove_principal",
|
||||
{
|
||||
"krbprincipalname":
|
||||
@@ -1435,60 +1504,86 @@ def main():
|
||||
}])
|
||||
|
||||
# Disallow create keytab
|
||||
if allow_create_keytab_user is not None or \
|
||||
allow_create_keytab_group is not None or \
|
||||
allow_create_keytab_host is not None or \
|
||||
allow_create_keytab_hostgroup is not None:
|
||||
allow_create_keytab_user_del = gen_intersection_list(
|
||||
allow_create_keytab_user,
|
||||
res_find.get("ipaallowedtoperform_write_keys_user"))
|
||||
allow_create_keytab_group_del = gen_intersection_list(
|
||||
allow_create_keytab_group,
|
||||
res_find.get("ipaallowedtoperform_write_keys_group"))
|
||||
allow_create_keytab_host_del = gen_intersection_list(
|
||||
allow_create_keytab_host,
|
||||
res_find.get("ipaallowedtoperform_write_keys_host"))
|
||||
allow_create_keytab_hostgroup_del = gen_intersection_list(
|
||||
allow_create_keytab_hostgroup,
|
||||
res_find.get(
|
||||
"ipaallowedtoperform_write_keys_hostgroup"))
|
||||
if len(allow_create_keytab_user_del) > 0 or \
|
||||
len(allow_create_keytab_group_del) > 0 or \
|
||||
len(allow_create_keytab_host_del) > 0 or \
|
||||
len(allow_create_keytab_hostgroup_del) > 0:
|
||||
commands.append(
|
||||
[name, "host_disallow_create_keytab",
|
||||
{
|
||||
"user": allow_create_keytab_user,
|
||||
"group": allow_create_keytab_group,
|
||||
"host": allow_create_keytab_host,
|
||||
"hostgroup": allow_create_keytab_hostgroup,
|
||||
"user": allow_create_keytab_user_del,
|
||||
"group": allow_create_keytab_group_del,
|
||||
"host": allow_create_keytab_host_del,
|
||||
"hostgroup":
|
||||
allow_create_keytab_hostgroup_del,
|
||||
}])
|
||||
|
||||
# Disallow retrieve keytab
|
||||
if allow_retrieve_keytab_user is not None or \
|
||||
allow_retrieve_keytab_group is not None or \
|
||||
allow_retrieve_keytab_host is not None or \
|
||||
allow_retrieve_keytab_hostgroup is not None:
|
||||
allow_retrieve_keytab_user_del = gen_intersection_list(
|
||||
allow_retrieve_keytab_user,
|
||||
res_find.get("ipaallowedtoperform_read_keys_user"))
|
||||
allow_retrieve_keytab_group_del = gen_intersection_list(
|
||||
allow_retrieve_keytab_group,
|
||||
res_find.get("ipaallowedtoperform_read_keys_group"))
|
||||
allow_retrieve_keytab_host_del = gen_intersection_list(
|
||||
allow_retrieve_keytab_host,
|
||||
res_find.get("ipaallowedtoperform_read_keys_host"))
|
||||
allow_retrieve_keytab_hostgroup_del = \
|
||||
gen_intersection_list(
|
||||
allow_retrieve_keytab_hostgroup,
|
||||
res_find.get(
|
||||
"ipaallowedtoperform_read_keys_hostgroup"))
|
||||
if len(allow_retrieve_keytab_user_del) > 0 or \
|
||||
len(allow_retrieve_keytab_group_del) > 0 or \
|
||||
len(allow_retrieve_keytab_host_del) > 0 or \
|
||||
len(allow_retrieve_keytab_hostgroup_del) > 0:
|
||||
commands.append(
|
||||
[name, "host_disallow_retrieve_keytab",
|
||||
{
|
||||
"user": allow_retrieve_keytab_user,
|
||||
"group": allow_retrieve_keytab_group,
|
||||
"host": allow_retrieve_keytab_host,
|
||||
"hostgroup": allow_retrieve_keytab_hostgroup,
|
||||
"user": allow_retrieve_keytab_user_del,
|
||||
"group": allow_retrieve_keytab_group_del,
|
||||
"host": allow_retrieve_keytab_host_del,
|
||||
"hostgroup":
|
||||
allow_retrieve_keytab_hostgroup_del,
|
||||
}])
|
||||
|
||||
dnsrecord_args = gen_dnsrecord_args(ansible_module,
|
||||
ip_address, reverse)
|
||||
if res_find_dnsrecord is not None:
|
||||
dnsrecord_args = gen_dnsrecord_args(
|
||||
ansible_module, ip_address, reverse)
|
||||
|
||||
# Remove arecord and aaaarecord from dnsrecord_args
|
||||
# if the record does not exits in res_find_dnsrecord
|
||||
# to prevent "DNS resource record not found" error
|
||||
if "arecord" in dnsrecord_args \
|
||||
and dnsrecord_args["arecord"] is not None \
|
||||
and len(dnsrecord_args["arecord"]) > 0 \
|
||||
and (res_find_dnsrecord is None
|
||||
or "arecord" not in res_find_dnsrecord):
|
||||
del dnsrecord_args["arecord"]
|
||||
if "aaaarecord" in dnsrecord_args \
|
||||
and dnsrecord_args["aaaarecord"] is not None \
|
||||
and len(dnsrecord_args["aaaarecord"]) > 0 \
|
||||
and (res_find_dnsrecord is None
|
||||
or "aaaarecord" not in res_find_dnsrecord):
|
||||
del dnsrecord_args["aaaarecord"]
|
||||
# Only keep a and aaaa recrords that are part
|
||||
# of res_find_dnsrecord.
|
||||
for _type in ["arecord", "aaaarecord"]:
|
||||
if _type in dnsrecord_args:
|
||||
recs = gen_intersection_list(
|
||||
dnsrecord_args[_type],
|
||||
res_find_dnsrecord.get(_type))
|
||||
if len(recs) > 0:
|
||||
dnsrecord_args[_type] = recs
|
||||
else:
|
||||
del dnsrecord_args[_type]
|
||||
|
||||
if "arecord" in dnsrecord_args or \
|
||||
"aaaarecord" in dnsrecord_args:
|
||||
domain_name = name[name.find(".") + 1:]
|
||||
host_name = name[:name.find(".")]
|
||||
dnsrecord_args["idnsname"] = host_name
|
||||
if "arecord" in dnsrecord_args or \
|
||||
"aaaarecord" in dnsrecord_args:
|
||||
domain_name = name[name.find(".") + 1:]
|
||||
host_name = name[:name.find(".")]
|
||||
dnsrecord_args["idnsname"] = host_name
|
||||
|
||||
commands.append([domain_name, "dnsrecord_del",
|
||||
dnsrecord_args])
|
||||
commands.append([domain_name, "dnsrecord_del",
|
||||
dnsrecord_args])
|
||||
|
||||
elif state == "disabled":
|
||||
if res_find is not None:
|
||||
@@ -1504,7 +1599,7 @@ def main():
|
||||
# Execute commands
|
||||
|
||||
changed = ansible_module.execute_ipa_commands(
|
||||
commands, result_handler, exception_handler,
|
||||
commands, result_handler, batch=True, keeponly=["randompassword"],
|
||||
exit_args=exit_args, single_host=hosts is None)
|
||||
|
||||
# Done
|
||||
|
||||
@@ -87,7 +87,7 @@ options:
|
||||
sshpubkey:
|
||||
description: List of SSH public keys
|
||||
type: list
|
||||
element: str
|
||||
elements: str
|
||||
required: False
|
||||
aliases: ["ipasshpubkey"]
|
||||
certificate:
|
||||
@@ -113,7 +113,7 @@ options:
|
||||
description: |
|
||||
Suppress processing of membership attributes.
|
||||
Valid only if `state` is `absent`.
|
||||
type: str
|
||||
type: bool
|
||||
required: False
|
||||
aliases: ["no_members"]
|
||||
action:
|
||||
@@ -315,7 +315,7 @@ RETURN = """
|
||||
|
||||
from ansible.module_utils.ansible_freeipa_module import \
|
||||
IPAAnsibleModule, compare_args_ipa, gen_add_del_lists, gen_add_list, \
|
||||
gen_intersection_list, encode_certificate
|
||||
gen_intersection_list, encode_certificate, convert_input_certificates
|
||||
from ansible.module_utils import six
|
||||
|
||||
if six.PY3:
|
||||
@@ -479,8 +479,8 @@ def main():
|
||||
|
||||
ansible_module.params_fail_used_invalid(invalid, state, action)
|
||||
|
||||
if certificate is not None:
|
||||
certificate = [cert.strip() for cert in certificate]
|
||||
certificate = convert_input_certificates(ansible_module, certificate,
|
||||
state)
|
||||
|
||||
# Init
|
||||
|
||||
|
||||
@@ -82,7 +82,6 @@ options:
|
||||
description: OAuth 2.0 client secret
|
||||
required: false
|
||||
type: str
|
||||
no_log: true
|
||||
aliases: ["ipaidpclientsecret"]
|
||||
scope:
|
||||
description: OAuth 2.0 scope. Multiple scopes separated by space
|
||||
@@ -362,11 +361,11 @@ def main():
|
||||
dev_auth_uri=dict(required=False, type="str", default=None,
|
||||
aliases=["ipaidpdevauthendpoint"]),
|
||||
token_uri=dict(required=False, type="str", default=None,
|
||||
aliases=["ipaidptokenendpoint"]),
|
||||
aliases=["ipaidptokenendpoint"], no_log=False),
|
||||
userinfo_uri=dict(required=False, type="str", default=None,
|
||||
aliases=["ipaidpuserinfoendpoint"]),
|
||||
keys_uri=dict(required=False, type="str", default=None,
|
||||
aliases=["ipaidpkeysendpoint"]),
|
||||
aliases=["ipaidpkeysendpoint"], no_log=False),
|
||||
issuer_url=dict(required=False, type="str", default=None,
|
||||
aliases=["ipaidpissuerurl"]),
|
||||
client_id=dict(required=False, type="str", default=None,
|
||||
|
||||
@@ -154,7 +154,7 @@ RETURN = """
|
||||
|
||||
|
||||
from ansible.module_utils.ansible_freeipa_module import \
|
||||
IPAAnsibleModule, compare_args_ipa
|
||||
IPAAnsibleModule, compare_args_ipa, to_text
|
||||
|
||||
|
||||
def find_permission(module, name):
|
||||
@@ -164,7 +164,12 @@ def find_permission(module, name):
|
||||
except Exception: # pylint: disable=broad-except
|
||||
# An exception is raised if permission name is not found.
|
||||
return None
|
||||
return _result["result"]
|
||||
_res = _result["result"]
|
||||
for param in ["ipapermlocation", "ipapermtarget", "ipapermtargetto",
|
||||
"ipapermtargetfrom"]:
|
||||
if param in _res:
|
||||
_res[param] = [to_text(elem) for elem in _res[param]]
|
||||
return _res
|
||||
|
||||
|
||||
def gen_args(right, attrs, bindtype, subtree,
|
||||
|
||||
@@ -293,7 +293,7 @@ def result_get_value_lowercase(res_find, key, default=None):
|
||||
if existing is not None:
|
||||
if isinstance(existing, (list, tuple)):
|
||||
existing = [to_text(item).lower() for item in existing]
|
||||
if isinstance(existing, (str, unicode)):
|
||||
if isinstance(existing, (str, unicode)): # pylint: disable=W0012,E0606
|
||||
existing = existing.lower()
|
||||
else:
|
||||
existing = default
|
||||
|
||||
@@ -44,7 +44,7 @@ options:
|
||||
description: The service to manage
|
||||
type: list
|
||||
elements: str
|
||||
required: true
|
||||
required: false
|
||||
aliases: ["service"]
|
||||
services:
|
||||
description: The list of service dicts.
|
||||
@@ -167,6 +167,13 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
aliases: ["ipaallowedtoperform_read_keys_hostgroup"]
|
||||
delete_continue:
|
||||
description:
|
||||
Continuous mode. Don't stop on errors.
|
||||
Valid only if `state` is `absent`.
|
||||
required: false
|
||||
type: bool
|
||||
aliases: ["continue"]
|
||||
certificate:
|
||||
description: Base-64 encoded service certificate.
|
||||
required: false
|
||||
@@ -370,6 +377,43 @@ EXAMPLES = """
|
||||
host:
|
||||
- host1.example.com
|
||||
- name: HTTP/www.service.com
|
||||
|
||||
# Ensure multiple services are present
|
||||
- ipaservice:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
services:
|
||||
- name: HTTP/www.example.com
|
||||
principal:
|
||||
- host/host1.example.com
|
||||
- name: mysvc/www.example.com
|
||||
pac_type: NONE
|
||||
ok_as_delegate: yes
|
||||
ok_to_auth_as_delegate: yes
|
||||
- name: HTTP/www.example.com
|
||||
allow_create_keytab_user:
|
||||
- user01
|
||||
- user02
|
||||
allow_create_keytab_group:
|
||||
- group01
|
||||
- group02
|
||||
allow_create_keytab_host:
|
||||
- host1.example.com
|
||||
- host2.example.com
|
||||
allow_create_keytab_hostgroup:
|
||||
- hostgroup01
|
||||
- hostgroup02
|
||||
- name: mysvc/host2.example.com
|
||||
auth_ind: otp,radius
|
||||
|
||||
# Ensure service host members are present
|
||||
- ipaservice:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
services:
|
||||
- name: HTTP/www1.example.com
|
||||
host: host1.example.com
|
||||
- name: HTTP/www2.example.com
|
||||
host: host2.example.com
|
||||
action: member
|
||||
"""
|
||||
|
||||
RETURN = """
|
||||
@@ -378,7 +422,7 @@ RETURN = """
|
||||
from ansible.module_utils.ansible_freeipa_module import \
|
||||
IPAAnsibleModule, compare_args_ipa, encode_certificate, \
|
||||
gen_add_del_lists, gen_add_list, gen_intersection_list, ipalib_errors, \
|
||||
api_get_realm, to_text
|
||||
api_get_realm, to_text, convert_input_certificates
|
||||
from ansible.module_utils import six
|
||||
if six.PY3:
|
||||
unicode = str
|
||||
@@ -601,12 +645,6 @@ def main():
|
||||
# service attributes
|
||||
principal = ansible_module.params_get("principal")
|
||||
certificate = ansible_module.params_get("certificate")
|
||||
# Any leading or trailing whitespace is removed while adding the
|
||||
# certificate with serive_add_cert. To be able to compare the results
|
||||
# from service_show with the given certificates we have to remove the
|
||||
# white space also.
|
||||
if certificate is not None:
|
||||
certificate = [cert.strip() for cert in certificate]
|
||||
pac_type = ansible_module.params_get(
|
||||
"pac_type", allow_empty_list_item=True)
|
||||
auth_ind = ansible_module.params_get(
|
||||
@@ -636,6 +674,8 @@ def main():
|
||||
ansible_module.fail_json(msg="At least one name or services is "
|
||||
"required")
|
||||
check_parameters(ansible_module, state, action, names)
|
||||
certificate = convert_input_certificates(ansible_module, certificate,
|
||||
state)
|
||||
|
||||
# Use services if names is None
|
||||
if services is not None:
|
||||
@@ -669,12 +709,8 @@ def main():
|
||||
service_set.add(name)
|
||||
principal = service.get("principal")
|
||||
certificate = service.get("certificate")
|
||||
# Any leading or trailing whitespace is removed while adding
|
||||
# the certificate with serive_add_cert. To be able to compare
|
||||
# the results from service_show with the given certificates
|
||||
# we have to remove the white space also.
|
||||
if certificate is not None:
|
||||
certificate = [cert.strip() for cert in certificate]
|
||||
certificate = convert_input_certificates(ansible_module,
|
||||
certificate, state)
|
||||
pac_type = service.get("pac_type")
|
||||
auth_ind = service.get("auth_ind")
|
||||
check_authind(ansible_module, auth_ind)
|
||||
@@ -693,7 +729,11 @@ def main():
|
||||
|
||||
delete_continue = service.get("delete_continue")
|
||||
|
||||
elif isinstance(service, (str, unicode)):
|
||||
elif (
|
||||
isinstance(
|
||||
service, (str, unicode) # pylint: disable=W0012,E0606
|
||||
)
|
||||
):
|
||||
name = service
|
||||
else:
|
||||
ansible_module.fail_json(msg="Service '%s' is not valid" %
|
||||
@@ -840,7 +880,9 @@ def main():
|
||||
elif state == "absent":
|
||||
if action == "service":
|
||||
if res_find is not None:
|
||||
args = {'continue': delete_continue}
|
||||
args = {}
|
||||
if delete_continue is not None:
|
||||
args['continue'] = delete_continue
|
||||
commands.append([name, 'service_del', args])
|
||||
|
||||
elif action == "member":
|
||||
@@ -929,7 +971,7 @@ def main():
|
||||
|
||||
# Execute commands
|
||||
changed = ansible_module.execute_ipa_commands(
|
||||
commands, fail_on_member_errors=True)
|
||||
commands, batch=True, keeponly=[], fail_on_member_errors=True)
|
||||
|
||||
# Done
|
||||
ansible_module.exit_json(changed=changed, **exit_args)
|
||||
|
||||
@@ -741,7 +741,8 @@ user:
|
||||
from ansible.module_utils.ansible_freeipa_module import \
|
||||
IPAAnsibleModule, compare_args_ipa, gen_add_del_lists, date_format, \
|
||||
encode_certificate, load_cert_from_str, DN_x500_text, to_text, \
|
||||
ipalib_errors
|
||||
ipalib_errors, gen_add_list, gen_intersection_list, \
|
||||
convert_input_certificates
|
||||
from ansible.module_utils import six
|
||||
if six.PY3:
|
||||
unicode = str
|
||||
@@ -1006,9 +1007,8 @@ def gen_certmapdata_args(certmapdata):
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def result_handler(module, result, command, name, args, errors, exit_args,
|
||||
single_user):
|
||||
|
||||
def result_handler(module, result, command, name, args, exit_args,
|
||||
errors, single_user):
|
||||
if "random" in args and command in ["user_add", "user_mod"] \
|
||||
and "randompassword" in result["result"]:
|
||||
if single_user:
|
||||
@@ -1018,31 +1018,8 @@ def result_handler(module, result, command, name, args, errors, exit_args,
|
||||
exit_args.setdefault(name, {})["randompassword"] = \
|
||||
result["result"]["randompassword"]
|
||||
|
||||
# Get all errors
|
||||
# All "already a member" and "not a member" failures in the
|
||||
# result are ignored. All others are reported.
|
||||
if "failed" in result and len(result["failed"]) > 0:
|
||||
for item in result["failed"]:
|
||||
failed_item = result["failed"][item]
|
||||
for member_type in failed_item:
|
||||
for member, failure in failed_item[member_type]:
|
||||
if "already a member" in failure \
|
||||
or "not a member" in failure:
|
||||
continue
|
||||
errors.append("%s: %s %s: %s" % (
|
||||
command, member_type, member, failure))
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def exception_handler(module, ex, errors, exit_args, single_user):
|
||||
msg = str(ex)
|
||||
if "already contains" in msg \
|
||||
or "does not contain" in msg:
|
||||
return True
|
||||
# The canonical principal name may not be removed
|
||||
if "equal to the canonical principal name must" in msg:
|
||||
return True
|
||||
return False
|
||||
IPAAnsibleModule.member_error_handler(module, result, command, name, args,
|
||||
errors)
|
||||
|
||||
|
||||
def main():
|
||||
@@ -1127,7 +1104,7 @@ def main():
|
||||
nomembers=dict(type='bool', default=None),
|
||||
idp=dict(type="str", default=None, aliases=['ipaidpconfiglink']),
|
||||
idp_user_id=dict(type="str", default=None,
|
||||
aliases=['ipaidpconfiglink']),
|
||||
aliases=['ipaidpsub']),
|
||||
rename=dict(type="str", required=False, default=None,
|
||||
aliases=["new_name"]),
|
||||
)
|
||||
@@ -1277,6 +1254,8 @@ def main():
|
||||
preserve, update_password, smb_logon_script, smb_profile_path,
|
||||
smb_home_dir, smb_home_drive, idp, idp_user_id, rename,
|
||||
)
|
||||
certificate = convert_input_certificates(ansible_module, certificate,
|
||||
state)
|
||||
certmapdata = convert_certmapdata(certmapdata)
|
||||
|
||||
# Init
|
||||
@@ -1387,6 +1366,8 @@ def main():
|
||||
update_password, smb_logon_script, smb_profile_path,
|
||||
smb_home_dir, smb_home_drive, idp, idp_user_id, rename,
|
||||
)
|
||||
certificate = convert_input_certificates(ansible_module,
|
||||
certificate, state)
|
||||
certmapdata = convert_certmapdata(certmapdata)
|
||||
|
||||
# Check API specific parameters
|
||||
@@ -1397,7 +1378,11 @@ def main():
|
||||
|
||||
email = extend_emails(email, default_email_domain)
|
||||
|
||||
elif isinstance(user, (str, unicode)):
|
||||
elif (
|
||||
isinstance(
|
||||
user, (str, unicode) # pylint: disable=W0012,E0606
|
||||
)
|
||||
):
|
||||
name = user
|
||||
else:
|
||||
ansible_module.fail_json(msg="User '%s' is not valid" %
|
||||
@@ -1646,10 +1631,12 @@ def main():
|
||||
msg="No user '%s'" % name)
|
||||
|
||||
# Ensure managers are present
|
||||
if manager is not None and len(manager) > 0:
|
||||
manager_add = gen_add_list(
|
||||
manager, res_find.get("manager"))
|
||||
if manager_add is not None and len(manager_add) > 0:
|
||||
commands.append([name, "user_add_manager",
|
||||
{
|
||||
"user": manager,
|
||||
"user": manager_add,
|
||||
}])
|
||||
|
||||
# Principals need to be added and removed one by one,
|
||||
@@ -1658,8 +1645,10 @@ def main():
|
||||
# the removal of non-existing entries.
|
||||
|
||||
# Ensure principals are present
|
||||
if principal is not None and len(principal) > 0:
|
||||
for _principal in principal:
|
||||
principal_add = gen_add_list(
|
||||
principal, res_find.get("krbprincipalname"))
|
||||
if principal_add is not None and len(principal_add) > 0:
|
||||
for _principal in principal_add:
|
||||
commands.append([name, "user_add_principal",
|
||||
{
|
||||
"krbprincipalname":
|
||||
@@ -1672,8 +1661,11 @@ def main():
|
||||
# the removal of non-existing entries.
|
||||
|
||||
# Ensure certificates are present
|
||||
if certificate is not None and len(certificate) > 0:
|
||||
for _certificate in certificate:
|
||||
certificate_add = gen_add_list(
|
||||
certificate, res_find.get("usercertificate"))
|
||||
if certificate_add is not None and \
|
||||
len(certificate_add) > 0:
|
||||
for _certificate in certificate_add:
|
||||
commands.append([name, "user_add_cert",
|
||||
{
|
||||
"usercertificate":
|
||||
@@ -1685,8 +1677,11 @@ def main():
|
||||
# one reliably (https://pagure.io/freeipa/issue/8097)
|
||||
|
||||
# Ensure certmapdata are present
|
||||
if certmapdata is not None and len(certmapdata) > 0:
|
||||
for _data in certmapdata:
|
||||
certmapdata_add = gen_add_list(
|
||||
certmapdata, res_find.get("ipacertmapdata"))
|
||||
if certmapdata_add is not None and \
|
||||
len(certmapdata_add) > 0:
|
||||
for _data in certmapdata_add:
|
||||
commands.append([name, "user_add_certmapdata",
|
||||
gen_certmapdata_args(_data)])
|
||||
|
||||
@@ -1707,10 +1702,12 @@ def main():
|
||||
msg="No user '%s'" % name)
|
||||
|
||||
# Ensure managers are absent
|
||||
if manager is not None and len(manager) > 0:
|
||||
manager_del = gen_intersection_list(
|
||||
manager, res_find.get("manager"))
|
||||
if manager_del is not None and len(manager_del) > 0:
|
||||
commands.append([name, "user_remove_manager",
|
||||
{
|
||||
"user": manager,
|
||||
"user": manager_del,
|
||||
}])
|
||||
|
||||
# Principals need to be added and removed one by one,
|
||||
@@ -1719,10 +1716,12 @@ def main():
|
||||
# the removal of non-existing entries.
|
||||
|
||||
# Ensure principals are absent
|
||||
if principal is not None and len(principal) > 0:
|
||||
principal_del = gen_intersection_list(
|
||||
principal, res_find.get("krbprincipalname"))
|
||||
if principal_del is not None and len(principal_del) > 0:
|
||||
commands.append([name, "user_remove_principal",
|
||||
{
|
||||
"krbprincipalname": principal,
|
||||
"krbprincipalname": principal_del,
|
||||
}])
|
||||
|
||||
# Certificates need to be added and removed one by one,
|
||||
@@ -1731,8 +1730,11 @@ def main():
|
||||
# the removal of non-existing entries.
|
||||
|
||||
# Ensure certificates are absent
|
||||
if certificate is not None and len(certificate) > 0:
|
||||
for _certificate in certificate:
|
||||
certificate_del = gen_intersection_list(
|
||||
certificate, res_find.get("usercertificate"))
|
||||
if certificate_del is not None and \
|
||||
len(certificate_del) > 0:
|
||||
for _certificate in certificate_del:
|
||||
commands.append([name, "user_remove_cert",
|
||||
{
|
||||
"usercertificate":
|
||||
@@ -1744,10 +1746,13 @@ def main():
|
||||
# one reliably (https://pagure.io/freeipa/issue/8097)
|
||||
|
||||
# Ensure certmapdata are absent
|
||||
if certmapdata is not None and len(certmapdata) > 0:
|
||||
certmapdata_del = gen_intersection_list(
|
||||
certmapdata, res_find.get("ipacertmapdata"))
|
||||
if certmapdata_del is not None and \
|
||||
len(certmapdata_del) > 0:
|
||||
# Using issuer and subject can only be done one by
|
||||
# one reliably (https://pagure.io/freeipa/issue/8097)
|
||||
for _data in certmapdata:
|
||||
for _data in certmapdata_del:
|
||||
commands.append([name, "user_remove_certmapdata",
|
||||
gen_certmapdata_args(_data)])
|
||||
elif state == "undeleted":
|
||||
@@ -1791,7 +1796,7 @@ def main():
|
||||
# Execute commands
|
||||
|
||||
changed = ansible_module.execute_ipa_commands(
|
||||
commands, result_handler, exception_handler,
|
||||
commands, result_handler, batch=True, keeponly=["randompassword"],
|
||||
exit_args=exit_args, single_user=users is None)
|
||||
|
||||
# Done
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
-r requirements-tests.txt
|
||||
ipdb==0.13.4
|
||||
pre-commit==2.20.0
|
||||
flake8==6.0.0
|
||||
flake8==7.0.0
|
||||
flake8-bugbear
|
||||
pylint==2.17.2
|
||||
pylint>=3.2
|
||||
wrapt==1.14.1
|
||||
pydocstyle==6.3.0
|
||||
yamllint==1.32.0
|
||||
ansible-lint >= 6.22
|
||||
yamllint==1.35.1
|
||||
ansible-lint>=24.5.0
|
||||
|
||||
@@ -42,7 +42,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -6,7 +6,7 @@ galaxy_info:
|
||||
description: A role to backup and restore an IPA server
|
||||
company: Red Hat, Inc
|
||||
license: GPLv3
|
||||
min_ansible_version: "2.13"
|
||||
min_ansible_version: "2.15"
|
||||
platforms:
|
||||
- name: Fedora
|
||||
versions:
|
||||
|
||||
@@ -34,7 +34,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -152,8 +152,10 @@ def configure_dns_resolver(nameservers, searchdomains, fstore=None):
|
||||
if not searchdomains or not isinstance(searchdomains, list):
|
||||
raise AssertionError("searchdomains must be of type list")
|
||||
|
||||
changed = False
|
||||
if fstore is not None and not fstore.has_file(paths.RESOLV_CONF):
|
||||
fstore.backup_file(paths.RESOLV_CONF)
|
||||
changed = True
|
||||
|
||||
resolve1_enabled = detect_resolve1_resolv_conf()
|
||||
if "NetworkManager" not in services.knownservices:
|
||||
@@ -192,6 +194,7 @@ def configure_dns_resolver(nameservers, searchdomains, fstore=None):
|
||||
sdrd_service = services.service("systemd-resolved.service")
|
||||
if sdrd_service.is_enabled():
|
||||
sdrd_service.reload_or_restart()
|
||||
changed = True
|
||||
|
||||
# Then configure NetworkManager or resolve.conf
|
||||
if nm_service.is_enabled():
|
||||
@@ -217,6 +220,7 @@ def configure_dns_resolver(nameservers, searchdomains, fstore=None):
|
||||
outf.write(cfg)
|
||||
# reload NetworkManager
|
||||
nm_service.reload_or_restart()
|
||||
changed = True
|
||||
|
||||
# Configure resolv.conf if NetworkManager and systemd-resoled are not
|
||||
# enabled
|
||||
@@ -231,6 +235,9 @@ def configure_dns_resolver(nameservers, searchdomains, fstore=None):
|
||||
cfg.append("nameserver %s" % nameserver)
|
||||
with open(paths.RESOLV_CONF, 'w') as outf:
|
||||
outf.write('\n'.join(cfg))
|
||||
changed = True
|
||||
|
||||
return changed
|
||||
|
||||
|
||||
def unconfigure_dns_resolver(fstore=None):
|
||||
@@ -239,8 +246,11 @@ def unconfigure_dns_resolver(fstore=None):
|
||||
|
||||
:param fstore: optional file store for resolv.conf restore
|
||||
"""
|
||||
changed = False
|
||||
|
||||
if fstore is not None and fstore.has_file(paths.RESOLV_CONF):
|
||||
fstore.restore_file(paths.RESOLV_CONF)
|
||||
changed = True
|
||||
|
||||
if os.path.isfile(NETWORK_MANAGER_IPA_CONF):
|
||||
os.unlink(NETWORK_MANAGER_IPA_CONF)
|
||||
@@ -252,6 +262,7 @@ def unconfigure_dns_resolver(fstore=None):
|
||||
nm_service = services.knownservices['NetworkManager']
|
||||
if nm_service.is_enabled():
|
||||
nm_service.reload_or_restart()
|
||||
changed = True
|
||||
|
||||
if os.path.isfile(SYSTEMD_RESOLVED_IPA_CONF):
|
||||
os.unlink(SYSTEMD_RESOLVED_IPA_CONF)
|
||||
@@ -261,6 +272,9 @@ def unconfigure_dns_resolver(fstore=None):
|
||||
sdrd_service = services.service("systemd-resolved.service")
|
||||
if sdrd_service.is_enabled():
|
||||
sdrd_service.reload_or_restart()
|
||||
changed = True
|
||||
|
||||
return changed
|
||||
|
||||
|
||||
def main():
|
||||
@@ -308,11 +322,12 @@ def main():
|
||||
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
|
||||
|
||||
if state == "present":
|
||||
configure_dns_resolver(nameservers, searchdomains, fstore)
|
||||
changed = configure_dns_resolver(nameservers,
|
||||
searchdomains, fstore)
|
||||
else:
|
||||
unconfigure_dns_resolver(fstore)
|
||||
changed = unconfigure_dns_resolver(fstore)
|
||||
|
||||
module.exit_json(changed=True)
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -89,9 +89,13 @@ try:
|
||||
from ipapython.ipautil import run
|
||||
from ipalib.constants import DEFAULT_CONFIG
|
||||
try:
|
||||
from ipalib.install.kinit import kinit_password, kinit_keytab
|
||||
from ipalib.kinit import kinit_password, kinit_keytab
|
||||
except ImportError:
|
||||
from ipapython.ipautil import kinit_password, kinit_keytab
|
||||
try:
|
||||
from ipalib.install.kinit import kinit_password, kinit_keytab
|
||||
except ImportError:
|
||||
# pre 4.5.0
|
||||
from ipapython.ipautil import kinit_password, kinit_keytab
|
||||
except ImportError as _err:
|
||||
MODULE_IMPORT_ERROR = str(_err)
|
||||
else:
|
||||
|
||||
@@ -156,6 +156,7 @@ options:
|
||||
description: True if selinux status check passed
|
||||
required: false
|
||||
type: bool
|
||||
default: false
|
||||
krb_name:
|
||||
description: The krb5 config file name
|
||||
type: str
|
||||
|
||||
@@ -6,7 +6,7 @@ galaxy_info:
|
||||
description: A role to join a machine to an IPA domain
|
||||
company: Red Hat, Inc
|
||||
license: GPLv3
|
||||
min_ansible_version: "2.13"
|
||||
min_ansible_version: "2.15"
|
||||
platforms:
|
||||
- name: Fedora
|
||||
versions:
|
||||
|
||||
@@ -173,9 +173,13 @@ try:
|
||||
ipa_generate_password
|
||||
from ipapython.dn import DN
|
||||
try:
|
||||
from ipalib.install.kinit import kinit_keytab, kinit_password
|
||||
from ipalib.kinit import kinit_password, kinit_keytab
|
||||
except ImportError:
|
||||
from ipapython.ipautil import kinit_keytab, kinit_password
|
||||
try:
|
||||
from ipalib.install.kinit import kinit_keytab, kinit_password
|
||||
except ImportError:
|
||||
# pre 4.5.0
|
||||
from ipapython.ipautil import kinit_keytab, kinit_password
|
||||
from ipapython.ipa_log_manager import standard_logging_setup
|
||||
from gssapi.exceptions import GSSError
|
||||
try:
|
||||
|
||||
@@ -36,7 +36,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -139,7 +139,7 @@ def main():
|
||||
conn.connect(ccache=installer._ccache)
|
||||
remote_api.Command['hostgroup_add_member'](
|
||||
u'ipaservers',
|
||||
host=[unicode(api.env.host)],
|
||||
host=[unicode(api.env.host)], # pylint: disable=W0012,E0606
|
||||
)
|
||||
finally:
|
||||
if conn.isconnected():
|
||||
|
||||
@@ -51,6 +51,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
domain:
|
||||
description: Primary DNS domain of the IPA deployment
|
||||
type: str
|
||||
@@ -70,6 +71,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_host_dns:
|
||||
description: Do not use DNS for hostname lookup during installation
|
||||
type: bool
|
||||
@@ -97,6 +99,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
force_join:
|
||||
description: Force client enrollment even if already enrolled
|
||||
type: bool
|
||||
|
||||
@@ -90,7 +90,7 @@ from ansible.module_utils.ansible_ipa_replica import (
|
||||
check_imports, AnsibleModuleLog, setup_logging, installer, DN, paths,
|
||||
gen_env_boostrap_finalize_core, constants, api_bootstrap_finalize,
|
||||
gen_ReplicaConfig, gen_remote_api, api, redirect_stdout, service,
|
||||
find_providing_servers, services
|
||||
find_providing_servers, services, clean_up_hsm_nicknames
|
||||
)
|
||||
|
||||
|
||||
@@ -168,6 +168,9 @@ def main():
|
||||
# Everything installed properly, activate ipa service.
|
||||
services.knownservices.ipa.enable()
|
||||
|
||||
if options.setup_ca and clean_up_hsm_nicknames is not None:
|
||||
clean_up_hsm_nicknames(api)
|
||||
|
||||
# Print a warning if CA role is only installed on one server
|
||||
if len(ca_servers) == 1:
|
||||
msg = u'''
|
||||
|
||||
@@ -51,6 +51,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
domain:
|
||||
description: Primary DNS domain of the IPA deployment
|
||||
type: str
|
||||
@@ -70,6 +71,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_host_dns:
|
||||
description: Do not use DNS for hostname lookup during installation
|
||||
type: bool
|
||||
@@ -97,6 +99,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
force_join:
|
||||
description: Force client enrollment even if already enrolled
|
||||
type: bool
|
||||
@@ -156,6 +159,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
author:
|
||||
- Thomas Woerner (@t-woerner)
|
||||
'''
|
||||
@@ -333,9 +337,7 @@ def main():
|
||||
|
||||
# done #
|
||||
|
||||
ansible_module.exit_json(changed=True,
|
||||
config_master_host_name=config.master_host_name,
|
||||
config_ca_host_name=config.ca_host_name)
|
||||
ansible_module.exit_json(changed=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -53,6 +53,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
domain:
|
||||
description: Primary DNS domain of the IPA deployment
|
||||
type: str
|
||||
@@ -77,6 +78,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_host_dns:
|
||||
description: Do not use DNS for hostname lookup during installation
|
||||
type: bool
|
||||
@@ -104,6 +106,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
dirsrv_cert_name:
|
||||
description: Name of the Directory Server SSL certificate to install
|
||||
type: str
|
||||
@@ -118,6 +121,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
http_cert_name:
|
||||
description: Name of the Apache Server SSL certificate to install
|
||||
type: str
|
||||
@@ -132,6 +136,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
pkinit_cert_name:
|
||||
description: Name of the Kerberos KDC SSL certificate to install
|
||||
type: str
|
||||
@@ -182,6 +187,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_reverse:
|
||||
description: Do not create new reverse DNS zone
|
||||
type: bool
|
||||
@@ -197,6 +203,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_forwarders:
|
||||
description: Do not add any DNS forwarders, use root servers instead
|
||||
type: bool
|
||||
@@ -250,6 +257,10 @@ options:
|
||||
type: bool
|
||||
default: no
|
||||
required: no
|
||||
ipa_client_installed:
|
||||
description: Was client configured already
|
||||
type: bool
|
||||
required: yes
|
||||
author:
|
||||
- Thomas Woerner (@t-woerner)
|
||||
'''
|
||||
@@ -275,7 +286,8 @@ from ansible.module_utils.ansible_ipa_replica import (
|
||||
check_domain_level_is_supported, errors, ScriptError, setup_logging,
|
||||
logger, check_dns_resolution, service, find_providing_server, ca, kra,
|
||||
dns, no_matching_interface_for_ip_address_warning, adtrust,
|
||||
constants, api, redirect_stdout, replica_conn_check, tasks
|
||||
constants, api, redirect_stdout, replica_conn_check, tasks,
|
||||
install_ca_cert
|
||||
)
|
||||
from ansible.module_utils import six
|
||||
|
||||
@@ -353,6 +365,7 @@ def main():
|
||||
skip_conncheck=dict(required=False, type='bool'),
|
||||
sid_generation_always=dict(required=False, type='bool',
|
||||
default=False),
|
||||
ipa_client_installed=dict(required=True, type='bool'),
|
||||
),
|
||||
supports_check_mode=False,
|
||||
)
|
||||
@@ -436,6 +449,7 @@ def main():
|
||||
# options._random_serial_numbers is generated by ca.install_check and
|
||||
# later used by ca.install in the _setup_ca module.
|
||||
options._random_serial_numbers = False
|
||||
ipa_client_installed = ansible_module.params.get('ipa_client_installed')
|
||||
|
||||
# init #
|
||||
|
||||
@@ -601,10 +615,20 @@ def main():
|
||||
ansible_log.debug("-- CA_CRT --")
|
||||
|
||||
cafile = paths.IPA_CA_CRT
|
||||
if not os.path.isfile(cafile):
|
||||
ansible_module.fail_json(
|
||||
msg="CA cert file is not available! Please reinstall"
|
||||
"the client and try again.")
|
||||
if install_ca_cert is not None:
|
||||
if not os.path.isfile(cafile):
|
||||
ansible_module.fail_json(
|
||||
msg="CA cert file is not available! Please reinstall"
|
||||
"the client and try again.")
|
||||
else:
|
||||
if ipa_client_installed:
|
||||
# host was already an IPA client, refresh client cert stores to
|
||||
# ensure we have up to date CA certs.
|
||||
try:
|
||||
ipautil.run([paths.IPA_CERTUPDATE])
|
||||
except ipautil.CalledProcessError:
|
||||
ansible_module.fail_json(
|
||||
msg="ipa-certupdate failed to refresh certs.")
|
||||
|
||||
ansible_log.debug("-- REMOTE_API --")
|
||||
|
||||
@@ -658,7 +682,7 @@ def main():
|
||||
# Check authorization
|
||||
result = remote_api.Command['hostgroup_find'](
|
||||
cn=u'ipaservers',
|
||||
host=[unicode(api.env.host)]
|
||||
host=[unicode(api.env.host)] # pylint: disable=W0012,E0606
|
||||
)['result']
|
||||
add_to_ipaservers = not result
|
||||
|
||||
|
||||
@@ -127,6 +127,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
author:
|
||||
- Thomas Woerner (@t-woerner)
|
||||
'''
|
||||
|
||||
@@ -61,6 +61,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
forward_policy:
|
||||
description: DNS forwarding policy for global forwarders
|
||||
type: str
|
||||
|
||||
@@ -51,6 +51,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
domain:
|
||||
description: Primary DNS domain of the IPA deployment
|
||||
type: str
|
||||
@@ -70,6 +71,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_host_dns:
|
||||
description: Do not use DNS for hostname lookup during installation
|
||||
type: bool
|
||||
@@ -108,6 +110,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
force_join:
|
||||
description: Force client enrollment even if already enrolled
|
||||
type: bool
|
||||
@@ -176,6 +179,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
author:
|
||||
- Thomas Woerner (@t-woerner)
|
||||
'''
|
||||
|
||||
@@ -51,6 +51,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
domain:
|
||||
description: Primary DNS domain of the IPA deployment
|
||||
type: str
|
||||
@@ -70,6 +71,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_host_dns:
|
||||
description: Do not use DNS for hostname lookup during installation
|
||||
type: bool
|
||||
@@ -101,6 +103,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
force_join:
|
||||
description: Force client enrollment even if already enrolled
|
||||
type: bool
|
||||
|
||||
@@ -42,6 +42,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
domain:
|
||||
description: Primary DNS domain of the IPA deployment
|
||||
type: str
|
||||
@@ -51,6 +52,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
realm:
|
||||
description: Kerberos realm name of the IPA deployment
|
||||
type: str
|
||||
@@ -66,6 +68,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
hidden_replica:
|
||||
description: Install a hidden replica
|
||||
type: bool
|
||||
@@ -112,18 +115,21 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
http_cert_files:
|
||||
description:
|
||||
File containing the Apache Server SSL certificate and private key
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
pkinit_cert_files:
|
||||
description:
|
||||
File containing the Kerberos KDC SSL certificate and private key
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_ntp:
|
||||
description: Do not configure ntp
|
||||
type: bool
|
||||
@@ -134,6 +140,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
ntp_pool:
|
||||
description: ntp server pool to use
|
||||
type: str
|
||||
@@ -153,6 +160,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_forwarders:
|
||||
description: Do not add any DNS forwarders, use root servers instead
|
||||
type: bool
|
||||
@@ -191,7 +199,7 @@ from ansible.module_utils.ansible_ipa_replica import (
|
||||
paths, sysrestore, ansible_module_get_parsed_ip_addresses, service,
|
||||
redirect_stdout, create_ipa_conf, ipautil,
|
||||
x509, validate_domain_name, common_check,
|
||||
IPA_PYTHON_VERSION, getargspec, adtrustinstance
|
||||
IPA_PYTHON_VERSION, getargspec, adtrustinstance, install_ca_cert
|
||||
)
|
||||
|
||||
|
||||
@@ -542,7 +550,8 @@ def main():
|
||||
# additional
|
||||
client_enrolled=client_enrolled,
|
||||
change_master_for_certmonger=change_master_for_certmonger,
|
||||
sid_generation_always=sid_generation_always
|
||||
sid_generation_always=sid_generation_always,
|
||||
install_ca_certs=install_ca_cert is not None
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ galaxy_info:
|
||||
description: A role to setup an IPA domain replica
|
||||
company: Red Hat, Inc
|
||||
license: GPLv3
|
||||
min_ansible_version: "2.13"
|
||||
min_ansible_version: "2.15"
|
||||
platforms:
|
||||
- name: Fedora
|
||||
versions:
|
||||
|
||||
@@ -49,7 +49,7 @@ __all__ = ["contextlib", "dnsexception", "dnsresolver", "dnsreversename",
|
||||
"dnsname", "kernel_keyring", "krbinstance", "getargspec",
|
||||
"adtrustinstance", "paths", "api", "dsinstance", "ipaldap", "Env",
|
||||
"ipautil", "installutils", "IPA_PYTHON_VERSION", "NUM_VERSION",
|
||||
"ReplicaConfig", "create_api"]
|
||||
"ReplicaConfig", "create_api", "clean_up_hsm_nicknames"]
|
||||
|
||||
import sys
|
||||
import logging
|
||||
@@ -104,7 +104,10 @@ try:
|
||||
from ipaclient.install.ipachangeconf import IPAChangeConf
|
||||
from ipalib.install import certstore, sysrestore
|
||||
from ipapython.ipautil import ipa_generate_password
|
||||
from ipalib.install.kinit import kinit_keytab
|
||||
try:
|
||||
from ipalib.kinit import kinit_keytab
|
||||
except ImportError:
|
||||
from ipalib.install.kinit import kinit_keytab
|
||||
from ipapython import ipaldap, ipautil, kernel_keyring
|
||||
from ipapython.certdb import IPA_CA_TRUST_FLAGS, \
|
||||
EXTERNAL_CA_TRUST_FLAGS
|
||||
@@ -141,7 +144,7 @@ try:
|
||||
from ipaserver.install.replication import (
|
||||
ReplicationManager, replica_conn_check)
|
||||
from ipaserver.install.server.replicainstall import (
|
||||
make_pkcs12_info, install_replica_ds, install_krb, install_ca_cert,
|
||||
make_pkcs12_info, install_replica_ds, install_krb,
|
||||
install_http, install_dns_records, create_ipa_conf, check_dirsrv,
|
||||
check_dns_resolution, configure_certmonger,
|
||||
remove_replica_info_dir,
|
||||
@@ -154,6 +157,16 @@ try:
|
||||
# ensure_enrolled,
|
||||
promotion_check_ipa_domain
|
||||
)
|
||||
try:
|
||||
from ipaserver.install.server.replicainstall import \
|
||||
install_ca_cert
|
||||
except ImportError:
|
||||
install_ca_cert = None
|
||||
try:
|
||||
from ipaserver.install.server.replicainstall import \
|
||||
clean_up_hsm_nicknames
|
||||
except ImportError:
|
||||
clean_up_hsm_nicknames = None
|
||||
import SSSDConfig
|
||||
from subprocess import CalledProcessError
|
||||
|
||||
|
||||
@@ -209,6 +209,7 @@
|
||||
server: "{{ result_ipareplica_test.server }}"
|
||||
skip_conncheck: "{{ ipareplica_skip_conncheck }}"
|
||||
sid_generation_always: "{{ result_ipareplica_test.sid_generation_always }}"
|
||||
ipa_client_installed: "{{ result_ipareplica_test.client_enrolled }}"
|
||||
register: result_ipareplica_prepare
|
||||
|
||||
- name: Install - Add to ipaservers
|
||||
@@ -276,6 +277,7 @@
|
||||
config_ca_host_name: "{{ result_ipareplica_prepare.config_ca_host_name }}"
|
||||
config_ips: "{{ result_ipareplica_prepare.config_ips }}"
|
||||
register: result_ipareplica_install_ca_certs
|
||||
when: result_ipareplica_test.install_ca_certs
|
||||
|
||||
- name: Install - Setup DS
|
||||
ipareplica_setup_ds:
|
||||
@@ -312,7 +314,7 @@
|
||||
dirman_password: "{{ __derived_dirman_password }}"
|
||||
config_setup_ca: "{{ result_ipareplica_prepare.config_setup_ca }}"
|
||||
config_master_host_name:
|
||||
"{{ result_ipareplica_install_ca_certs.config_master_host_name }}"
|
||||
"{{ result_ipareplica_prepare.config_master_host_name }}"
|
||||
config_ca_host_name: "{{ result_ipareplica_prepare.config_ca_host_name }}"
|
||||
config_ips: "{{ result_ipareplica_prepare.config_ips }}"
|
||||
register: result_ipareplica_setup_ds
|
||||
@@ -339,7 +341,7 @@
|
||||
### additional ###
|
||||
server: "{{ result_ipareplica_test.server }}"
|
||||
config_master_host_name:
|
||||
"{{ result_ipareplica_install_ca_certs.config_master_host_name }}"
|
||||
"{{ result_ipareplica_prepare.config_master_host_name }}"
|
||||
config_ca_host_name: "{{ result_ipareplica_prepare.config_ca_host_name }}"
|
||||
ccache: "{{ result_ipareplica_prepare.ccache }}"
|
||||
installer_ccache: "{{ result_ipareplica_prepare.installer_ccache }}"
|
||||
@@ -362,7 +364,7 @@
|
||||
subject_base: "{{ result_ipareplica_prepare.subject_base }}"
|
||||
### additional ###
|
||||
config_master_host_name:
|
||||
"{{ result_ipareplica_install_ca_certs.config_master_host_name }}"
|
||||
"{{ result_ipareplica_prepare.config_master_host_name }}"
|
||||
ccache: "{{ result_ipareplica_prepare.ccache }}"
|
||||
_pkinit_pkcs12_info: "{{ result_ipareplica_prepare._pkinit_pkcs12_info if result_ipareplica_prepare._pkinit_pkcs12_info != None else omit }}"
|
||||
_top_dir: "{{ result_ipareplica_prepare._top_dir }}"
|
||||
@@ -393,7 +395,7 @@
|
||||
### additional ###
|
||||
server: "{{ result_ipareplica_test.server }}"
|
||||
config_master_host_name:
|
||||
"{{ result_ipareplica_install_ca_certs.config_master_host_name }}"
|
||||
"{{ result_ipareplica_prepare.config_master_host_name }}"
|
||||
config_ca_host_name: "{{ result_ipareplica_prepare.config_ca_host_name }}"
|
||||
ccache: "{{ result_ipareplica_prepare.ccache }}"
|
||||
installer_ccache: "{{ result_ipareplica_prepare.installer_ccache }}"
|
||||
@@ -406,7 +408,7 @@
|
||||
dirman_password: "{{ __derived_dirman_password }}"
|
||||
setup_ca: "{{ result_ipareplica_prepare.config_setup_ca }}"
|
||||
master:
|
||||
"{{ result_ipareplica_install_ca_certs.config_master_host_name }}"
|
||||
"{{ result_ipareplica_prepare.config_master_host_name }}"
|
||||
when: result_ipareplica_test.change_master_for_certmonger
|
||||
|
||||
- name: Install - DS enable SSL
|
||||
@@ -420,7 +422,7 @@
|
||||
subject_base: "{{ result_ipareplica_prepare.subject_base }}"
|
||||
### additional ###
|
||||
config_master_host_name:
|
||||
"{{ result_ipareplica_install_ca_certs.config_master_host_name }}"
|
||||
"{{ result_ipareplica_prepare.config_master_host_name }}"
|
||||
ccache: "{{ result_ipareplica_prepare.ccache }}"
|
||||
_ca_enabled: "{{ result_ipareplica_prepare._ca_enabled }}"
|
||||
_ca_file: "{{ result_ipareplica_prepare._ca_file }}"
|
||||
@@ -441,7 +443,7 @@
|
||||
subject_base: "{{ result_ipareplica_prepare.subject_base }}"
|
||||
### additional ###
|
||||
config_master_host_name:
|
||||
"{{ result_ipareplica_install_ca_certs.config_master_host_name }}"
|
||||
"{{ result_ipareplica_prepare.config_master_host_name }}"
|
||||
config_ca_host_name: "{{ result_ipareplica_prepare.config_ca_host_name }}"
|
||||
ccache: "{{ result_ipareplica_prepare.ccache }}"
|
||||
_ca_enabled: "{{ result_ipareplica_prepare._ca_enabled }}"
|
||||
@@ -473,7 +475,7 @@
|
||||
### additional ###
|
||||
server: "{{ result_ipareplica_test.server }}"
|
||||
config_master_host_name:
|
||||
"{{ result_ipareplica_install_ca_certs.config_master_host_name }}"
|
||||
"{{ result_ipareplica_prepare.config_master_host_name }}"
|
||||
config_ca_host_name: "{{ result_ipareplica_prepare.config_ca_host_name }}"
|
||||
ccache: "{{ result_ipareplica_prepare.ccache }}"
|
||||
installer_ccache: "{{ result_ipareplica_prepare.installer_ccache }}"
|
||||
@@ -498,7 +500,7 @@
|
||||
subject_base: "{{ result_ipareplica_prepare.subject_base }}"
|
||||
### additional ###
|
||||
config_master_host_name:
|
||||
"{{ result_ipareplica_install_ca_certs.config_master_host_name }}"
|
||||
"{{ result_ipareplica_prepare.config_master_host_name }}"
|
||||
ccache: "{{ result_ipareplica_prepare.ccache }}"
|
||||
_ca_file: "{{ result_ipareplica_prepare._ca_file }}"
|
||||
_top_dir: "{{ result_ipareplica_prepare._top_dir }}"
|
||||
@@ -549,9 +551,9 @@
|
||||
dirman_password: "{{ __derived_dirman_password }}"
|
||||
config_setup_ca: "{{ result_ipareplica_prepare.config_setup_ca }}"
|
||||
config_master_host_name:
|
||||
"{{ result_ipareplica_install_ca_certs.config_master_host_name }}"
|
||||
"{{ result_ipareplica_prepare.config_master_host_name }}"
|
||||
config_ca_host_name:
|
||||
"{{ result_ipareplica_install_ca_certs.config_ca_host_name }}"
|
||||
"{{ result_ipareplica_prepare.config_ca_host_name }}"
|
||||
config_ips: "{{ result_ipareplica_prepare.config_ips }}"
|
||||
when: result_ipareplica_prepare._ca_enabled
|
||||
|
||||
@@ -565,7 +567,7 @@
|
||||
subject_base: "{{ result_ipareplica_prepare.subject_base }}"
|
||||
### additional ###
|
||||
config_master_host_name:
|
||||
"{{ result_ipareplica_install_ca_certs.config_master_host_name }}"
|
||||
"{{ result_ipareplica_prepare.config_master_host_name }}"
|
||||
ccache: "{{ result_ipareplica_prepare.ccache }}"
|
||||
_ca_enabled: "{{ result_ipareplica_prepare._ca_enabled }}"
|
||||
_ca_file: "{{ result_ipareplica_prepare._ca_file }}"
|
||||
@@ -585,7 +587,7 @@
|
||||
subject_base: "{{ result_ipareplica_prepare.subject_base }}"
|
||||
### additional ###
|
||||
config_master_host_name:
|
||||
"{{ result_ipareplica_install_ca_certs.config_master_host_name }}"
|
||||
"{{ result_ipareplica_prepare.config_master_host_name }}"
|
||||
ccache: "{{ result_ipareplica_prepare.ccache }}"
|
||||
_ca_enabled: "{{ result_ipareplica_prepare._ca_enabled }}"
|
||||
_ca_file: "{{ result_ipareplica_prepare._ca_file }}"
|
||||
@@ -645,7 +647,7 @@
|
||||
subject_base: "{{ result_ipareplica_prepare.subject_base }}"
|
||||
### additional ###
|
||||
config_master_host_name:
|
||||
"{{ result_ipareplica_install_ca_certs.config_master_host_name }}"
|
||||
"{{ result_ipareplica_prepare.config_master_host_name }}"
|
||||
ccache: "{{ result_ipareplica_prepare.ccache }}"
|
||||
_ca_file: "{{ result_ipareplica_prepare._ca_file }}"
|
||||
_top_dir: "{{ result_ipareplica_prepare._top_dir }}"
|
||||
|
||||
@@ -33,7 +33,7 @@ Requirements
|
||||
------------
|
||||
|
||||
**Controller**
|
||||
* Ansible version: 2.13+
|
||||
* Ansible version: 2.15+
|
||||
|
||||
**Node**
|
||||
* Supported FreeIPA version (see above)
|
||||
|
||||
@@ -77,9 +77,13 @@ try:
|
||||
from ipapython.ipautil import run
|
||||
from ipalib.constants import DEFAULT_CONFIG
|
||||
try:
|
||||
from ipalib.install.kinit import kinit_password
|
||||
from ipalib.kinit import kinit_password
|
||||
except ImportError:
|
||||
from ipapython.ipautil import kinit_password
|
||||
try:
|
||||
from ipalib.install.kinit import kinit_password
|
||||
except ImportError:
|
||||
# pre 4.5.0
|
||||
from ipapython.ipautil import kinit_password
|
||||
except ImportError as _err:
|
||||
MODULE_IMPORT_ERROR = str(_err)
|
||||
else:
|
||||
|
||||
@@ -55,6 +55,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
domain:
|
||||
description: Primary DNS domain of the IPA deployment
|
||||
type: str
|
||||
@@ -74,6 +75,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_host_dns:
|
||||
description: Do not use DNS for hostname lookup during installation
|
||||
type: bool
|
||||
@@ -114,6 +116,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
subject_base:
|
||||
description:
|
||||
The certificate subject base (default O=<realm-name>).
|
||||
@@ -134,6 +137,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_reverse:
|
||||
description: Do not create new reverse DNS zone
|
||||
type: bool
|
||||
@@ -149,6 +153,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_forwarders:
|
||||
description: Do not add any DNS forwarders, use root servers instead
|
||||
type: bool
|
||||
@@ -226,7 +231,8 @@ from ansible.module_utils.ansible_ipa_server import (
|
||||
redirect_stdout, adtrust, api, default_subject_base,
|
||||
default_ca_subject_dn, ipautil, installutils, ca, kra, dns,
|
||||
get_server_ip_address, no_matching_interface_for_ip_address_warning,
|
||||
services, logger, tasks, update_hosts_file, ScriptError
|
||||
services, logger, tasks, update_hosts_file, ScriptError, IPAChangeConf,
|
||||
realm_to_ldapi_uri
|
||||
)
|
||||
|
||||
|
||||
@@ -325,6 +331,12 @@ def main():
|
||||
# ssl certificate
|
||||
# options.dirsrv_cert_files = ansible_module.params.get(
|
||||
# 'dirsrv_cert_files')
|
||||
# hsm
|
||||
if hasattr(ca, "hsm_version"):
|
||||
options.token_name = None
|
||||
options.token_library_path = None
|
||||
options.token_password = None
|
||||
options.token_password_file = None
|
||||
# client
|
||||
# options.no_ntp = ansible_module.params.get('no_ntp')
|
||||
# certificate system
|
||||
@@ -365,6 +377,11 @@ def main():
|
||||
fstore = sysrestore.FileStore(paths.SYSRESTORE)
|
||||
sstore = sysrestore.StateFile(paths.SYSRESTORE)
|
||||
|
||||
domain_name = options.domain_name
|
||||
realm_name = options.realm_name
|
||||
host_name = options.host_name
|
||||
setup_ca = options.setup_ca
|
||||
|
||||
# subject_base
|
||||
if not options.subject_base:
|
||||
options.subject_base = str(default_subject_base(options.realm_name))
|
||||
@@ -391,27 +408,68 @@ def main():
|
||||
|
||||
# Create the management framework config file and finalize api
|
||||
target_fname = paths.IPA_DEFAULT_CONF
|
||||
# pylint: disable=invalid-name, consider-using-with
|
||||
fd = open(target_fname, "w")
|
||||
fd.write("[global]\n")
|
||||
fd.write("host=%s\n" % options.host_name)
|
||||
fd.write("basedn=%s\n" % ipautil.realm_to_suffix(options.realm_name))
|
||||
fd.write("realm=%s\n" % options.realm_name)
|
||||
fd.write("domain=%s\n" % options.domain_name)
|
||||
fd.write("xmlrpc_uri=https://%s/ipa/xml\n" %
|
||||
ipautil.format_netloc(options.host_name))
|
||||
fd.write("ldap_uri=ldapi://%%2fvar%%2frun%%2fslapd-%s.socket\n" %
|
||||
installutils.realm_to_serverid(options.realm_name))
|
||||
if options.setup_ca:
|
||||
fd.write("enable_ra=True\n")
|
||||
fd.write("ra_plugin=dogtag\n")
|
||||
fd.write("dogtag_version=10\n")
|
||||
if realm_to_ldapi_uri is not None:
|
||||
ipaconf = IPAChangeConf("IPA Server Install")
|
||||
ipaconf.setOptionAssignment(" = ")
|
||||
ipaconf.setSectionNameDelimiters(("[", "]"))
|
||||
|
||||
xmlrpc_uri = 'https://{0}/ipa/xml'.format(
|
||||
ipautil.format_netloc(host_name))
|
||||
ldapi_uri = realm_to_ldapi_uri(realm_name)
|
||||
|
||||
# [global] section
|
||||
gopts = [
|
||||
ipaconf.setOption('host', host_name),
|
||||
ipaconf.setOption('basedn',
|
||||
ipautil.realm_to_suffix(realm_name)),
|
||||
ipaconf.setOption('realm', realm_name),
|
||||
ipaconf.setOption('domain', domain_name),
|
||||
ipaconf.setOption('xmlrpc_uri', xmlrpc_uri),
|
||||
ipaconf.setOption('ldap_uri', ldapi_uri),
|
||||
ipaconf.setOption('mode', 'production')
|
||||
]
|
||||
|
||||
if setup_ca:
|
||||
gopts.extend([
|
||||
ipaconf.setOption('enable_ra', 'True'),
|
||||
ipaconf.setOption('ra_plugin', 'dogtag'),
|
||||
ipaconf.setOption('dogtag_version', '10')
|
||||
])
|
||||
else:
|
||||
gopts.extend([
|
||||
ipaconf.setOption('enable_ra', 'False'),
|
||||
ipaconf.setOption('ra_plugin', 'None')
|
||||
])
|
||||
|
||||
opts = [
|
||||
ipaconf.setSection('global', gopts),
|
||||
{'name': 'empty', 'type': 'empty'}
|
||||
]
|
||||
|
||||
ipaconf.newConf(target_fname, opts)
|
||||
else:
|
||||
fd.write("enable_ra=False\n")
|
||||
fd.write("ra_plugin=none\n")
|
||||
fd.write("mode=production\n")
|
||||
fd.close()
|
||||
# pylint: enable=invalid-name, consider-using-with
|
||||
# pylint: disable=invalid-name, consider-using-with
|
||||
fd = open(target_fname, "w")
|
||||
fd.write("[global]\n")
|
||||
fd.write("host=%s\n" % options.host_name)
|
||||
fd.write("basedn=%s\n" % ipautil.realm_to_suffix(
|
||||
options.realm_name))
|
||||
fd.write("realm=%s\n" % options.realm_name)
|
||||
fd.write("domain=%s\n" % options.domain_name)
|
||||
fd.write("xmlrpc_uri=https://%s/ipa/xml\n" %
|
||||
ipautil.format_netloc(options.host_name))
|
||||
fd.write("ldap_uri=ldapi://%%2fvar%%2frun%%2fslapd-%s.socket\n" %
|
||||
installutils.realm_to_serverid(options.realm_name))
|
||||
if options.setup_ca:
|
||||
fd.write("enable_ra=True\n")
|
||||
fd.write("ra_plugin=dogtag\n")
|
||||
fd.write("dogtag_version=10\n")
|
||||
else:
|
||||
fd.write("enable_ra=False\n")
|
||||
fd.write("ra_plugin=none\n")
|
||||
fd.write("mode=production\n")
|
||||
fd.close()
|
||||
# pylint: enable=invalid-name, consider-using-with
|
||||
|
||||
# Must be readable for everyone
|
||||
os.chmod(target_fname, 0o644)
|
||||
|
||||
@@ -96,6 +96,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
subject_base:
|
||||
description:
|
||||
The certificate subject base (default O=<realm-name>).
|
||||
@@ -113,6 +114,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
domainlevel:
|
||||
description: The domain level
|
||||
type: int
|
||||
|
||||
@@ -54,6 +54,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
domain:
|
||||
description: Primary DNS domain of the IPA deployment
|
||||
type: str
|
||||
@@ -182,6 +183,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_reverse:
|
||||
description: Do not create new reverse DNS zone
|
||||
type: bool
|
||||
@@ -305,6 +307,12 @@ def main():
|
||||
options.dirsrv_cert_files = ansible_module.params.get('dirsrv_cert_files')
|
||||
options._dirsrv_pkcs12_info = ansible_module.params.get(
|
||||
'_dirsrv_pkcs12_info')
|
||||
# hsm
|
||||
if hasattr(ca, "hsm_version"):
|
||||
options.token_name = None
|
||||
options.token_library_path = None
|
||||
options.token_password = None
|
||||
options.token_password_file = None
|
||||
# certificate system
|
||||
options.external_ca = ansible_module.params.get('external_ca')
|
||||
options.external_ca_type = ansible_module.params.get('external_ca_type')
|
||||
@@ -354,7 +362,7 @@ def main():
|
||||
options.no_hbac_allow, options._dirsrv_pkcs12_info,
|
||||
options.no_pkinit)
|
||||
|
||||
# setup CA ##############################################################
|
||||
# setup custodia ########################################################
|
||||
|
||||
if hasattr(custodiainstance, "get_custodia_instance"):
|
||||
if hasattr(custodiainstance.CustodiaModes, "FIRST_MASTER"):
|
||||
@@ -362,9 +370,14 @@ def main():
|
||||
else:
|
||||
mode = custodiainstance.CustodiaModes.MASTER_PEER
|
||||
custodia = custodiainstance.get_custodia_instance(options, mode)
|
||||
custodia.set_output(ansible_log)
|
||||
with redirect_stdout(ansible_log):
|
||||
custodia.create_instance()
|
||||
else:
|
||||
custodia = custodiainstance.CustodiaInstance(options.host_name,
|
||||
options.realm_name)
|
||||
custodia.set_output(ansible_log)
|
||||
with redirect_stdout(ansible_log):
|
||||
custodia.create_instance()
|
||||
|
||||
# setup CA ##############################################################
|
||||
|
||||
if options.setup_ca:
|
||||
if not options.external_cert_files and options.external_ca:
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Authors:
|
||||
# Thomas Woerner <twoerner@redhat.com>
|
||||
#
|
||||
# Based on ipa-client-install code
|
||||
#
|
||||
# Copyright (C) 2017-2022 Red Hat
|
||||
# see file 'COPYING' for use and warranty information
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
ANSIBLE_METADATA = {
|
||||
'metadata_version': '1.0',
|
||||
'supported_by': 'community',
|
||||
'status': ['preview'],
|
||||
}
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ipaserver_setup_custodia
|
||||
short_description: Setup custodia
|
||||
description: Setup custodia
|
||||
options:
|
||||
realm:
|
||||
description: Kerberos realm name of the IPA deployment
|
||||
type: str
|
||||
required: yes
|
||||
hostname:
|
||||
description: Fully qualified name of this host
|
||||
type: str
|
||||
required: no
|
||||
setup_ca:
|
||||
description: Configure a dogtag CA
|
||||
type: bool
|
||||
default: no
|
||||
required: no
|
||||
author:
|
||||
- Thomas Woerner (@t-woerner)
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.ansible_ipa_server import (
|
||||
check_imports, setup_logging, AnsibleModuleLog, options,
|
||||
api_Backend_ldap2,
|
||||
custodiainstance, redirect_stdout
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
ansible_module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
# basic
|
||||
realm=dict(required=True, type='str'),
|
||||
hostname=dict(required=False, type='str'),
|
||||
setup_ca=dict(required=False, type='bool', default=False),
|
||||
),
|
||||
)
|
||||
|
||||
ansible_module._ansible_debug = True
|
||||
check_imports(ansible_module)
|
||||
setup_logging()
|
||||
ansible_log = AnsibleModuleLog(ansible_module)
|
||||
|
||||
# set values ############################################################
|
||||
|
||||
options.realm_name = ansible_module.params.get('realm')
|
||||
options.host_name = ansible_module.params.get('hostname')
|
||||
options.setup_ca = ansible_module.params.get('setup_ca')
|
||||
options.promote = False
|
||||
|
||||
# init ##################################################################
|
||||
|
||||
api_Backend_ldap2(options.host_name, options.setup_ca, connect=True)
|
||||
|
||||
# setup custodia ########################################################
|
||||
|
||||
if hasattr(custodiainstance, "get_custodia_instance"):
|
||||
if hasattr(custodiainstance.CustodiaModes, "FIRST_MASTER"):
|
||||
mode = custodiainstance.CustodiaModes.FIRST_MASTER
|
||||
else:
|
||||
mode = custodiainstance.CustodiaModes.MASTER_PEER
|
||||
custodia = custodiainstance.get_custodia_instance(options, mode)
|
||||
else:
|
||||
custodia = custodiainstance.CustodiaInstance(options.host_name,
|
||||
options.realm_name)
|
||||
custodia.set_output(ansible_log)
|
||||
with redirect_stdout(ansible_log):
|
||||
custodia.create_instance()
|
||||
|
||||
# done ##################################################################
|
||||
|
||||
ansible_module.exit_json(changed=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -42,6 +42,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
domain:
|
||||
description: Primary DNS domain of the IPA deployment
|
||||
type: str
|
||||
|
||||
@@ -87,6 +87,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
_dirsrv_pkcs12_info:
|
||||
description: The installer _dirsrv_pkcs12_info setting
|
||||
type: list
|
||||
@@ -99,6 +100,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
subject_base:
|
||||
description:
|
||||
The certificate subject base (default O=<realm-name>).
|
||||
|
||||
@@ -66,17 +66,20 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
reverse_zones:
|
||||
description: The reverse DNS zones to use
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
http_cert_files:
|
||||
description:
|
||||
File containing the Apache Server SSL certificate and private key
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
setup_adtrust:
|
||||
description: Configure AD trust capability
|
||||
type: bool
|
||||
@@ -124,6 +127,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
subject_base:
|
||||
description:
|
||||
The certificate subject base (default O=<realm-name>).
|
||||
@@ -166,6 +170,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_reverse:
|
||||
description: Do not create new reverse DNS zone
|
||||
type: bool
|
||||
|
||||
@@ -74,7 +74,7 @@ RETURN = '''
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.ansible_ipa_server import (
|
||||
check_imports, AnsibleModuleLog, setup_logging, options,
|
||||
api_Backend_ldap2, redirect_stdout, api, custodiainstance, kra
|
||||
api_Backend_ldap2, redirect_stdout, api, custodiainstance, kra, ca
|
||||
)
|
||||
|
||||
|
||||
@@ -106,6 +106,12 @@ def main():
|
||||
options.pki_config_override = ansible_module.params.get(
|
||||
'pki_config_override')
|
||||
options.promote = False # first master, no promotion
|
||||
# hsm
|
||||
if hasattr(ca, "hsm_version"):
|
||||
options.token_name = None
|
||||
options.token_library_path = None
|
||||
options.token_password = None
|
||||
options.token_password_file = None
|
||||
|
||||
# init ##########################################################
|
||||
|
||||
|
||||
@@ -66,11 +66,13 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
reverse_zones:
|
||||
description: The reverse DNS zones to use
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
setup_adtrust:
|
||||
description: Configure AD trust capability
|
||||
type: bool
|
||||
@@ -113,6 +115,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
subject_base:
|
||||
description:
|
||||
The certificate subject base (default O=<realm-name>).
|
||||
|
||||
@@ -73,6 +73,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_host_dns:
|
||||
description: Do not use DNS for hostname lookup during installation
|
||||
type: bool
|
||||
@@ -223,6 +224,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_reverse:
|
||||
description: Do not create new reverse DNS zone
|
||||
type: bool
|
||||
@@ -242,6 +244,7 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
required: no
|
||||
default: []
|
||||
no_forwarders:
|
||||
description: Do not add any DNS forwarders, use root servers instead
|
||||
type: bool
|
||||
@@ -1171,7 +1174,7 @@ def main():
|
||||
changed=False,
|
||||
ipa_python_version=IPA_PYTHON_VERSION,
|
||||
# basic
|
||||
domain=options.domain_name,
|
||||
domain=domain_name,
|
||||
realm=realm_name,
|
||||
hostname=host_name,
|
||||
_hostname_overridden=bool(options.host_name),
|
||||
|
||||
@@ -6,7 +6,7 @@ galaxy_info:
|
||||
description: A role to setup an iPA domain server
|
||||
company: Red Hat, Inc
|
||||
license: GPLv3
|
||||
min_ansible_version: "2.13"
|
||||
min_ansible_version: "2.15"
|
||||
platforms:
|
||||
- name: Fedora
|
||||
versions:
|
||||
|
||||
@@ -44,7 +44,7 @@ __all__ = ["IPAChangeConf", "certmonger", "sysrestore", "root_logger",
|
||||
"check_available_memory", "getargspec", "get_min_idstart",
|
||||
"paths", "api", "ipautil", "adtrust_imported", "NUM_VERSION",
|
||||
"time_service", "kra_imported", "dsinstance", "IPA_PYTHON_VERSION",
|
||||
"NUM_VERSION", "SerialNumber"]
|
||||
"NUM_VERSION", "SerialNumber", "realm_to_ldapi_uri"]
|
||||
|
||||
import sys
|
||||
import logging
|
||||
@@ -121,6 +121,10 @@ try:
|
||||
)
|
||||
from ipapython.dnsutil import check_zone_overlap
|
||||
from ipapython.dn import DN
|
||||
try:
|
||||
from ipapython.ipaldap import realm_to_ldapi_uri
|
||||
except ImportError:
|
||||
realm_to_ldapi_uri = None
|
||||
try:
|
||||
from ipaclient.install import timeconf
|
||||
from ipaclient.install.client import sync_time
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user