-
-
Save tianying484/48ea6b47a3f0e478490bd78a340180b2 to your computer and use it in GitHub Desktop.
ansible mysql percona task
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: Add Percona apt signing key | |
sudo: yes | |
apt_key: keyserver=keys.gnupg.net id=1C4CBDCDCD2EFD2A state=present | |
- name: Add Percona repository | |
sudo: yes | |
apt_repository: repo='deb http://repo.percona.com/apt trusty main' state=present | |
- name: Add Percona source repository | |
sudo: yes | |
apt_repository: repo='deb-src http://repo.percona.com/apt trusty main' state=present | |
- name: Update apt cache | |
sudo: yes | |
apt: update_cache=yes | |
- name: Install python packages | |
sudo: yes | |
apt: pkg={{ item }} state=present | |
with_items: | |
- vim | |
- python-pycurl | |
- python-mysqldb | |
- name: Install Percona packages | |
sudo: yes | |
apt: pkg={{ item }} state=present update_cache=yes | |
with_items: | |
- percona-server-common-5.6 | |
- percona-server-client-5.6 | |
- percona-server-server-5.6 | |
environment: | |
DEBIAN_FRONTEND: noninteractive | |
- name: Create Mysql configuration file | |
sudo: yes | |
template: src=server.my.cnf.j2 dest=/etc/mysql/my.cnf | |
notify: | |
- restart mysql | |
- name: Update mysql root password for all root accounts | |
sudo: yes | |
mysql_user: name=root host={{ item }} password={{ mysql_root_password }} | |
with_items: | |
- "{{ ansible_hostname }}" | |
- 127.0.0.1 | |
- ::1 | |
- localhost | |
- name: Copy .my.cnf file with root password credentials | |
sudo: yes | |
template: src=root.my.cnf.j2 dest=~/.my.cnf mode=0600 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment