Last active
April 27, 2016 00:40
-
-
Save ahebrank/11994107a387e5096a247f3ed5707abf to your computer and use it in GitHub Desktop.
ansible role for mysql 5.1 on ubuntu 14.04
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
--- | |
# 5.1 compile from source from https://sonnguyen.ws/install-mysql-5-1-ubuntu-14/ and trial and error | |
- stat: path=/usr/bin/mysqld_safe | |
register: mysql_binary | |
- name: Install build tools | |
sudo: yes | |
apt: name={{item}} state=installed | |
with_items: | |
- g++ | |
- libssl-dev | |
- libedit-dev | |
- readline-common | |
- libedit2 | |
- name: Download mysql 5.1 | |
get_url: url=http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.65.tar.gz dest=/tmp/mysql-5.1.65.tar.gz mode=0440 | |
- name: Untar mysql | |
unarchive: src=/tmp/mysql-5.1.65.tar.gz dest=/tmp copy=no | |
when: mysql_binary.stat.exists == False | |
- name: Configure and build mysql | |
shell: "{{ item }}" | |
sudo: yes | |
args: | |
chdir: /tmp/mysql-5.1.65 | |
with_items: | |
- ./configure '--prefix=/usr' '--exec-prefix=/usr' '--libexecdir=/usr/sbin' '--datadir=/usr/share' '--localstatedir=/var/lib/mysql' '--includedir=/usr/include' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-system-type=debian-linux-gnu' '--enable-shared' '--enable-static' '--enable-thread-safe-client' '--enable-assembler' '--enable-local-infile' '--with-fast-mutexes' '--with-big-tables' '--with-unix-socket-path=/var/run/mysqld/mysqld.sock' '--with-mysqld-user=mysql' '--with-libwrap' '--without-readline' '--with-ssl' '--without-docs' '--with-extra-charsets=all' '--with-plugins=max' '--with-embedded-server' '--with-embedded-privilege-control' '--with-readline' | |
- make | |
- make install | |
when: mysql_binary.stat.exists == False | |
- name: mysql storage and user | |
shell: "{{ item }}" | |
sudo: yes | |
with_items: | |
- mkdir /var/lib/mysql | |
- useradd mysql | |
- chown -R mysql:mysql /var/lib/mysql | |
when: mysql_binary.stat.exists == False | |
- name: "expose 3306 externally" | |
sudo: yes | |
lineinfile: dest=/etc/mysql/my.cnf regexp="^bind-address" line="bind-address = 0.0.0.0" | |
- name: "comment out lc-messages-dir" | |
sudo: yes | |
lineinfile: dest=/etc/mysql/my.cnf regexp="^lc\-messages\-dir" line="#lc-messages-dir = /usr/share/mysql" | |
- name: copy user my.cnf file with root passwd credentials | |
sudo: yes | |
template: src=template.cnf dest=/root/.my.cnf group=root mode=0600 | |
- name: "Install db" | |
sudo: yes | |
shell: "mysql_install_db --user=mysql" | |
when: mysql_binary.stat.exists == False | |
- name: Install MySQL Python DB library | |
sudo: yes | |
apt: pkg=python-mysqldb state=latest | |
- name: Start the new server | |
sudo: yes | |
shell: "/usr/bin/mysqld_safe --user=mysql &" | |
- name: Update MySQL Root Password | |
mysql_user: "check_implicit_admin=True name=root host=localhost password={{mysql_root_passwd}}" | |
- name: Add (Vagrant) debug user | |
mysql_user: "name=root host=192.168.56.1 password={{mysql_root_passwd}} priv=*.*:ALL" | |
- name: delete anonymous mysql user | |
mysql_user: name="" state=absent | |
- name: remove mysql test database | |
mysql_db: name=test state=absent | |
- name: "create dev database" | |
mysql_db: "name={{ database.name }} state=present" | |
- name: "create dev database user" | |
mysql_user: "name={{ database.user }} password={{ database.password }} priv=*.*:ALL state=present" | |
- name: "copy initial dev db" | |
copy: src=initial.sql dest=/tmp/initial.sql | |
- name: "initialize dev database" | |
mysql_db: name={{ database.name }} state=import target=/tmp/initial.sql | |
- name: "Stop mysql" | |
sudo: yes | |
shell: "/usr/bin/mysqladmin shutdown" | |
- name: "Start mysql" | |
sudo: yes | |
shell: "/usr/bin/mysqld_safe --user=mysql &" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment