Skip to content

Instantly share code, notes, and snippets.

@fnzv
Forked from bjallen/main.yml
Last active August 8, 2017 10:32
Show Gist options
  • Save fnzv/1faebbcdcddb9565dc1623ebe438bc75 to your computer and use it in GitHub Desktop.
Save fnzv/1faebbcdcddb9565dc1623ebe438bc75 to your computer and use it in GitHub Desktop.
ansible mysql percona task
---
- name: Add Percona apt signing key
sudo: yes
apt_key: keyserver=keys.gnupg.net id=8507EFA5 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