Init role for ds389
Change-Id: I0ea615e3e7ea0db11519051ae905a1bca77ce41a
diff --git a/tasks/Debian.yml b/tasks/Debian.yml
new file mode 100644
index 0000000..102db1b
--- /dev/null
+++ b/tasks/Debian.yml
@@ -0,0 +1,12 @@
+---
+# ds389 tasks/Debian.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+- name: Install 389-ds package
+ apt:
+ name:
+ - "389-ds"
+ state: "present"
+ update_cache: true
diff --git a/tasks/main.yml b/tasks/main.yml
new file mode 100644
index 0000000..cda8982
--- /dev/null
+++ b/tasks/main.yml
@@ -0,0 +1,36 @@
+---
+# ds389 tasks/main.yml
+#
+# SPDX-FileCopyrightText: © 2021 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+- name: include OS-specific tasks
+ include_tasks: "{{ ansible_os_family }}.yml"
+
+- name: Create a directory if it does not exist
+ file:
+ path: "{{ ds389_config_dir }}"
+ state: directory
+ mode: '0700'
+
+- name: Create configuration file for 389DS service
+ template:
+ src: "{{ item }}.j2"
+ dest: "{{ ds389_config_dir }}/{{ item }}"
+ owner: "root"
+ group: "root"
+ mode: "0400"
+ with_items:
+ - "instance.inf"
+
+- name: Get current instance status
+ command:
+ cmd: dsctl {{ ds389_instance_name }} status
+ register: dsctl_result
+ changed_when: false
+ failed_when: false
+
+- name: Run dscreate to init instance
+ command:
+ cmd: "dscreate from-file {{ ds389_config_dir }}/instance.inf"
+ when: dsctl_result.rc != 0