Skip to content

Commit

Permalink
Merge pull request #817 from splunk/develop
Browse files Browse the repository at this point in the history
Patch1 releases for 9.0.9, 9.1.4 and 9.2.1
  • Loading branch information
ruomeiy-splunk committed Apr 17, 2024
2 parents ec7b9c0 + 199cbb2 commit 0798330
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 22 deletions.
27 changes: 27 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
## Changelog

## Navigation
* [9.2.1-patch1](#921-patch1)
* [9.2.1](#921)
* [9.2.0.1](#9201)
* [9.2.0](#920)
* [9.1.4-patch1](#914-patch1)
* [9.1.4](#914)
* [9.1.3](#913)
* [9.1.2](#912)
* [9.1.1](#911)
* [9.1.0.2](#9102)
* [9.1.0.1](#9101)
* [9.0.9-patch1](#909-patch1)
* [9.0.9](#909)
* [9.0.8](#908)
* [9.0.7](#907)
Expand Down Expand Up @@ -87,6 +90,14 @@

---

## 9.2.1-patch1

#### Changes
* Check for UDS file instead of UDS flag
* Bugfixes

---

## 9.2.1

#### Changes
Expand All @@ -111,6 +122,14 @@

---

## 9.1.4-patch1

#### Changes
* Check for UDS file instead of UDS flag
* Bugfixes

---

## 9.1.4

#### Changes
Expand Down Expand Up @@ -159,6 +178,14 @@

---

## 9.0.9-patch1

#### Changes
* Check for UDS file instead of UDS flag
* Bugfixes

---

## 9.0.9

#### Changes
Expand Down
7 changes: 6 additions & 1 deletion roles/splunk_common/handlers/restart_splunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
state: restarted
when: splunk.enable_service and not ansible_system is match("Linux")

- name: Check if UDS file exists
stat:
path: "/opt/splunkforwarder/var/run/splunk/cli.socket"
register: uds_socket_exists

- name: "Wait for splunkd management port"
wait_for:
port: "{{ splunk.svc_port }}"
when: splunk.splunk_http_enabled|bool == true
when: not uds_socket_exists.stat.exists
17 changes: 0 additions & 17 deletions roles/splunk_common/tasks/configure_mgmt_port.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
---
- name: Set mgmt port
ini_file:
dest: "{{ splunk.home }}/etc/system/local/web.conf"
section: settings
option: "mgmtHostPort"
value: "0.0.0.0:{{ splunk.svc_port }}"
owner: "{{ splunk.user }}"
group: "{{ splunk.group }}"
when:
- "'svc_port' in splunk"
register: set_mgmt_port

- name: Configure to set Mgmt Mode as auto (Allows UDS)
ini_file:
dest: "{{ splunk.home }}/etc/system/local/server.conf"
Expand All @@ -30,8 +18,3 @@
owner: "{{ splunk.user }}"
group: "{{ splunk.group }}"
when: splunk.role == "splunk_universal_forwarder" and splunk.splunk_http_enabled|bool == true

# Restart only when Splunk is running and when any of the above have changed
- include_tasks: ../handlers/restart_splunk.yml
when: set_mgmt_port is changed

28 changes: 28 additions & 0 deletions roles/splunk_common/tasks/install_python_requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
- name: Check if requests_unixsocket exists
command: "pip list | grep 'requests-unixsocket'"
register: requests_unixsocket_check
ignore_errors: true

- name: Install and upgrade pip
pip:
name: pip
extra_args: --upgrade
executable: pip3
when: requests_unixsocket_check is failed

- name: Check if pip3 unixsocket exits
command: "pip3 list | grep 'requests-unixsocket'"
register: requests_unixsocket_check_py3
when: requests_unixsocket_check is failed
ignore_errors: true

- name: Install missing requests_unixsocket
ansible.builtin.pip:
name: "requests_unixsocket"
when: requests_unixsocket_check is succeeded and (requests_unixsocket_check.stdout | length == 0 or requests_unixsocket_check.stdout.find("requests-unixsocket") == -1)

- name: Install missing requests_unixsocket PY3
ansible.builtin.pip:
name: "requests_unixsocket"
when: requests_unixsocket_check_py3 is succeeded and (requests_unixsocket_check_py3.stdout | length == 0 or requests_unixsocket_check_py3.stdout.find("requests-unixsocket") == -1)
11 changes: 10 additions & 1 deletion roles/splunk_common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
- include_tasks: get_facts.yml

- include_tasks: install_python_requirements.yml

- include_tasks: change_splunk_directory_owner.yml
when:
- ansible_system is match("Linux")
Expand Down Expand Up @@ -74,6 +76,8 @@
- "'http_port' in splunk"
- splunk.http_port | int != 8000

- include_tasks: set_mgmt_port.yml

- include_tasks: set_root_endpoint.yml
when: "'root_endpoint' in splunk and splunk.root_endpoint"

Expand Down Expand Up @@ -122,8 +126,13 @@

- include_tasks: start_splunk.yml

- name: Check if UDS file exists
stat:
path: "/opt/splunkforwarder/var/run/splunk/cli.socket"
register: uds_socket_exists

- include_tasks: set_certificate_prefix.yml
when: splunk.splunk_http_enabled|bool == true
when: not uds_socket_exists.stat.exists

- include_tasks: clean_user_seed.yml

Expand Down
7 changes: 6 additions & 1 deletion roles/splunk_common/tasks/set_certificate_prefix.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---
- name: Check if UDS file exists
stat:
path: "/opt/splunkforwarder/var/run/splunk/cli.socket"
register: uds_socket_exists

- name: "Test basic https endpoint"
uri:
url: "https://127.0.0.1:{{ splunk.svc_port }}"
Expand All @@ -8,7 +13,7 @@
timeout: 10
use_proxy: no
register: ssl_enabled
when: splunk.splunk_http_enabled|bool == true
when: not uds_socket_exists.stat.exists
ignore_errors: true
delay: "{{ retry_delay }}"
retries: "{{ retry_num }}"
Expand Down
16 changes: 16 additions & 0 deletions roles/splunk_common/tasks/set_mgmt_port.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: Set mgmt port
ini_file:
dest: "{{ splunk.home }}/etc/system/local/web.conf"
section: settings
option: "mgmtHostPort"
value: "0.0.0.0:{{ splunk.svc_port }}"
owner: "{{ splunk.user }}"
group: "{{ splunk.group }}"
when:
- "'svc_port' in splunk"
register: set_mgmt_port

# Restart only when Splunk is running and when any of the above have changed
- include_tasks: ../handlers/restart_splunk.yml
when: set_mgmt_port is changed
7 changes: 6 additions & 1 deletion roles/splunk_common/tasks/start_splunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@
- splunk.enable_service
- ansible_os_family == "Windows"

- name: Check if UDS file exists
stat:
path: "/opt/splunkforwarder/var/run/splunk/cli.socket"
register: uds_socket_exists

- name: "Wait for splunkd management port"
wait_for:
port: "{{ splunk.svc_port }}"
when: splunk.splunk_http_enabled|bool == true
when: not uds_socket_exists.stat.exists

- name: Flush restart handlers
meta: flush_handlers
7 changes: 6 additions & 1 deletion roles/splunk_common/tasks/wait_for_splunk_process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
state: present
when: ansible_system is match("Linux")

- name: Check if UDS file exists
stat:
path: "/opt/splunkforwarder/var/run/splunk/cli.socket"
register: uds_socket_exists

- name: Wait for the Splunk service port to be available
wait_for:
host: 127.0.0.1
port: "{{ splunk.svc_port }}"
timeout: 180
when: splunk.splunk_http_enabled|bool == true
when: not uds_socket_exists.stat.exists

0 comments on commit 0798330

Please sign in to comment.