<commit_before>---
#
# edX Configuration
#
# github:     https://github.com/edx/configuration
# wiki:       https://openedx.atlassian.net/wiki/display/OpenOPS
# code style: https://openedx.atlassian.net/wiki/display/OpenOPS/Ansible+Code+Conventions
# license:    https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
#
#
# Tasks for role splunk
#
# Overview:
#
#
# Dependencies:
#
#
# Example play:
#
#

# Install Splunk Forwarder for common_debian_variants
- name: Install splunkforwarder specific system packages
  apt:
    name: "{{ item }}"
    state: present
  with_items: "{{ splunk_debian_pkgs }}"
  tags:
    - splunk
    - install
    - update
  when: ansible_distribution in common_debian_variants

- name: Download the splunk deb
  get_url:
    dest: "/tmp/{{ SPLUNKFORWARDER_DEB }}"
    url: "{{ SPLUNKFORWARDER_PACKAGE_URL }}"
  register: download_deb
  until: download_deb|succeeded
  retries: 5
  when: ansible_distribution in common_debian_variants

- name: Install splunk forwarder
  shell: "gdebi -nq /tmp/{{ SPLUNKFORWARDER_DEB }}"
  when: ansible_distribution in common_debian_variants and download_deb.changed

# Install Splunk Forwarder for common_redhat_variants
- name: Download the splunk rpm
  get_url:
    dest: "/tmp/{{ SPLUNKFORWARDER_RPM }}"
    url: "{{ SPLUNKFORWARDER_PACKAGE_URL }}"
  register: download_rpm
  until: download_rpm|succeeded
  retries: 5
  when: ansible_distribution in common_redhat_variants

- name: Install splunk forwarder
  shell: "rpm -i /tmp/{{ SPLUNKFORWARDER_RPM }}"
  when: ansible_distribution in common_redhat_variants and download_rpm.changed

- name: Create splunk user
  user:
    name: splunk
    createhome: no
    state: present
    append: yes
    groups: syslog,adm
  when: download_rpm.changed or download_deb.changed

# Need to start splunk manually so that it can create various files
# and directories that aren't created till the first run and are needed
# to run some of the below commands.<commit_msg>Update task names for clarity.<commit_after>---
#
# edX Configuration
#
# github:     https://github.com/edx/configuration
# wiki:       https://openedx.atlassian.net/wiki/display/OpenOPS
# code style: https://openedx.atlassian.net/wiki/display/OpenOPS/Ansible+Code+Conventions
# license:    https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
#
#
# Tasks for role splunk
#
# Overview:
#
#
# Dependencies:
#
#
# Example play:
#
#

# Install Splunk Forwarder for common_debian_variants
- name: Install splunkforwarder specific system packages
  apt:
    name: "{{ item }}"
    state: present
  with_items: "{{ splunk_debian_pkgs }}"
  tags:
    - splunk
    - install
    - update
  when: ansible_distribution in common_debian_variants

- name: Download the splunk deb
  get_url:
    dest: "/tmp/{{ SPLUNKFORWARDER_DEB }}"
    url: "{{ SPLUNKFORWARDER_PACKAGE_URL }}"
  register: download_deb
  until: download_deb|succeeded
  retries: 5
  when: ansible_distribution in common_debian_variants

- name: Install splunk forwarder deb
  shell: "gdebi -nq /tmp/{{ SPLUNKFORWARDER_DEB }}"
  when: ansible_distribution in common_debian_variants and download_deb.changed

# Install Splunk Forwarder for common_redhat_variants
- name: Download the splunk rpm
  get_url:
    dest: "/tmp/{{ SPLUNKFORWARDER_RPM }}"
    url: "{{ SPLUNKFORWARDER_PACKAGE_URL }}"
  register: download_rpm
  until: download_rpm|succeeded
  retries: 5
  when: ansible_distribution in common_redhat_variants

- name: Install splunk forwarder rpm
  shell: "rpm -i /tmp/{{ SPLUNKFORWARDER_RPM }}"
  when: ansible_distribution in common_redhat_variants and download_rpm.changed

- name: Create splunk user
  user:
    name: splunk
    createhome: no
    state: present
    append: yes
    groups: syslog,adm
  when: download_rpm.changed or download_deb.changed

# Need to start splunk manually so that it can create various files
# and directories that aren't created till the first run and are needed
# to run some of the below commands.
{'fraction_non_alphanumeric': 0.09382036527395547, 'fraction_numerical': 0.0010007505629221916, 'mean_word_length': 4.060759493670886, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4255597', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1329, 'n_words': 351}