---
- name: 'Create LDAP Authentication Source'
  theforeman.foreman.auth_source_ldap:
    username: "{{ foreman_username | default(omit) }}"
    password: "{{ foreman_password | default(omit) }}"
    server_url: "{{ foreman_server_url | default(omit) }}"
    validate_certs: "{{ foreman_validate_certs | default(omit) }}"
    organizations: "{{ item.organizations | default(omit) }}"
    locations: "{{ item.locations | default(omit) }}"
    name: "{{ item.name }}"
    account: "{{ item.account | default(omit) }}"
    account_password: "{{ item.account_password | default(omit) }}"
    base_dn: "{{ item.base_dn | default(omit) }}"
    attr_login: "{{ item.attr_login | default(omit) }}"
    attr_firstname: "{{ item.attr_firstname | default(omit) }}"
    attr_lastname: "{{ item.attr_lastname | default(omit) }}"
    attr_mail: "{{ item.attr_mail | default(omit) }}"
    attr_photo: "{{ item.attr_photo | default(omit) }}"
    onthefly_register: "{{ item.onthefly_register | default(omit) }}"
    usergroup_sync: "{{ item.usergroup_sync | default(omit) }}"
    tls: "{{ item.tls | default(omit) }}"
    groups_base: "{{ item.groups_base | default(omit) }}"
    host: "{{ item.host | default(omit) }}"
    port: "{{ item.port | default(omit) }}"
    server_type: "{{ item.server_type | default(omit) }}"
    ldap_filter: "{{ item.ldap_filter | default(omit) }}"
    use_netgroups: "{{ item.use_netgroups | default(omit) }}"
    state: "{{ item.state | default('present') }}"
  loop: "{{ foreman_auth_sources_ldap }}"
  no_log: "{{ item.account_password is defined }}"
