Compare commits

...

17 Commits

Author SHA1 Message Date
Thomas Woerner
25f7eb93f5 Merge pull request #569 from rjeffman/docs_ipaserver_role
Fix display of variables in ipaserver role README.
2021-07-08 22:44:14 +02:00
Thomas Woerner
9289473d93 Merge pull request #577 from rjeffman/fix_ignore_errors
Remove ignore_errors from pwpolicy tests.
2021-07-08 22:39:43 +02:00
Thomas Woerner
8037ace869 Merge pull request #581 from rjeffman/sudorule_fix_documentation
ipasudorule: Fix documentation attribute.
2021-07-08 22:13:50 +02:00
Rafael Guterres Jeffman
041dd761ff Merge pull request #590 from t-woerner/automember_result_failed_misuse
automember: Fix result["failed"] issues with conditions
2021-07-08 16:59:26 -03:00
Thomas Woerner
032c41f89e automember: Fix result["failed"] issues with conditions
result["failed"] is used only for INCLUDE_RE, EXCLUDE_RE if entries could
not be added that are already there and it entries could not be removed
that are not there.

All other issues like invalid attributes etc. are handled as exceptions.
Therefore the error section is not here as in other modules.

Fixes RHBZ#1979626
2021-07-08 21:41:09 +02:00
Rafael Guterres Jeffman
690c827208 ipasudorule: Fix documentation attribute.
Change, in the module documentation, the attribute named 'usergroup'
to 'group', as it is used in the code.
2021-07-08 14:13:16 -03:00
Rafael Guterres Jeffman
35a381b17d tests: Remove ignore_errors from pwpolicy tests.
Instead of ignoring errors it is better that we specific evaluate
errors provided by negative tests. This patche removes the an
occurrence of 'ignore_errors: true' in ansible-freeipa tests.
2021-07-08 14:05:08 -03:00
Rafael Guterres Jeffman
32f4e08397 Merge pull request #584 from t-woerner/fix_automember_action_name
automember: Fix action to be automember or member, not service
2021-07-08 10:07:01 -03:00
Rafael Guterres Jeffman
5302dda05a Merge pull request #583 from t-woerner/fix_automember_invalid_in_exclusive_parameters
automember: Fail on wrong in/ex/clusive parameter names
2021-07-08 10:06:41 -03:00
Thomas Woerner
2a660e7365 automember: Fail on wrong in/ex/clusive parameter names
The parameters in the inclusive and exclusive dicts are not defined and
also not checked. Therefore it is possible to have parameters in the
dicts that are not used.

The dicts for the inclusive and exclusive parameters are now defined and
also added to the description.
2021-07-06 14:09:57 +02:00
Thomas Woerner
fadb62dc81 automember: Fix action to be automember or member, not service
The action is service and member for the module, but it needs to be the
module name and member.
2021-07-06 14:09:20 +02:00
Rafael Guterres Jeffman
c75b0292a1 Merge pull request #574 from t-woerner/galaxy_fix_requirements
galaxy.yml: Drop empty dependencies
2021-06-16 08:38:57 -03:00
Thomas Woerner
9f8cafffc4 galaxy.yml: Drop empty dependencies
Ansible 2.11 does not like to have empty dependencies. It will fail to
install the collection with "'NoneType' object has no attribute 'items'"
error. The empty dependencies have been removed.

The requirements for ansible in requirements.txt have been removed also.

Fixes #571 (error installing freeipa-ansible_freeipa-0.3.6.tar.gz)
2021-06-16 12:28:25 +02:00
Varun Mylaraiah
dad7818ba7 Merge pull request #570 from t-woerner/ipabackup_get_backup_dir_module
ipabackup: Use module to get IPA_BACKUP_DIR from ipaplatform
2021-06-09 15:40:43 +05:30
Thomas Woerner
db208bd6c1 ipabackup: Use module to get IPA_BACKUP_DIR from ipaplatform
Up to now a python snippet was used to get IPA_BACKUP_DIR from ipaplatform
but this was not working when ansible_facts was false due to not getting
ansible_python_interpreter set.

The module version is also working if gather_facts is turned off.
2021-06-09 11:07:58 +02:00
Rafael Guterres Jeffman
a42a2d4389 ipaserver: Fix display of ipaserver_forward_policy in README. 2021-06-04 17:36:39 -03:00
Rafael Guterres Jeffman
3882b7364b ipaserver: Better display or README 'choice' variables. 2021-06-04 17:35:40 -03:00
8 changed files with 127 additions and 40 deletions

View File

@@ -14,8 +14,6 @@ issues: "https://github.com/freeipa/ansible-freeipa/issues"
readme: "README.md"
license: "GPL-3.0-or-later"
dependencies:
tags:
- "system"
- "identity"

View File

