Skip to content

Instantly share code, notes, and snippets.

@rimiti

rimiti/main.yml

Created Apr 26, 2018
Embed
What would you like to do?
How to install MySQL 5.7 with Ansible
# Add PGP key to install mysql 5.7 from mysql repository
- name: Add PGP key
apt_key:
keyserver: hkp://pgp.mit.edu:80
id: 5072E1F5
- name: Add official APT repository
apt_repository:
repo: "deb http://repo.mysql.com/apt/debian/ stretch mysql-5.7"
# Install mysql
- name: Install mysql-server
apt:
name: "{{item}}"
state: present
update_cache: yes
with_items:
- mysql-server
# Mysql setup
- name: Ensure anonymous users are not in the database
mysql_user: name='' host=localhost state=absent
- name: Remove test database
mysql_db: name=test state=absent
- name: Create admin user
mysql_user:
name: "{{sql_admin_user}}"
password: "{{sql_admin_password}}"
priv: "*.*:ALL,GRANT"
append_privs: yes
state: present
no_log: True
# Update /etc/hosts file
- name: update hosts file
lineinfile:
dest: /etc/hosts
line: "127.0.0.1 {{ sql_host }}"
state: present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.