---
- name: Bootstrap instance(s)
  hosts: all
  gather_facts: no
  become: True
  roles:
    - python

- name: Configure instance(s)
  hosts: all
  become: True
  gather_facts: True
  vars:
    COMMON_ENABLE_DATADOG: True
    COMMON_ENABLE_SPLUNKFORWARDER: True
    COMMON_ENABLE_NEWRELIC: True
    COMMON_SECURITY_UPDATES: yes
    SECURITY_UPGRADE_ON_ANSIBLE: true

    SPLUNKFORWARDER_LOG_ITEMS:
      - source: '/var/lib/jenkins/jobs/*/builds/*/junitResult.xml'
        recursive: true
        index: 'testeng'
        sourcetype: junit
        followSymlink: false
        blacklist: '\.gz$'
        crcSalt: '<SOURCE>'

      - source: '/var/lib/jenkins/jobs/*/builds/*/build.xml'
        index: 'testeng'
        recursive: true
        sourcetype: build_result
        followSymlink: false
        crcSalt: '<SOURCE>'
        blacklist: '\.gz$'

      - source: '/var/lib/jenkins/jobs/edx-platform-*/builds/*/archive/.../test_root/log/timing.*.log'
        index: 'testeng'
        recursive: true
        sourcetype: 'json_timing_log'
        followSymlink: false
        crcSalt: '<SOURCE>'
        blacklist: coverage|private|subset|specific|custom|special|\.gz$

      - source: '/var/log/jenkins/jenkins.log'
        index: 'testeng'
        recursive: false
        followSymlink: false
        blacklist: '\.gz$'

  roles:
    - aws
    - role: datadog
      when: COMMON_ENABLE_DATADOG

    - jenkins_build

    # 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
        - jenkins:promote-to-production
      become: True

    - role: newrelic
      when: COMMON_ENABLE_NEWRELIC
      tags:
        - newreliconly