---
  - name: playbook to install the MDC
    hosts: local
    connection: local
    vars:
      local_path: "{{ lookup('env', 'HOME') }}"
      anaconda_path: "{{ local_path }}/anaconda"
      mdc_path: "{{ local_path }}/git/mdc"

    tasks:

      - name: apt-get installs
        apt:
          name: "{{ item }}"
          state: present
        become: true
        with_items:
          - bzip2

      - name: download miniconda
        get_url:
          url: https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh
          dest: /tmp
          force: no

      - name: install miniconda
        shell: bash /tmp/Miniconda-latest-Linux-x86_64.sh -b -p {{ anaconda_path }}
        args:
          creates: "{{ anaconda_path }}"

      - name: update conda
        shell: "{{ anaconda_path }}/bin/conda update conda"

      - name: clone MDC
        git:
          repo: https://github.com/usnistgov/mdcs.git
          dest: "{{ mdc_path }}"
          version: master

      - name: install new enviroment
        shell: "{{ anaconda_path }}/bin/conda env update -n root --file environment.yml"

      - name: install mongodb
        apt: pkg=mongodb-org state=latest update_cache=yes
        notify:
          - start mongodb

    handlers:

      - name: start mongodb
        service: name=mongod state=started

---
  - name: playbook to install the MDC
    hosts: local
    connection: local
    vars:
      local_path: "{{ lookup('env', 'HOME') }}"
      anaconda_path: "{{ local_path }}/anaconda"
      mdc_path: "{{ local_path }}/git/mdc"

    tasks:

      - name: apt-get installs
        apt:
          name: "{{ item }}"
          state: present
        become: true
        with_items:
          - bzip2

      - name: check if anaconda is installed
        stat: path={{ anaconda_path }}
        register: anaconda_dir

      - name: download miniconda
        get_url:
          url: https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh
          dest: /tmp
          force: no
        when: anaconda_dir.stat.exists == False

      - name: install miniconda
        shell: bash /tmp/Miniconda-latest-Linux-x86_64.sh -b -p {{ anaconda_path }}
        args:
          creates: "{{ anaconda_path }}"
        when: anaconda_dir.stat.exists == False

      - name: update conda
        shell: "{{ anaconda_path }}/bin/conda update conda"

      - name: clone MDC
        git:
          repo: https://github.com/usnistgov/mdcs.git
          dest: "{{ mdc_path }}"
          version: master

      - name: install new enviroment
        shell: "{{ anaconda_path }}/bin/conda env update -n root --file environment.yml"

      - name: install mongodb
        apt: pkg=mongodb-org state=latest update_cache=yes
        become: true
        notify:
          - start mongodb

    handlers:

      - name: start mongodb
        service: name=mongod state=started

Update anaconda installation and mongodb
Update anaconda installation and mongodb
