---
- name: Initialize | Download seed data
  get_url:
    dest: '/tmp/cbioportal-seed.sql.gz'
    url: '{{ seed_database }}'

- name: Initialize | Load seed data
  mysql_db:
    name: "{{mysql_database_name}}"
    state: import
    target: '/tmp/cbioportal-seed.sql.gz'
    login_user: "{{mysql_database_user}}"
    login_password: "{{mysql_database_password}}"

---
- name: Initialize | Download seed data
  get_url:
    dest: '/tmp/cbioportal-seed.sql.gz'
    url: '{{ seed_database }}'


## Just how many mutations exactly?
- name: Retrieve stuff from mysql
  command: >
    mysql --user={{mysql_database_user}} --password={{mysql_database_password}} {{mysql_database_name}}
    --host=localhost --batch --skip-column-names
    --execute="SELECT COUNT(*) AS COUNT FROM cosmic_mutation"
  register: cosmic_mutation_count
  always_run: True
  changed_when: False

- name: echo
  debug:
    var: 'cosmic_mutation_count'

## Don't reload if we have data
- name: Initialize | Load seed data
  mysql_db:
    name: "{{mysql_database_name}}"
    state: import
    target: '/tmp/cbioportal-seed.sql.gz'
    login_user: "{{mysql_database_user}}"
    login_password: "{{mysql_database_password}}"
  when: cosmic_mutation_count.stdout == "0"

Make the seed loading behave with a bit more idempotence
Make the seed loading behave with a bit more idempotence