@@ -66,15 +66,33 @@ options:
type: list
elements: dict
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:
description: List of dictionaries containing the attribute and expression.
type: list
elements: dict
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:
description: Work on service or member level
default: service
choices: ["member", "service"]
description: Work on automember or member level
default: automember
choices: ["member", "automember"]
state:
description: State to ensure
default: present
@@ -174,17 +192,27 @@ def main():
ipaadmin_principal=dict(type="str", default="admin"),
ipaadmin_password=dict(type="str", required=False, no_log=True),
inclusive=dict(type="list", aliases=[
"automemberinclusiveregex"], default=None),
inclusive=dict(type="list",
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=[
"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"],
default=None, required=True),
description=dict(type="str", default=None),
automember_type=dict(type='str', required=False,
choices=['group', 'hostgroup']),
action=dict(type="str", default="service",
choices=["member", "service"]),
action=dict(type="str", default="automember",
choices=["member", "automember"]),
state=dict(type="str", default="present",
choices=["present", "absent", "rebuild"]),
users=dict(type="list", default=None),
@@ -250,7 +278,7 @@ def main():
if state == 'present':
args = gen_args(description, automember_type)
if action == "service":
if action == "automember":
if res_find is not None:
if not compare_args_ipa(ansible_module,
args,
@@ -273,7 +301,8 @@ def main():
elif action == "member":
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_del = []
@@ -309,14 +338,15 @@ def main():
condition_args])
elif state == 'absent':
if action == "service":
if action == "automember":
if res_find is not None:
commands.append([name, 'automember_del',
{'type': to_text(automember_type)}])
elif action == "member":
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:
for _inclusive in transform_conditions(inclusive):
@@ -355,7 +385,6 @@ def main():
if ansible_module.check_mode:
ansible_module.exit_json(changed=len(commands) > 0, **exit_args)
errors = []
for name, command, args in commands:
try:
if name is None:
@@ -372,16 +401,13 @@ def main():
except Exception as ex:
ansible_module.fail_json(msg="%s: %s: %s" % (command, name,
str(ex)))
# Get all errors
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]:
errors.append("%s: %s %s: %s" % (
command, member_type, member, failure))
if len(errors) > 0:
ansible_module.fail_json(msg=", ".join(errors))
# result["failed"] is used only for INCLUDE_RE, EXCLUDE_RE
# if entries could not be added that are already there and
# it entries could not be removed that are not there.
# All other issues like invalid attributes etc. are handled
# as exceptions. Therefore the error section is not here as
# in other modules.
except Exception as e:
ansible_module.fail_json(msg=str(e))

View File

@@ -53,7 +53,7 @@ options:
required: false
choices: ["all", ""]
aliases: ["usercat"]
usergroup:
group:
description: List of user groups assigned to the sudo rule.
required: false
runasgroupcategory:

View File

@@ -1 +0,0 @@
ansible>=2.8.0

View 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()

View File

@@ -1,12 +1,8 @@
---
- name: Get IPA_BACKUP_DIR dir from ipaplatform
command: "{{ ansible_python_interpreter | default('/usr/bin/python') }}"
args:
stdin: |
from ipaplatform.paths import paths
print(paths.IPA_BACKUP_DIR)
register: result_ipaplatform_backup_dir
- name: Get IPA_BACKUP_DIR from ipaplatform
ipabackup_get_backup_dir:
register: result_ipabackup_get_backup_dir
- name: Set IPA backup dir
set_fact:
ipabackup_dir: "{{ result_ipaplatform_backup_dir.stdout_lines | first }}"
ipabackup_dir: "{{ result_ipabackup_get_backup_dir.backup_dir }}"

View File

@@ -260,12 +260,12 @@ Certificate system Variables
Variable | Description | Required
-------- | ----------- | --------
`ipaserver_external_ca` | Generate a CSR for the IPA CA certificate to be signed by an external CA. (bool, default: false) | no
`ipaserver_external_ca_type` | Type of the external CA. (choice: generic,ms-cs) | no
`ipaserver_external_ca_type` | Type of the external CA. (choice: generic, ms-cs) | no
`ipaserver_external_ca_profile` | Specify the certificate profile/template to use at the external CA. (string) | no
`ipaserver_external_cert_files` | Files containing the IPA CA certificates and the external CA certificate chains (list of string) | no
`ipaserver_subject_base` | The certificate subject base (default O=<realm-name>). RDNs are in LDAP order (most specific RDN first). (string) | no
`ipaserver_ca_subject` | The CA certificate subject DN (default CN=Certificate Authority,O=<realm-name>). RDNs are in LDAP order (most specific RDN first). (string) | no
`ipaserver_ca_signing_algorithm` | Signing algorithm of the IPA CA certificate. (choice: SHA1withRSA,SHA256withRSA,SHA512withRSA) | no
`ipaserver_ca_signing_algorithm` | Signing algorithm of the IPA CA certificate. (choice: SHA1withRSA, SHA256withRSA, SHA512withRSA) | no
DNS Variables
-------------
@@ -280,7 +280,7 @@ Variable | Description | Required
`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_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
AD trust Variables

View File

@@ -81,8 +81,7 @@
ipaadmin_password: SomeADMINpassword
state: absent
register: result
ignore_errors: True
failed_when: (result is defined and result) or result.failed
failed_when: not result.failed or "'global_policy' can not be made absent." not in result.msg
- name: Ensure absence of pwpolicies for group ops
ipapwpolicy: