Skip to content

Instantly share code, notes, and snippets.

@anujdevopslearn
Last active May 17, 2024 23:16
Show Gist options
  • Save anujdevopslearn/98a73c0ef7f72a70fc11759f8b2b9c25 to your computer and use it in GitHub Desktop.
Save anujdevopslearn/98a73c0ef7f72a70fc11759f8b2b9c25 to your computer and use it in GitHub Desktop.
MySQL Ansible Installation Script
- hosts: webservers
tasks:
- name: Install MySQL
action: apt pkg={{ item }} state=latest
with_items:
- libmysqlclient-dev
- python-mysqldb
- mysql-server
- mysql-client
- name: Start the MySQL service
action: service name=mysql state=started
- name: Create deploy user for mysql
mysql_user: user="deploy" host="%" password=password priv=*.*:ALL,GRANT
- name: Ensure anonymous users are not in the database
mysql_user: user='' host={{ item }} state=absent
with_items:
- 127.0.0.1
- ::1
- localhost
- name: Update mysql root password for all root accounts
mysql_user: name=root host={{ item }} password=password
with_items:
- 127.0.0.1
- ::1
- localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment