---
- name: install dd repo key
  apt_key:
    id: C7A7DA52
    keyserver: keyserver.ubuntu.com

- name: install dd repo
  apt_repository:
    repo: "deb https://apt.datadoghq.com/ stable main"
    update_cache: yes

- name: install dependency packages
  apt:
    name: "{{ item }}"
    state: installed
  with_items:
    - apt-transport-https

- name: install datadog agent package
  apt:
    name: datadog-agent
    state: installed
  notify:
    - restart dd-agent

# This is required to call datadog_monitor with ansible and later to use the
# datadog callback for more integration into ansible runs
# within datadog.
- name: install datadog pip
  pip:
    name: datadog
    virtualenv: /opt/datadog

- name: Ensure config directories
  file:
    state: directory
    path: "{{ item }}"
  with_items:
    - "{{ datadog_config_dir }}"
    - "{{ datadog_check_dir }}"
    - "{{ datadog_frag_dir }}"

- name: configure datadog
  template:
    src: etc/dd-agent/datadog.conf
    dest: "{{ datadog_config_dir }}/datadog.conf"
    owner: dd-agent
    group: root
  notify:
    - restart dd-agent

# Flush handlers to avoid a start + restart scenario
- meta: flush_handlers

- name: start datadog agent
  service:
    name: datadog-agent
    state: started
    enabled: yes

---
- name: install dd repo key
  apt_key:
    id: C7A7DA52
    keyserver: keyserver.ubuntu.com

- name: install dd repo
  apt_repository:
    repo: "deb https://apt.datadoghq.com/ stable main"
    update_cache: yes

- name: install dependency packages
  apt:
    name: "{{ item }}"
    state: installed
  with_items:
    - apt-transport-https

- name: install datadog agent package
  apt:
    name: datadog-agent
    state: installed
  notify:
    - restart dd-agent

- name: Ensure config directories
  file:
    state: directory
    path: "{{ item }}"
  with_items:
    - "{{ datadog_config_dir }}"
    - "{{ datadog_check_dir }}"
    - "{{ datadog_frag_dir }}"

- name: configure datadog
  template:
    src: etc/dd-agent/datadog.conf
    dest: "{{ datadog_config_dir }}/datadog.conf"
    owner: dd-agent
    group: root
  notify:
    - restart dd-agent

# Flush handlers to avoid a start + restart scenario
- meta: flush_handlers

- name: start datadog agent
  service:
    name: datadog-agent
    state: started
    enabled: yes

Stop install pip datadog to /opt/datadog
Stop install pip datadog to /opt/datadog

I think this is a remnant of some earlier attempt at ansible datadog
integration, however ansible gets installed into /opt/ansible and there
is no other reference to this directory I can find in hoist.

I don't think it's required any more.

Signed-off-by: Jamie Lennox <1b9801e8e46f6bd96338b24e58c84c4f37762fc2@gmail.com>
