Skip to content

Instantly share code, notes, and snippets.

@tbernacchi
Created May 25, 2017 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbernacchi/9288c00b40f10c4e14627f81f8ddc767 to your computer and use it in GitHub Desktop.
Save tbernacchi/9288c00b40f10c4e14627f81f8ddc767 to your computer and use it in GitHub Desktop.
---
##VARIAVEIS
- name: Variaveis
include_vars: /etc/ansible/vars/mariadb.yml
##MARIADB RUNNING
- name: MariaDB running...
service: name=mariadb state=started enabled=true
##INSTALA O MODULO PYTHONDB
- name: Instalando o modulo MySQL-python...
yum: pkg=MySQL-python.x86_64 state=installed
#login_user e login_password sao usados para trocar a senha ja cadastrada
##SETA A SENHA DO ROOT
- name: Setando a senha do root
mysql_user: name={{ db_login }} password={{ db_pass }} priv=*.*:ALL,GRANT state=present host='{{item}}'
with_items:
- localhost
- 127.0.0.1
- ::1
##COPIA O ARQUIVO my.cnf
- name: Copiando o security...
template: src=/etc/ansible/templates/security.cnf dest=/root/.my.cnf owner=root mode=0600
#DISALLOW ROOT REMOTE
- name: Desabilita login do root
command: 'mysql -ne "{{ item }}"'
with_items:
- DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')
changed_when: False
##REMOVE USUÁRIOS ANONIMOS
- name: Removendo usuarios anonimos do MariaDB
mysql_user: name='' host=localhost state=absent
##REMOVE BANCO DE TESTE
- name: Removendo o banco test
action: mysql_db db=test state=absent
##FLUSH PRIVILEGES
- name: Flush privileges
command: 'mysql -ne "{{ item }}"'
with_items:
- FLUSH PRIVILEGES
changed_when: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment