Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for User Defined Active Directory Users and Groups #172

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions inventories/opensearch/group_vars/all/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ cluster_type: multi-node

# opensearch user info
os_user: opensearch
os_group: opensearch

os_dashboards_user: opensearch-dashboards
os_dashboards_group: opensearch-dashboards

# Number of days that certificates are valid
cert_valid_days: 730
Expand Down
17 changes: 11 additions & 6 deletions roles/linux/dashboards/tasks/dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@
dest: "/tmp/opensearch-dashboards.tar.gz"
register: download

- name: Dashboards Install | Create opensearch dashboard user
- name: Dashboards Install | Check if (( os_dashboards_user }} exists
ansible.builtin.command: "getent passwd {{ os_dashboards_user }}"
register: user_check
ignore_errors: true

- name: Dashboards Install | Create {{ os_dashboards_user }} user
ansible.builtin.user:
name: "{{ os_dashboards_user }}"
state: present
shell: /bin/false
create_home: true
home: "{{ os_dashboards_home }}"
when: download.changed or iac_enable
when: (download.changed or iac_enable) and user_check.rc !=0

- name: Dashboards Install | Create home directory
ansible.builtin.file:
path: "{{ os_dashboards_home }}"
state: directory
owner: "{{ os_dashboards_user }}"
group: "{{ os_dashboards_user }}"
group: "{{ os_dashboards_group }}"
when: download.changed or iac_enable

- name: Dashboards Install | Extract the tar file
Expand All @@ -32,22 +37,22 @@
src: opensearch_dashboards.yml
dest: "{{ os_conf_dir }}/opensearch_dashboards.yml"
owner: "{{ os_dashboards_user }}"
group: "{{ os_dashboards_user }}"
group: "{{ os_dashboards_group }}"
mode: 0644
backup: true

- name: Dashboards Install | Set the file ownerships
ansible.builtin.file:
dest: "{{ os_dashboards_home }}"
owner: "{{ os_dashboards_user }}"
group: "{{ os_dashboards_user }}"
group: "{{ os_dashboards_group }}"
recurse: true

- name: Dashboards Install | Set the folder permission
ansible.builtin.file:
dest: "{{ os_conf_dir }}"
owner: "{{ os_dashboards_user }}"
group: "{{ os_dashboards_user }}"
group: "{{ os_dashboards_group }}"
mode: 0700

- name: Dashboards Install | create systemd service
Expand Down
25 changes: 20 additions & 5 deletions roles/linux/opensearch/tasks/opensearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,36 @@
dest: "/tmp/opensearch.tar.gz"
register: download

- name: OpenSearch Install | Create opensearch user
- name: Opensearch Install | Check if {{ os_user }} user exists
ansible.builtin.command: "getent passwd {{ os_user }}"
register: user_check
ignore_errors: true

- name: Opensearch Install | Create {{ os_user }} user
ansible.builtin.user:
name: "{{ os_user }}"
state: present
group: "{{ os_group }}"
shell: /bin/false
create_home: true
home: "{{ os_home }}"
when: download.changed or iac_enable
when: (download.changed or iac_enable) and user_check.rc != 0

- name: OpenSearch Install | Create {{ os_user }}
ansible.builtin.user:
name: "{{ os_user }}"
state: present
shell: /bin/false
create_home: true
home: "{{ os_home }}"
when: (download.changed or iac_enable) and user_check.rc != 0

- name: OpenSearch Install | Create home directory
ansible.builtin.file:
path: "{{ os_home }}"
state: directory
owner: "{{ os_user }}"
group: "{{ os_user }}"
group: "{{ os_group }}"
when: download.changed or iac_enable

- name: OpenSearch Install | Extract the tar file
Expand All @@ -36,15 +51,15 @@
create: true
marker: "## {mark} opensearch main configuration ##"
owner: "{{ os_user }}"
group: "{{ os_user }}"
group: "{{ os_group }}"
mode: 0600

- name: OpenSearch Install | Copy jvm.options File for Instance
ansible.builtin.template:
src: jvm.options
dest: "{{ os_conf_dir }}/jvm.options"
owner: "{{ os_user }}"
group: "{{ os_user }}"
group: "{{ os_group }}"
mode: 0600
force: true

Expand Down
10 changes: 5 additions & 5 deletions roles/linux/opensearch/tasks/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
ansible.builtin.file:
dest: "{{ os_sec_plugin_conf_path }}"
owner: "{{ os_user }}"
group: "{{ os_user }}"
group: "{{ os_group }}"
mode: 0700
state: directory
when: configuration.changed or iac_enable
Expand All @@ -161,7 +161,7 @@
dest: "{{ os_sec_plugin_conf_path }}/config.yml"
backup: true
owner: "{{ os_user }}"
group: "{{ os_user }}"
group: "{{ os_group }}"
mode: 0600
force: true
when: auth_type == 'oidc' or copy_custom_security_configs
Expand All @@ -174,14 +174,14 @@
ansible.builtin.file:
dest: "{{ os_home }}"
owner: "{{ os_user }}"
group: "{{ os_user }}"
group: "{{ os_group }}"
recurse: true

- name: Security Plugin configuration | Set the folder permission
ansible.builtin.file:
dest: "{{ os_conf_dir }}"
owner: "{{ os_user }}"
group: "{{ os_user }}"
group: "{{ os_group }}"
mode: 0700

- name: Security Plugin configuration | Restart opensearch with security configuration
Expand Down Expand Up @@ -211,7 +211,7 @@
src: "{{ item }}"
dest: "{{ os_sec_plugin_conf_path }}/"
owner: "{{ os_user }}"
group: "{{ os_user }}"
group: "{{ os_group }}"
backup: true
mode: 0640
force: true
Expand Down
2 changes: 1 addition & 1 deletion roles/linux/opensearch/templates/opensearch.service
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PrivateTmp=true
WorkingDirectory={{ os_home }}

User={{ os_user }}
Group={{ os_user }}
Group={{ os_group }}

ExecStart={{ os_home }}/bin/opensearch -p {{ os_home }}/opensearch.pid -q

Expand Down