Skip to content
Snippets Groups Projects
  1. Jan 29, 2025
  2. Nov 15, 2024
    • Rafael Guterres Jeffman's avatar
      ansible_freeipa_module_utils: Add EntryFactory class · da775a21
      Rafael Guterres Jeffman authored
      This patch adds the class EntryFactory to the ansible-freeipa module
      utils. This class allows the handling of modules with multiple object
      entries as list of objects. When the multi-object parameter is not used,
      it creates a list of a single object, allowing for the same code idiom
      to be used.
      
      The entries created can be used both as objects, by acessing the values
      as properties, or as dictionaires, by accessing the elements as
      key-value pairs.
      da775a21
  3. Oct 11, 2024
    • Thomas Woerner's avatar
      ipauser: Use date string, not datetime object for expiration dates · 55ec25a7
      Thomas Woerner authored
      So far a datetime object was created for the expiration dates
      krbpasswordexpiration and krbprincipalexpiration. This resulted in also
      sending these objects to the API. With this change, the dates are
      converted into strings using the LDAP_GENERALIZED_TIME_FORMAT defined in
      ipalib.constants. This way only strings are used with the IPA API.
      
      A new function has been added to ansible_freeipa_module:
      
      - date_string: Convert datetime to gernalized time format string
      
      This fuction is used on the result of user_show to convert the
      expiration dates to the gernalized time format string.
      
      The existing function date_format in ansible_freeipa_module has been
      renamed to convert_date and fixed in the way that it also uses
      date_string to return a gernalized time format string and not a
      datetime object. This function was only used in the ipauser module so
      far.
      55ec25a7
  4. Jun 25, 2024
    • Thomas Woerner's avatar
      ansible_freeipa_module: Fix errors in batch mode · 39ba2257
      Thomas Woerner authored
      The error string returned by execute_ipa_commands in batch mode
      additionally contains the whole parameter list for the command. This is
      different to non batch mode execution and breaks tests that are checking
      the returned error message.
      
      A left over debug message also have been removed from the error
      processing.
      39ba2257
    • Thomas Woerner's avatar
      ansible_freeipa_module: New function convert_input_certificates · 84b5d33c
      Thomas Woerner authored
      Certificates given by ansible could have leading and trailing white
      space, but also multi line input is possible that also could have
      leading and training white space and newlines.
      
      New function:
      - convert_input_certificates(module, certs, state)
      84b5d33c
  5. May 22, 2024
    • Rafael Guterres Jeffman's avatar
    • Rafael Guterres Jeffman's avatar
      pylint: Ignore usage of 'unicode' before assignment · f53ca3ad
      Rafael Guterres Jeffman authored
      New versions of pylint ignore Python 2 functions and types, evaluating
      'unicode' as "undefined". ansible-freeipa will always define 'unicode'
      when running under Python 3, and it is always defined under Python 2.
      
      This patch fixes these false positives.
      f53ca3ad
    • Thomas Woerner's avatar
      IPAAnsibleModule: Add support for batch command in execute_ipa_commands · bcb6a682
      Thomas Woerner authored
      The method execute_ipa_commands has been extended to handle multi
      commands with the batch command.
      
      New constants for execute_ipa_commands debugging:
      
          DEBUG_COMMAND_ALL = 0b1111
          DEBUG_COMMAND_LIST = 0b0001
              Print the while command list
          DEBUG_COMMAND_COUNT = 0b0010
              Print the command number
          DEBUG_COMMAND_BATCH = 0b0100
              Print information about the batch slice size and currently executed
              batch slice
      
      New parameters have been added to execute_ipa_commands:
      
          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.
              Default: None (Keep all)
          debug: integer
              Enable debug output for the exection using DEBUG_COMMAND_*
      
      Batch mode can be enabled within the module with setting batch to True
      for execute_ipa_commands.
      
      Fixes: #1128 (batch command support)
      bcb6a682
  6. May 13, 2024
  7. Mar 27, 2024
  8. Dec 15, 2023
  9. Dec 08, 2023
    • Rafael Guterres Jeffman's avatar
      Rename parameter 'allow_empty_string' to 'allow_empty_list_item' · f4c9e287
      Rafael Guterres Jeffman authored
      The parameter 'allow_empty_string' in 'module_params_get' is used to
      allow an item in a list to be an empty string. The problem is that the
      naming is misleading, as it is checking a list item rather than a
      string.
      
      This patch rename the parameter to 'allow_empty_list_item' so that it
      more clearly refers to list itens instead of standalone strings, and do
      not collide with future parameters that may test for empty strings which
      are not part of lists.
      f4c9e287
  10. Dec 05, 2023
    • Thomas Woerner's avatar
      ipaidp: Fix validation and reset of parameters · ff084fbd
      Thomas Woerner authored
      The uri parameters auth_uri, dev_auth_uri, token_uri, userinfo_uri and
      keys_uri have not been validated before. Also the base_url was not
      normalized. The auth_uri, dev_auth_uri, token_uri and userinfo_uri need
      to be set for new entries, but might be empty or empty string for reset
      or updates.
      
      The ipaidpclientsecret needs to be decoded from binary string in
      find_idp result to not trigger no change ipd_mod calls.
      
      The code for validate_uri and base_url normalization has been copied
      from the ipaserver idp plugin.
      
      ansible_freeipa_module:
      urlparse from urllib.parse with a fallback to six.moves.urllib.parse is
      imported and also exported. urlparse is needed for validate_uri in ipaidp
      module.
      
      Resolves: RHEL-17954, RHEL-17955, RHEL-17957 and RHEL-17958
      ff084fbd
  11. Sep 27, 2023
    • Thomas Woerner's avatar
      New idp management module · f9ff4132
      Thomas Woerner authored
      There is a new idp management module placed in the plugins folder:
      
          plugins/modules/ipaidp.py
      
      The idp module allows to ensure presence or absence of external Identity
      Providers.
      
      Here is the documentation for the module:
      
          README-idp.md
      
      New idp example playbooks:
      
          playbooks/idp/idp-present.yml
          playbooks/idp/idp-absent.yml
      
      New tests for the module:
      
          tests/idp/test_idp.yml
          tests/idp/test_idp_client_context.yml
      f9ff4132
  12. Sep 14, 2023
  13. Jul 21, 2023
    • Thomas Woerner's avatar
      ansible_freeipa_module: Fix ipa_command_invalid_param_choices · d58b492f
      Thomas Woerner authored
      Fix ipa_command_invalid_param_choices for IPA 4.6 (RHEL-7)
      
      - krbprincipalauthind in host_add does not have choices defined
      - krbprincipalauthind in service_add does not have choices defined
      
      api.Command[command].params[name].cli_metavar returns "STR" and
      ast.literal_eval failes with a ValueError "malformed string".
      
      There is no way to verify that the given values are valid or not in
      this case. The check is done later on while applying the change
      with host_add, host_mod, service_add and service_mod.
      d58b492f
  14. Jul 19, 2023
  15. Jul 11, 2023
  16. Jun 07, 2023
    • Sam Morris's avatar
      New certificate management module. · 87e1edf5
      Sam Morris authored
      There is a new certificate management module placed in the plugins
      folder:
      
          plugins/modules/ipacert.py
      
      The certificate module allows to request, revoke, release and retrieve
      certificates for users, hosts and services.
      
      Here is the documentation for the module:
      
          README-cert.md
      
      New example playbooks have been added:
      
          playbooks/cert/cert-hold.yml
          playbooks/cert/cert-release.yml
          playbooks/cert/cert-request-host.yml
          playbooks/cert/cert-request-service.yml
          playbooks/cert/cert-request-user.yml
          playbooks/cert/cert-retrieve.yml
          playbooks/cert/cert-revoke.yml
      
      New tests for the module can be found at:
      
          tests/cert/test_cert_client_context.yml
          tests/cert/test_cert_host.yml
          tests/cert/test_cert_service.yml
          tests/cert/test_cert_user.yml
      
      The module has been co-authored by Sam Morris (@yrro) and Rafael
      Guterres Jeffman (@rjeffman).
      87e1edf5
  17. May 05, 2023
    • Thomas Woerner's avatar
      ansible_freeipa_module.py: Calm down ansible-test on print and sys.exit · a32fcb37
      Thomas Woerner authored
      The function exit_raw_json is a replacement for AnsibleModule.exit_json
      without flterting out values for no_log parameters.
      
      Ansible added checks for pylint to forbid print and also sys.exit and
      fails with ansible-bad-function. As the check is not known outside of
      ansible-test, the disable line needed also W0012:
      
          # pylint: disable=W0012,ansible-bad-function
      a32fcb37
  18. Jan 12, 2023
  19. Nov 30, 2022
    • Rafael Guterres Jeffman's avatar
      environment: Fix os.environ language setting. · 76aad719
      Rafael Guterres Jeffman authored
      A combination of ansible-freeipa modifications and a newer version of
      IPA has brought a regression regarding different OS localization.
      
      For properly setting environment to use "C" language, as required by
      ansible-freeipa, the setting must be executed before importing the
      module 'ipaserver.dcerpc', so setting environment language was moved
      closer to the 'import os' statement, so that it is always set, as soon
      as possible.
      
      Note that 'import os' should always be imported before any FreeIPA
      module.
      76aad719
  20. Nov 11, 2022
    • Rafael Guterres Jeffman's avatar
      pylint: Modify certificate loader function definition. · 10b3f461
      Rafael Guterres Jeffman authored
      This patch modifies the way that the certificate load function is
      defined, depending on the dependency version, so that the resulting
      identifier for the function is always set and static analysis tools,
      like linters don't complain about variables being used before being
      set.
      
      The same idiom is applied to both the ipaclient role and the plugins
      ansible_module_utils.
      10b3f461
  21. Sep 27, 2022
    • Thomas Woerner's avatar
      ansible_freeipa_module: Fix ansible-test fake execution test findings · 71f3f110
      Thomas Woerner authored
      All imports that are only available after installing IPA need to be in a
      try exception clause to be able to pass the fake execution test. The old
      workaround "if 'ansible.executor' in sys.modules:" is not working with
      this test anymore.
      
      If the imports can not be done, all used and needed attributes are
      defines with the value None.
      
      A check has been added to IPAAnsibleModule.__init__ to make sure that it
      fails if the imports have not been done successfully.
      71f3f110
  22. Sep 16, 2022
  23. Jul 08, 2022
    • Thomas Woerner's avatar
      ansible_freeipa_module: Use ipaplatform.tasks.parse_ipa_version · 12729fc2
      Thomas Woerner authored
      api_check_ipa_version was using packaging.version. IPA is using
      pkg_resources.parse_version in ipaplatform.tasks.parse_ipa_version.
      
      With this change tasks.parse_ipa_version from ipaplatform is used to
      have exactly the same version comparison that also IPA has.
      
      Additionally tasks is added to __all__.
      12729fc2
  24. Jul 06, 2022
    • Rafael Guterres Jeffman's avatar
      api_check_ipa_version: Fix version comparison for more than one digit · 87ff15a9
      Rafael Guterres Jeffman authored
      The fallback function used to compare IPA versions was spliting the
      version string into a tuple of strings, and the comparison of the tuple
      would fail if comparing a field with one digit aginst a two-digit one,
      for example, '8' with '10', as the string comparison would put '10'
      before the '8'.
      
      This patch forces the version fields to be converted to integers, so
      a numerical comparison will be performed. If a version string field
      cannot be converted to a number, than the string comparison will still
      be used.
      87ff15a9
    • Rafael Guterres Jeffman's avatar
      Fix handling of boolean values for FreeIPA 4.9.10+ · c8d5cb7e
      Rafael Guterres Jeffman authored
      FreeIPA 4.9.10+ and 4.10 use proper mapping for boolean values, and
      only searching for "TRUE" does not work anymore.
      
      This patch fix ipadnszone plugin and IPAParamMapping class handling
      of boolean values.
      c8d5cb7e
    • Thomas Woerner's avatar
      Provide own getargspec for roles and modules with Python 3.11 · 07b056ad
      Thomas Woerner authored
      Python 3.11 dropped compat inspect.getargspec. As the roles and modules
      need to support Python2 and Python3, the code for getargspec has been
      copied from Python 3.10 and is added as a fallback as soon as getargspec
      can not be imported from inspect. The copied getargspec is using
      getfullargspec internally.
      
      Fixes: #855 (Python's inspect.getargspec was removed in version 3.11)
      07b056ad
  25. Jun 20, 2022
  26. Jun 17, 2022
  27. Apr 26, 2022
    • Rafael Guterres Jeffman's avatar
      module_utils: Fix comparison of elements not in IPA object. · f2865efb
      Rafael Guterres Jeffman authored
      This change modifies the comparison of the retrieved IPA object and the
      provided arguments on ansible_freeipa_module.compare_args_ipa when the
      provider argument is an empty string.
      
      If an attribute is not available in 'ipa', its value is considered to be
      a list with an empty string (['']), possibly forcing the conversion of
      the 'args' attribute to a list for comparison. This allows, for example,
      the usage of empty strings which should compare as equals to inexistent
      attributes (None), as is done in IPA API.
      f2865efb
  28. Feb 24, 2022
    • Thomas Woerner's avatar
      module_params_get*: Fail on empty string in string list parameters · d05ad6b1
      Thomas Woerner authored
      So far it is possible to pass list parameters with empty strings to the
      modules. The use of empty strings in list does not make a lot of sense,
      though. The simple solution is to add a check to module_params_get for
      empty strings in returned lists.
      
      The option allow_empty_string can be set to True to allow an empty string
      in the list with a list len of 1. The option defaults to False. It is
      needed for some parameters the modules, like for example userauthtype in
      the user module. It is using "" to reset to the default value.
      
      module_params_get_lowercase has been changed to use module_params_get to
      have one place to add the check.
      
      Due to an issue in Ansible it is possible to use the empty string "" for
      lists with choices, even if the empty list is not part of the choices.
      Ansible issue https://github.com/ansible/ansible/issues/77108
      d05ad6b1
  29. Feb 17, 2022
    • Rafael Guterres Jeffman's avatar
      IPAAnsibleModule: Provide base configuration for delete_continue. · e88aaaf9
      Rafael Guterres Jeffman authored
      Allows the creation of IPAAnsibleModule objects with specific
      `ipa_arguments` which are defined in a dictionary of argumets in
      the base class.
      
      Every module using `delete_continue` should provide the proper behavior
      and the module must be instantiated with:
      
        ansible_module = IPAAnsibleModule(
            ...,
            ipa_arguments=["delete_continue"]
        )
      
      The plugin documentation must be extended with
      'ipamodule_arguments.delete_continue'.
      e88aaaf9
  30. Feb 14, 2022
    • Thomas Woerner's avatar
      servicedelegation: Do not fail for not existing members with state absent · 8010d19b
      Thomas Woerner authored
      Ensuring absence of members (services and targets) that do not exist may
      not fail as they are not members for servicedelegationtarget and
      servicedelegationrule.
      
      servicedelegation_normalize_principals in ansible_freeipa_module has
      been extended with a check_exists argument that defaults to False. state
      == "present" is now given as this argument to turn on the element exists
      check only if elements should be added.
      8010d19b
  31. Feb 03, 2022
    • Thomas Woerner's avatar
      ansible_freeipa_module: New function servicedelegation_normalize_principals · 1aca0c13
      Thomas Woerner authored
      This function will be used in servicedelegation target and rule modules
      to normalize principals given in the tasks. These can be service and host
      principals and also aliases.
      
      Note: The use of host principals requires IPA 4.9.0 or later. fail_json
      is called if the version is lower.
      
      servicedelegation_normalize_principals contains two embedded fuctions.
      One is normalize_principal_name that has been copied from
      ipaserver/plugins/servicedelegation.py, the other is the generic
      function _check_exists to be able to check if a host or service exists.
      1aca0c13
  32. Jan 13, 2022
    • Rafael Guterres Jeffman's avatar
      IPAAnsibleModule: cache IPA domain. · bde3eb82
      Rafael Guterres Jeffman authored
      Some attributes retrieved by the IPA API backend don't change, and are
      used more than once, in different places of the code. IPA API domain
      is one of these attributes.
      
      This patch adds a cache to the attribute, so there is only one request
      for the API, improving access time to the object and alowing multiple
      calls with no efficiency penalty.
      bde3eb82
  33. Dec 22, 2021
  34. Dec 14, 2021
  35. Nov 24, 2021
Loading