File: ansible/roles/mysql/tasks/main.yml

Recommend this page to a friend!
  Classes of Omar Shaban  >  PHP Game of Three  >  ansible/roles/mysql/tasks/main.yml  >  Download  
File: ansible/roles/mysql/tasks/main.yml
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP Game of Three
Game of Three implementation using Websockets
Author: By
Last change:
Date: 3 months ago
Size: 1,401 bytes
 

Contents

Class file image Download
---
# Retrieve the current hostname, because {{ ansible_hostname }} still contains the old name
- shell: hostname
  register: current_hostname

- name: mysql | Install MySQL Packages
  sudo: yes
  apt: pkg={{ item }} state=latest
  with_items:
    - mysql-server
    - mysql-client
    - python-mysqldb

- name: mysql | Update root password for all root accounts
  mysql_user: name=root host={{ item }} check_implicit_admin=yes password={{ mysql.root_password }} login_user=root login_password={{ mysql.root_password }}
  with_items:
    - "{{ current_hostname.stdout | lower }}"
    - 127.0.0.1
    - ::1
    - localhost

- name: mysql | Create databases
  mysql_db: name={{ mysql.database }} state=present login_user=root login_password={{ mysql.root_password }}

- name: mysql | Import dump
  mysql_db: name={{ mysql.database }} state=import login_user=root login_password={{ mysql.root_password }} target=/vagrant/{{ mysql.dump }}
  when: mysql.dump

- name: mysql | Ensure anonymous users are not in the database
  mysql_user: name='' host={{ item }} state=absent login_user=root login_password={{ mysql.root_password }}
  with_items:
    - localhost
    - "{{ current_hostname.stdout | lower }}"

- name: mysql | Create users
  mysql_user: name={{ mysql.user }} password={{ mysql.password }} priv={{ mysql.database }}.*:ALL state=present login_user=root login_password={{ mysql.root_password }}
For more information send a message to info at phpclasses dot org.