---
- name: MySQL database
  mysql_db: name={{ mysqldb_dbname }} state=present encoding=utf8

- name: Create webapp mysql user (Deprecated)
  mysql_user: name={{ mysqldb_user }} host={{ mysqldb_user_host }} password={{ mysqldb_password }} priv={{ mysqldb_dbname }}.*:ALL state=present append_privs=yes
  when: mysqldb_user is defined

- name: Add mysql users
  mysql_user: name={{ item.user }} host={{ item.host }} password={{ item.password }} priv={{ mysqldb_dbname }}.*:ALL state=present append_privs=yes
  with_items: "{{ mysqldb_users }}"
  when: mysqldb_users is defined

- name: Add a crontab entry to backup database
  cron: name="mysqldump" minute="*/10" job="mysqldump -u root --single-transaction {{ mysqldb_dbname }} > {{ mysqldb_backup_dir }}/{{ mysqldb_dbname }}.backup"
  when: mysqldb_backup is defined and mysqldb_backup




---
- name: Install python module (needed by ansible)
  yum: name=MySQL-python

- name: Install python module (needed by ansible)
  yum: name={{ item }}
  with_items:
    - MySQL-python26
    - MySQL-python27
  when: ansible_distribution == 'Amazon' # Amazon Linux AMI

- name: MySQL database
  mysql_db: name={{ mysqldb_dbname }} state=present encoding=utf8

- name: Create webapp mysql user (Deprecated)
  mysql_user: name={{ mysqldb_user }} host={{ mysqldb_user_host }} password={{ mysqldb_password }} priv={{ mysqldb_dbname }}.*:ALL state=present append_privs=yes
  when: mysqldb_user is defined

- name: Add mysql users
  mysql_user: name={{ item.user }} host={{ item.host }} password={{ item.password }} priv={{ mysqldb_dbname }}.*:ALL state=present append_privs=yes
  with_items: "{{ mysqldb_users }}"
  when: mysqldb_users is defined

- name: Add a crontab entry to backup database
  cron: name="mysqldump" minute="*/10" job="mysqldump -u root --single-transaction {{ mysqldb_dbname }} > {{ mysqldb_backup_dir }}/{{ mysqldb_dbname }}.backup"
  when: mysqldb_backup is defined and mysqldb_backup




Install MySQL-python module for Ansible
Install MySQL-python module for Ansible
