From b4119cab5b52a45b49b08c155be622ef15a73972 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 5 Dec 2024 17:06:01 +0100 Subject: [PATCH] Extending Ansible role 389ds-config-plugins --- .../tasks/attr-uniq-entry-add.yaml | 51 +++++++++++++++++++ .../tasks/attr-uniq-entry.yaml | 5 +- 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 roles/389ds-config-plugins/tasks/attr-uniq-entry-add.yaml diff --git a/roles/389ds-config-plugins/tasks/attr-uniq-entry-add.yaml b/roles/389ds-config-plugins/tasks/attr-uniq-entry-add.yaml new file mode 100644 index 0000000..5d29ec2 --- /dev/null +++ b/roles/389ds-config-plugins/tasks/attr-uniq-entry-add.yaml @@ -0,0 +1,51 @@ +--- + +- name: "Adding attr-uniq entry." + debug: + var: entry_name + verbosity: 0 + +- name: "Start defining command for adding an attr-uniq entry." + set_fact: + entry_add_cmd: "dsconf {{ slapd_instance | quote }} plugin attr-uniq add" + +- name: "Add enabled to entry_add_cmd." + set_fact: + entry_add_cmd: "{{ entry_add_cmd }} --enabled {{ entry_data['enabled'] | bool | default(true) | bool_to_on_off }}" + +- name: "Adding attribute name to entry_add_cmd." + set_fact: + entry_add_cmd: "{{ entry_add_cmd }} --attr-name {{ attr_name | quote }}" + +- name: "Adding subtrees to entry_add_cmd." + set_fact: + entry_add_cmd: "{{ entry_add_cmd }} --subtree {{ entry_data['subtrees'] | map('quote') | join(' ') }}" + when: "'subtrees' in entry_data and entry_data['subtrees'] | length > 0" + +- name: "Adding across_all_subtrees to entry_add_cmd." + set_fact: + entry_add_cmd: "{{ entry_add_cmd }} --across-all-subtrees {{ entry_data['across_all_subtrees'] | default(true) | bool_to_on_off }}" + +- name: "Adding top_entry_oc to entry_add_cmd." + set_fact: + entry_add_cmd: "{{ entry_add_cmd }} --top-entry-oc {{ entry_data['top_entry_oc'] | quote }}" + when: "'top_entry_oc' in entry_data and entry_data['top_entry_oc'] is defined and entry_data['top_entry_oc'] != None and entry_data['top_entry_oc'] | length > 0" + +- name: "Adding subtree_entries_oc to entry_add_cmd." + set_fact: + entry_add_cmd: "{{ entry_add_cmd }} --subtree-entries-oc {{ entry_data['subtree_entries_oc'] | quote }}" + when: "'subtree_entries_oc' in entry_data and entry_data['subtree_entries_oc'] is defined and entry_data['subtree_entries_oc'] != None and entry_data['subtree_entries_oc'] | length > 0" + +- name: "Adding entry name to entry_add_cmd." + set_fact: + entry_add_cmd: "{{ entry_add_cmd }} {{ entry_name | quote }}." + +- name: "Show command for adding an attr-uniq entry." + debug: + var: entry_add_cmd + verbosity: 0 + +- name: "Finally adding attr-uniq entry." + ansible.builtin.shell: "{{ entry_add_cmd }}" + +# vim: filetype=yaml diff --git a/roles/389ds-config-plugins/tasks/attr-uniq-entry.yaml b/roles/389ds-config-plugins/tasks/attr-uniq-entry.yaml index a9458ca..b345626 100644 --- a/roles/389ds-config-plugins/tasks/attr-uniq-entry.yaml +++ b/roles/389ds-config-plugins/tasks/attr-uniq-entry.yaml @@ -65,8 +65,9 @@ block: - name: 'Add attr-uniq entry.' - debug: - msg: "Adding attr-uniq entry {{ entry_name | quote }}." + include_tasks: "attr-uniq-entry-add.yaml" + # vars: + # attr_name: "{{ attr_name }}" when: entry_name_lc not in cur_attr_uniq_entries_lc - name: 'Set attr-uniq entry.' -- 2.39.5