-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix and serverclass generation (#84)
* Accept license after other configuration tasks are done instead of immediately after unarchive * Add serverclass.conf generation and documentation
- Loading branch information
Mason Morales
authored
Aug 6, 2021
1 parent
d3200e0
commit 692e366
Showing
7 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
# Example host_vars for a deployment server that is leveraging the configure_serverclass.yml task to manage serverclass.conf | ||
serverclasses: | ||
# First server class example, basic definition: | ||
- serverclass: ALL | ||
whitelist: | ||
- '*' | ||
apps: | ||
- name: my_outputs_addon | ||
options: | ||
restartSplunkd: 1 | ||
# Second server class example, adding in the platform filter: | ||
- serverclass: ALL_NIX | ||
whitelist: | ||
- '*' | ||
platform: linux-x86_64 | ||
apps: | ||
- name: Splunk_TA_nix | ||
options: | ||
restartSplunkd: 1 | ||
# Third server class example, adding multiple apps and filters with additional options configured for each app: | ||
- serverclass: ALL_WINDOWS_x64 | ||
whitelist: | ||
- 'hosta' | ||
- 'hostb' | ||
- 'windows-dc-*' | ||
blacklist: | ||
- 'hostc' | ||
platform: windows-x64 | ||
apps: | ||
- name: Splunk_TA_windows | ||
options: | ||
restartSplunkd: 0 | ||
restartIfNeeded: 1 | ||
- name: custom_windows_inputs | ||
options: | ||
restartSplunkWeb: 0 | ||
restartSplunkd: 1 | ||
stateOnClient: enabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
- name: Check for duplicate serverclasses | ||
assert: | ||
that: > | ||
serverclasses | map(attribute='serverclass') | list | count | ||
== | ||
serverclasses | map(attribute='serverclass') | list | unique | count | ||
fail_msg: "A duplicate serverclass has been detected! Please correct the vars and try again." | ||
|
||
- name: Generate serverclass.conf from vars | ||
template: | ||
src: serverclass.conf.j2 | ||
dest: "{{ splunk_home }}/etc/system/local/serverclass.conf" | ||
backup: true | ||
mode: 0644 | ||
owner: "{{ splunk_nix_user }}" | ||
group: "{{ splunk_nix_group }}" | ||
become: true | ||
notify: reload deployment server | ||
when: serverclasses is defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This file is managed by Ansible - DO NOT MODIFY MANUALLY OR VIA SPLUNK WEB | ||
{% for x in serverclasses %} | ||
[serverClass:{{ x.serverclass }}] | ||
{% if x.platform is defined %} | ||
machineTypesFilter = {{ x.platform }} | ||
{% endif %} | ||
{% if x.blacklist is defined %} | ||
{% set blacklistindex = namespace(value=0) %} | ||
{% for y in x.blacklist %} | ||
blacklist.{{ blacklistindex.value }} = {{ y }} | ||
{% set blacklistindex.value = blacklistindex.value + 1 %} | ||
{% endfor %} | ||
{% endif %} | ||
{% if x.whitelist is defined %} | ||
{% set whitelistindex = namespace(value=0) %} | ||
{% for y in x.whitelist %} | ||
whitelist.{{ whitelistindex.value }} = {{ y }} | ||
{% set whitelistindex.value = whitelistindex.value + 1 %} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
{% if x.apps is defined %} | ||
{% for z in x.apps %} | ||
[serverClass:{{ x.serverclass }}:app:{{ z.name }}] | ||
{% if z.options is defined %} | ||
{% for key, value in z.options.items() %} | ||
{{ key }} = {{ value }} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
{% endfor %} | ||
{% endif %} | ||
{% endfor %} |