mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-14 13:32:10 +00:00
Compare commits
19 Commits
v0.3.6
...
ipaautomem
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
daf4aafb27 | ||
|
|
f785e8ba23 | ||
|
|
25f7eb93f5 | ||
|
|
9289473d93 | ||
|
|
8037ace869 | ||
|
|
041dd761ff | ||
|
|
032c41f89e | ||
|
|
690c827208 | ||
|
|
35a381b17d | ||
|
|
32f4e08397 | ||
|
|
5302dda05a | ||
|
|
2a660e7365 | ||
|
|
fadb62dc81 | ||
|
|
c75b0292a1 | ||
|
|
9f8cafffc4 | ||
|
|
dad7818ba7 | ||
|
|
db208bd6c1 | ||
|
|
a42a2d4389 | ||
|
|
3882b7364b |
@@ -127,6 +127,7 @@ Variable | Description | Required
|
|||||||
`automember_type` | Grouping to which the rule applies. It can be one of `group`, `hostgroup`. | yes
|
`automember_type` | Grouping to which the rule applies. It can be one of `group`, `hostgroup`. | yes
|
||||||
`inclusive` | List of dictionaries in the format of `{'key': attribute, 'expression': inclusive_regex}` | no
|
`inclusive` | List of dictionaries in the format of `{'key': attribute, 'expression': inclusive_regex}` | no
|
||||||
`exclusive` | List of dictionaries in the format of `{'key': attribute, 'expression': exclusive_regex}` | no
|
`exclusive` | List of dictionaries in the format of `{'key': attribute, 'expression': exclusive_regex}` | no
|
||||||
|
`action` | Work on automember or member level. It can be one of `member` or `automember` and defaults to `automember`. | no
|
||||||
`state` | The state to ensure. It can be one of `present`, `absent`, default: `present`. | no
|
`state` | The state to ensure. It can be one of `present`, `absent`, default: `present`. | no
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ issues: "https://github.com/freeipa/ansible-freeipa/issues"
|
|||||||
readme: "README.md"
|
readme: "README.md"
|
||||||
license: "GPL-3.0-or-later"
|
license: "GPL-3.0-or-later"
|
||||||
|
|
||||||
dependencies:
|
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
- "system"
|
- "system"
|
||||||
- "identity"
|
- "identity"
|
||||||
|
|||||||
@@ -66,15 +66,33 @@ options:
|
|||||||
type: list
|
type: list
|
||||||
elements: dict
|
elements: dict
|
||||||
aliases: ["automemberexclusiveregex"]
|
aliases: ["automemberexclusiveregex"]
|
||||||
|
options:
|
||||||
|
key:
|
||||||
|
description: The attribute of the regex
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
expression:
|
||||||
|
description: The expression of the regex
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
inclusive:
|
inclusive:
|
||||||
description: List of dictionaries containing the attribute and expression.
|
description: List of dictionaries containing the attribute and expression.
|
||||||
type: list
|
type: list
|
||||||
elements: dict
|
elements: dict
|
||||||
aliases: ["automemberinclusiveregex"]
|
aliases: ["automemberinclusiveregex"]
|
||||||
|
options:
|
||||||
|
key:
|
||||||
|
description: The attribute of the regex
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
expression:
|
||||||
|
description: The expression of the regex
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
action:
|
action:
|
||||||
description: Work on service or member level
|
description: Work on automember or member level
|
||||||
default: service
|
default: automember
|
||||||
choices: ["member", "service"]
|
choices: ["member", "automember"]
|
||||||
state:
|
state:
|
||||||
description: State to ensure
|
description: State to ensure
|
||||||
default: present
|
default: present
|
||||||
@@ -174,17 +192,27 @@ def main():
|
|||||||
ipaadmin_principal=dict(type="str", default="admin"),
|
ipaadmin_principal=dict(type="str", default="admin"),
|
||||||
ipaadmin_password=dict(type="str", required=False, no_log=True),
|
ipaadmin_password=dict(type="str", required=False, no_log=True),
|
||||||
|
|
||||||
inclusive=dict(type="list", aliases=[
|
inclusive=dict(type="list",
|
||||||
"automemberinclusiveregex"], default=None),
|
aliases=["automemberinclusiveregex"], default=None,
|
||||||
|
options=dict(
|
||||||
|
key=dict(type="str", required=True),
|
||||||
|
expression=dict(type="str", required=True)
|
||||||
|
),
|
||||||
|
elements="dict", required=False),
|
||||||
exclusive=dict(type="list", aliases=[
|
exclusive=dict(type="list", aliases=[
|
||||||
"automemberexclusiveregex"], default=None),
|
"automemberexclusiveregex"], default=None,
|
||||||
|
options=dict(
|
||||||
|
key=dict(type="str", required=True),
|
||||||
|
expression=dict(type="str", required=True)
|
||||||
|
),
|
||||||
|
elements="dict", required=False),
|
||||||
name=dict(type="list", aliases=["cn"],
|
name=dict(type="list", aliases=["cn"],
|
||||||
default=None, required=True),
|
default=None, required=True),
|
||||||
description=dict(type="str", default=None),
|
description=dict(type="str", default=None),
|
||||||
automember_type=dict(type='str', required=False,
|
automember_type=dict(type='str', required=False,
|
||||||
choices=['group', 'hostgroup']),
|
choices=['group', 'hostgroup']),
|
||||||
action=dict(type="str", default="service",
|
action=dict(type="str", default="automember",
|
||||||
choices=["member", "service"]),
|
choices=["member", "automember"]),
|
||||||
state=dict(type="str", default="present",
|
state=dict(type="str", default="present",
|
||||||
choices=["present", "absent", "rebuild"]),
|
choices=["present", "absent", "rebuild"]),
|
||||||
users=dict(type="list", default=None),
|
users=dict(type="list", default=None),
|
||||||
@@ -250,7 +278,7 @@ def main():
|
|||||||
if state == 'present':
|
if state == 'present':
|
||||||
args = gen_args(description, automember_type)
|
args = gen_args(description, automember_type)
|
||||||
|
|
||||||
if action == "service":
|
if action == "automember":
|
||||||
if res_find is not None:
|
if res_find is not None:
|
||||||
if not compare_args_ipa(ansible_module,
|
if not compare_args_ipa(ansible_module,
|
||||||
args,
|
args,
|
||||||
@@ -273,7 +301,8 @@ def main():
|
|||||||
|
|
||||||
elif action == "member":
|
elif action == "member":
|
||||||
if res_find is None:
|
if res_find is None:
|
||||||
ansible_module.fail_json(msg="No service '%s'" % name)
|
ansible_module.fail_json(
|
||||||
|
msg="No automember '%s'" % name)
|
||||||
|
|
||||||
inclusive_add = transform_conditions(inclusive or [])
|
inclusive_add = transform_conditions(inclusive or [])
|
||||||
inclusive_del = []
|
inclusive_del = []
|
||||||
@@ -309,14 +338,15 @@ def main():
|
|||||||
condition_args])
|
condition_args])
|
||||||
|
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
if action == "service":
|
if action == "automember":
|
||||||
if res_find is not None:
|
if res_find is not None:
|
||||||
commands.append([name, 'automember_del',
|
commands.append([name, 'automember_del',
|
||||||
{'type': to_text(automember_type)}])
|
{'type': to_text(automember_type)}])
|
||||||
|
|
||||||
elif action == "member":
|
elif action == "member":
|
||||||
if res_find is None:
|
if res_find is None:
|
||||||
ansible_module.fail_json(msg="No service '%s'" % name)
|
ansible_module.fail_json(
|
||||||
|
msg="No automember '%s'" % name)
|
||||||
|
|
||||||
if inclusive is not None:
|
if inclusive is not None:
|
||||||
for _inclusive in transform_conditions(inclusive):
|
for _inclusive in transform_conditions(inclusive):
|
||||||
@@ -355,7 +385,6 @@ def main():
|
|||||||
if ansible_module.check_mode:
|
if ansible_module.check_mode:
|
||||||
ansible_module.exit_json(changed=len(commands) > 0, **exit_args)
|
ansible_module.exit_json(changed=len(commands) > 0, **exit_args)
|
||||||
|
|
||||||
errors = []
|
|
||||||
for name, command, args in commands:
|
for name, command, args in commands:
|
||||||
try:
|
try:
|
||||||
if name is None:
|
if name is None:
|
||||||
@@ -372,16 +401,13 @@ def main():
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
ansible_module.fail_json(msg="%s: %s: %s" % (command, name,
|
ansible_module.fail_json(msg="%s: %s: %s" % (command, name,
|
||||||
str(ex)))
|
str(ex)))
|
||||||
# Get all errors
|
|
||||||
if "failed" in result and len(result["failed"]) > 0:
|
# result["failed"] is used only for INCLUDE_RE, EXCLUDE_RE
|
||||||
for item in result["failed"]:
|
# if entries could not be added that are already there and
|
||||||
failed_item = result["failed"][item]
|
# it entries could not be removed that are not there.
|
||||||
for member_type in failed_item:
|
# All other issues like invalid attributes etc. are handled
|
||||||
for member, failure in failed_item[member_type]:
|
# as exceptions. Therefore the error section is not here as
|
||||||
errors.append("%s: %s %s: %s" % (
|
# in other modules.
|
||||||
command, member_type, member, failure))
|
|
||||||
if len(errors) > 0:
|
|
||||||
ansible_module.fail_json(msg=", ".join(errors))
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
ansible_module.fail_json(msg=str(e))
|
ansible_module.fail_json(msg=str(e))
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ options:
|
|||||||
required: false
|
required: false
|
||||||
choices: ["all", ""]
|
choices: ["all", ""]
|
||||||
aliases: ["usercat"]
|
aliases: ["usercat"]
|
||||||
usergroup:
|
group:
|
||||||
description: List of user groups assigned to the sudo rule.
|
description: List of user groups assigned to the sudo rule.
|
||||||
required: false
|
required: false
|
||||||
runasgroupcategory:
|
runasgroupcategory:
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
ansible>=2.8.0
|
|
||||||
|
|||||||
69
roles/ipabackup/library/ipabackup_get_backup_dir.py
Normal file
69
roles/ipabackup/library/ipabackup_get_backup_dir.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Authors:
|
||||||
|
# Thomas Woerner <twoerner@redhat.com>
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 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/>.
|
||||||
|
|
||||||
|
ANSIBLE_METADATA = {
|
||||||
|
'metadata_version': '1.0',
|
||||||
|
'supported_by': 'community',
|
||||||
|
'status': ['preview'],
|
||||||
|
}
|
||||||
|
|
||||||
|
DOCUMENTATION = '''
|
||||||
|
---
|
||||||
|
module: ipabackup_get_backup_dir
|
||||||
|
short description:
|
||||||
|
Get IPA_BACKUP_DIR from ipaplatform
|
||||||
|
description:
|
||||||
|
Get IPA_BACKUP_DIR from ipaplatform
|
||||||
|
options:
|
||||||
|
author:
|
||||||
|
- Thomas Woerner
|
||||||
|
'''
|
||||||
|
|
||||||
|
EXAMPLES = '''
|
||||||
|
# Get IPA_BACKUP_DIR from ipaplatform
|
||||||
|
- name: ipabackup_get_backup_dir:
|
||||||
|
register result
|
||||||
|
'''
|
||||||
|
|
||||||
|
RETURN = '''
|
||||||
|
backup_dir:
|
||||||
|
description: IPA_BACKUP_DIR from ipaplatform
|
||||||
|
returned: always
|
||||||
|
type: str
|
||||||
|
'''
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ipaplatform.paths import paths
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=dict(),
|
||||||
|
supports_check_mode=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
module.exit_json(changed=False,
|
||||||
|
backup_dir=paths.IPA_BACKUP_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
---
|
---
|
||||||
- name: Get IPA_BACKUP_DIR dir from ipaplatform
|
- name: Get IPA_BACKUP_DIR from ipaplatform
|
||||||
command: "{{ ansible_python_interpreter | default('/usr/bin/python') }}"
|
ipabackup_get_backup_dir:
|
||||||
args:
|
register: result_ipabackup_get_backup_dir
|
||||||
stdin: |
|
|
||||||
from ipaplatform.paths import paths
|
|
||||||
print(paths.IPA_BACKUP_DIR)
|
|
||||||
register: result_ipaplatform_backup_dir
|
|
||||||
|
|
||||||
- name: Set IPA backup dir
|
- name: Set IPA backup dir
|
||||||
set_fact:
|
set_fact:
|
||||||
ipabackup_dir: "{{ result_ipaplatform_backup_dir.stdout_lines | first }}"
|
ipabackup_dir: "{{ result_ipabackup_get_backup_dir.backup_dir }}"
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ Variable | Description | Required
|
|||||||
`ipaserver_forwarders` | Add DNS forwarders to the DNS configuration. (list of strings) | no
|
`ipaserver_forwarders` | Add DNS forwarders to the DNS configuration. (list of strings) | no
|
||||||
`ipaserver_no_forwarders` | Do not add any DNS forwarders. Root DNS servers will be used instead. (bool, default: false) | no
|
`ipaserver_no_forwarders` | Do not add any DNS forwarders. Root DNS servers will be used instead. (bool, default: false) | no
|
||||||
`ipaserver_auto_forwarders` | Add DNS forwarders configured in /etc/resolv.conf to the list of forwarders used by IPA DNS. (bool, default: false) | no
|
`ipaserver_auto_forwarders` | Add DNS forwarders configured in /etc/resolv.conf to the list of forwarders used by IPA DNS. (bool, default: false) | no
|
||||||
`ipaserver_forward_policy` | DNS forwarding policy for global forwarders specified using other options. (choice: first|only) | no
|
`ipaserver_forward_policy` | DNS forwarding policy for global forwarders specified using other options. (choice: first, only) | no
|
||||||
`ipaserver_no_dnssec_validation` | Disable DNSSEC validation on this server. (bool, default: false) | no
|
`ipaserver_no_dnssec_validation` | Disable DNSSEC validation on this server. (bool, default: false) | no
|
||||||
|
|
||||||
AD trust Variables
|
AD trust Variables
|
||||||
|
|||||||
@@ -81,8 +81,7 @@
|
|||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: True
|
failed_when: not result.failed or "'global_policy' can not be made absent." not in result.msg
|
||||||
failed_when: (result is defined and result) or result.failed
|
|
||||||
|
|
||||||
- name: Ensure absence of pwpolicies for group ops
|
- name: Ensure absence of pwpolicies for group ops
|
||||||
ipapwpolicy:
|
ipapwpolicy:
|
||||||
|
|||||||
Reference in New Issue
Block a user