---
# mongo_mms
#
# Example play:
#
#   roles:
#   - mongo_mms

- fail: MMSAPIKEY is required
  when: MMSAPIKEY is not defined 

- name: download mongo mms agent
  get_url: >
    url="{{ base_url }}/{{ item.agent }}_{{ item.version }}_{{ pkg_arch }}.{{ pkg_format }}"
    dest="/tmp/{{ item.agent }}-{{ item.version }}.{{ pkg_format }}"
  register: download_mms_deb
  with_items:
    agents
  
- name: install mongo mms agent
  apt: >
    deb="/tmp/{{ item.agent }}-{{ item.version }}.deb"
  when: download_mms_deb.changed
  notify: restart mms
  with_items:
    agents

- name: add key to monitoring-agent.config
  lineinfile: >
    dest="{{ item.config }}"
    regexp="^mmsApiKey="
    line="mmsApiKey={{ MMSAPIKEY }}"
  notify: restart mms
  with_items:
    agents

- name: start mms service
  service: name=item.agent state=started
  with_items:
    agents

---
# mongo_mms
#
# Example play:
#
#   roles:
#   - mongo_mms

- fail: MMSAPIKEY is required
  when: MMSAPIKEY is not defined 

- name: download mongo mms agent
  get_url: >
    url="{{ base_url }}/{{ item.agent }}_{{ item.version }}_{{ pkg_arch }}.{{ pkg_format }}"
    dest="/tmp/{{ item.agent }}-{{ item.version }}.{{ pkg_format }}"
  register: download_mms_deb
  with_items:
    agents
  
- name: install mongo mms agent
  apt: >
    deb="/tmp/{{ item.agent }}-{{ item.version }}.deb"
  when: download_mms_deb.changed
  notify: restart mms
  with_items:
    agents

- name: add key to monitoring-agent.config
  lineinfile: >
    dest="{{ item.config }}"
    regexp="^mmsApiKey="
    line="mmsApiKey={{ MMSAPIKEY }}"
  notify: restart mms
  with_items:
    agents

- name: start mms service
  service: name="{{ item.agent }}" state=started
  with_items:
    agents

Expand the agent to restart
Expand the agent to restart
