Created
April 26, 2018 18:23
-
-
Save rimiti/b1d2410504f8e6cb0b754f3dfd8d999f to your computer and use it in GitHub Desktop.
How to install MySQL 5.7 with Ansible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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