diff --git a/inventory/environ.py b/inventory/environ.py index 3e6b81cb..e3dd1e81 100755 --- a/inventory/environ.py +++ b/inventory/environ.py @@ -113,6 +113,7 @@ def getDefaultVars(): getASan(defaultVars) getDisablePopups(defaultVars) getHEC(defaultVars) + getContainerEnv(defaultVars) getSecrets(defaultVars) getSplunkPaths(defaultVars) getIndexerClustering(defaultVars) @@ -523,6 +524,13 @@ def getHEC(vars_scope): else: vars_scope["splunk"]["hec"]["ssl"] = bool(vars_scope["splunk"]["hec"].get("ssl")) +def getContainerEnv(vars_scope): + """ + Get the configured max cpu, vcpu, and system memory + """ + vars_scope["splunk"]["containerEnv"] = os.environ.get("SPLUNK_CONTAINER_ENV", vars_scope["splunk"].get("containerEnv")) + vars_scope["splunk"]["cgroup"] = os.environ.get("SPLUNK_CGROUP_PATH", vars_scope["splunk"].get("cgroup")) + def getDSP(vars_scope): """ Configure DSP settings diff --git a/roles/splunk_common/tasks/main.yml b/roles/splunk_common/tasks/main.yml index a212069d..d0a235e9 100644 --- a/roles/splunk_common/tasks/main.yml +++ b/roles/splunk_common/tasks/main.yml @@ -130,4 +130,29 @@ - include_tasks: add_splunk_license.yml - include_tasks: disable_popups.yml - when: "'disable_popups' in splunk and splunk.disable_popups | bool" \ No newline at end of file + when: "'disable_popups' in splunk and splunk.disable_popups | bool" + +# set containerEnv to true in limits.conf +- name: set_container_true + ini_file: + dest: "{{ splunk.home }}/etc/system/local/limits.conf" + section: default + option: "containerEnv" + value: "{{ splunk.containerEnv }}" + owner: "{{ splunk.user }}" + group: "{{ splunk.group }}" + when: + - splunk.containerEnv is defined + - splunk.containerEnv | bool + +# set cgroup path, if defined, in limits.conf +- name: set_cgroup_path + ini_file: + dest: "{{ splunk.home }}/etc/system/local/limits.conf" + section: default + option: "cgroup" + value: "{{ splunk.cgroup }}" + owner: "{{ splunk.user }}" + group: "{{ splunk.group }}" + when: + - splunk.cgroup is defined \ No newline at end of file