]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Extending Ansible role 389ds-config-plugins
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 5 Dec 2024 16:06:01 +0000 (17:06 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 5 Dec 2024 16:06:01 +0000 (17:06 +0100)
roles/389ds-config-plugins/tasks/attr-uniq-entry-add.yaml [new file with mode: 0644]
roles/389ds-config-plugins/tasks/attr-uniq-entry.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 (file)
index 0000000..5d29ec2
--- /dev/null
@@ -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
index a9458ca519b38c0bce93974cc32ae5a558e6f5ce..b3456267134d6f3b0129aa3599392c4cc012c737 100644 (file)
@@ -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.'