Last active
February 3, 2022 14:06
-
-
Save zavan/bbefeeb16d7b581ce505e75a88e1307c to your computer and use it in GitHub Desktop.
Installing MySQL v5.7 on Ubuntu 20.04 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
- name: Setup MySQL v5.7 | |
become: yes | |
block: | |
- name: Add MySQL apt key | |
apt_key: | |
keyserver: pgp.mit.edu | |
id: 3A79BD29 | |
state: present | |
- name: Add MySQL apt repo | |
apt_repository: | |
repo: deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7 | |
state: present | |
filename: mysql | |
update_cache: yes | |
- name: Pre-configure MySQL root password apt variables | |
debconf: | |
name: mysql-community-server | |
question: "mysql-community-server/{{ item }}" | |
value: yourrootpassword | |
vtype: string | |
loop: | |
- root-pass | |
- re-root-pass | |
no_log: yes | |
- name: Install MySQL v5.7 | |
apt: | |
allow_downgrade: yes | |
pkg: | |
- mysql-common=5.7* | |
- mysql-client=5.7* | |
- libmysqlclient-dev=5.7* | |
- mysql-community-server=5.7* | |
- name: Start MySQL server and make sure it starts on boot | |
service: | |
name: mysql | |
state: started | |
enabled: yes | |
# Optional | |
- name: Prevent MySQL packages from being upgraded to v8 | |
dpkg_selections: | |
name: "{{ item }}" | |
selection: hold | |
loop: | |
- mysql-common | |
- mysql-client | |
- libmysqlclient-dev | |
- mysql-community-server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment