# Configure a Jenkins master instance for testeng
# This has the Jenkins Java app, but none of the requirements
# to run the tests.

- name: Configure instance(s)
  hosts: jenkins_master
  sudo: True
  gather_facts: True
  vars:
    COMMON_DATA_DIR: "/mnt"
    COMMON_ENABLE_DATADOG: True
    COMMON_ENABLE_SPLUNKFORWARDER: True

    SPLUNKFORWARDER_LOG_ITEMS:
      - source: '/var/lib/jenkins/jobs/*/builds/*/junitResult.xml'
        recursive: true
        index: 'testeng'
        sourcetype: junit
        followSymlink: false
        crcSalt: '<SOURCE>'
      - source: '/var/lib/jenkins/jobs/*/builds/*/build.xml'
        index: 'testeng'
        recursive: true
        sourcetype: build_result
        followSymlink: false
        crcSalt: '<SOURCE>'
      - source: '/var/lib/jenkins/jobs/*/builds/*/log'
        index: 'testeng'
        recursive: true
        sourcetype: build_log
        followSymlink: false
        crcSalt: '<SOURCE>'

  roles:
    - common
    - role: datadog
      when: COMMON_ENABLE_DATADOG
    - jenkins_master

    # run just the splunkforwarder role by using '--tags "splunkonly"'
    # e.g. ansible-playbook jenkins_testeng_master.yml -i inventory.ini --tags "splunkonly" -vvvv
    - role: splunkforwarder
      when: COMMON_ENABLE_SPLUNKFORWARDER
      tags: splunkonly
      sudo: True

# Configure a Jenkins master instance for testeng
# This has the Jenkins Java app, but none of the requirements
# to run the tests.

- name: Configure instance(s)
  hosts: jenkins_master
  sudo: True
  gather_facts: True
  vars:
    COMMON_DATA_DIR: "/mnt"
    COMMON_ENABLE_DATADOG: True
    COMMON_ENABLE_SPLUNKFORWARDER: True

    SPLUNKFORWARDER_LOG_ITEMS:
      - source: '/var/lib/jenkins/jobs/*/builds/*/junitResult.xml'
        recursive: true
        index: 'testeng'
        sourcetype: junit
        followSymlink: false
        crcSalt: '<SOURCE>'
      - source: '/var/lib/jenkins/jobs/*/builds/*/build.xml'
        index: 'testeng'
        recursive: true
        sourcetype: build_result
        followSymlink: false
        crcSalt: '<SOURCE>'
      - source: '/var/lib/jenkins/jobs/*/builds/*/log'
        index: 'testeng'
        recursive: true
        sourcetype: build_log
        followSymlink: false
        crcSalt: '<SOURCE>'
      - source: '/var/log/jenkins/jenkins.log'
        index: 'testeng'
        recursive: false
        followSymlink: false

  roles:
    - common
    - role: datadog
      when: COMMON_ENABLE_DATADOG
    - jenkins_master

    # run just the splunkforwarder role by using '--tags "splunkonly"'
    # e.g. ansible-playbook jenkins_testeng_master.yml -i inventory.ini --tags "splunkonly" -vvvv
    - role: splunkforwarder
      when: COMMON_ENABLE_SPLUNKFORWARDER
      tags: splunkonly
      sudo: True

Index the jenkins master log in Splunk
Index the jenkins master log in Splunk
