Skip to content

Instantly share code, notes, and snippets.

@wyattwalter
Created May 12, 2016 03:46
Show Gist options
  • Save wyattwalter/127e3ae7df9a6bf951d787d6cfdd8314 to your computer and use it in GitHub Desktop.
Save wyattwalter/127e3ae7df9a6bf951d787d6cfdd8314 to your computer and use it in GitHub Desktop.
MySQL secure_installation using Ansible
- name: delete anonymous MySQL server user for {{ ansible_nodename }}
mysql_user: login_user=root
login_password='{{ mysql_root }}'
check_implicit_admin=yes
user=""
host={{ item }}
state="absent"
with_items:
- ""
- "{{ ansible_nodename }}"
- localhost
- name: Change root user password on first run
mysql_user: login_user=root
login_password="{{ mysql_root }}"
check_implicit_admin=yes
name=root
password={{ mysql_root }}
priv=*.*:ALL,GRANT
host={{ item }}
with_items:
- "{{ ansible_nodename }}"
- 127.0.0.1
- ::1
- localhost
- name: remove the MySQL test database
action: mysql_db login_user=root login_password="{{ mysql_root }}" db=test state=absent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment