From 259d947ddc0db3c4db7f9d4db1ba91271165d432 Mon Sep 17 00:00:00 2001 From: philof Date: Thu, 25 Aug 2016 04:12:59 +0000 Subject: [PATCH 1/5] Update requirements file with PyMSQL --- requirements.in | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.in b/requirements.in index 4c2f09c..4a2de51 100644 --- a/requirements.in +++ b/requirements.in @@ -8,7 +8,7 @@ Flask-SQLAlchemy Flask-WTF mock mockldap -mysqlclient +pymysql passlib pylint pytest diff --git a/requirements.txt b/requirements.txt index 576edae..3949c7f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -31,12 +31,12 @@ MarkupSafe==0.23 # via jinja2, mako mccabe==0.5.2 # via pylint mock==2.0.0 mockldap==0.2.8 -mysqlclient==1.3.7 passlib==1.6.5 pbr==1.10.0 # via mock py==1.4.31 # via pytest pycparser==2.14 # via cffi pylint==1.6.4 +PyMySQL==0.7.6 pytest-cov==2.3.1 pytest==2.9.2 python-editor==1.0.1 # via alembic From 0c809f5fbefa49faa63762985340251d51a8f200 Mon Sep 17 00:00:00 2001 From: philof Date: Thu, 25 Aug 2016 04:17:36 +0000 Subject: [PATCH 2/5] Update SQLAlchemy URI and Documentation for PyMySQL --- config.default.py | 2 +- docs/Installation/Docker.md | 2 +- docs/Installation/Ubuntu1404.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config.default.py b/config.default.py index 7810186..452f01f 100644 --- a/config.default.py +++ b/config.default.py @@ -14,7 +14,7 @@ class BaseConfiguration(object): # Make this random (used to generate session keys) SECRET_KEY = '123456789abcdef123456789' SQLALCHEMY_TRACK_MODIFICATIONS = True - SQLALCHEMY_DATABASE_URI = 'mysql://root:vagrant@localhost:3306/servermail' + SQLALCHEMY_DATABASE_URI = 'pymysql://root:vagrant@localhost:3306/servermail' basedir = path.abspath(path.dirname(__file__)) LOG_LOCATION = '/opt/postmaster/logs/postmaster.log' diff --git a/docs/Installation/Docker.md b/docs/Installation/Docker.md index ff1bea4..62a21c8 100644 --- a/docs/Installation/Docker.md +++ b/docs/Installation/Docker.md @@ -54,7 +54,7 @@ Make sure to replace 'password_changeme' and 'docker.postmaster.local' with what docker run \ -p 0.0.0.0:80:8082 \ - -e DB_URI=mysql://postmasteruser:password_changeme@docker.postmaster.local:3306/servermail \ + -e DB_URI=pymysql://postmasteruser:password_changeme@docker.postmaster.local:3306/servermail \ -v /opt/postmaster_data/logs:/opt/postmaster/logs \ -d postmaster diff --git a/docs/Installation/Ubuntu1404.md b/docs/Installation/Ubuntu1404.md index 5e86c47..e1417ef 100644 --- a/docs/Installation/Ubuntu1404.md +++ b/docs/Installation/Ubuntu1404.md @@ -45,7 +45,7 @@ Make sure to replace "password_changeme" with the actual password supplied in st replace '127.0.0.1' with the IP address or DNS specified in step 2 of MySQL Preparation: cd /opt/postmaster/git - python manage.py setdburi 'mysql://postmasteruser:password_changeme@127.0.0.1:3306/servermail' + python manage.py setdburi 'pymysql://postmasteruser:password_changeme@127.0.0.1:3306/servermail' 5. PostMaster needs to create a few tables under the servermail database. This is done via a database migration, which means that only the necessary changes to the database are made, and these changes are reversible if something went wrong. From 2872dbb1b1b54bdc638155ed11af340262923438 Mon Sep 17 00:00:00 2001 From: philof Date: Thu, 25 Aug 2016 04:18:27 +0000 Subject: [PATCH 3/5] Remove libmysql & MySQL-python dependencies --- Dockerfile | 1 - docs/Installation/Ubuntu1404.md | 2 +- ops/ansible/roles/postmaster_deploy/tasks/main.yml | 1 - ops/ansible/roles/postmaster_deploy/tasks/mysql.yml | 4 ---- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3d632a6..5d51011 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,6 @@ RUN apt-get install -y \ libyaml-dev \ libpython2.7-dev \ sqlite3 \ - libmysqlclient-dev && \ apt-get autoremove -y && \ apt-get clean RUN /usr/sbin/apache2ctl stop && systemctl disable apache2 diff --git a/docs/Installation/Ubuntu1404.md b/docs/Installation/Ubuntu1404.md index e1417ef..0d8e3ac 100644 --- a/docs/Installation/Ubuntu1404.md +++ b/docs/Installation/Ubuntu1404.md @@ -75,7 +75,7 @@ You can change your username and password from Manage -> Administrators. 3. Install the required packages for PostMaster: - apt-get install python python-pip python-dev libldap2-dev libssl-dev libsasl2-dev libffi-dev apache2 libapache2-mod-wsgi mysql-server libmysqlclient-dev + apt-get install python python-pip python-dev libldap2-dev libssl-dev libsasl2-dev libffi-dev apache2 libapache2-mod-wsgi mysql-server 4. Make sure you are running Python 2.7 as your default Python installation, as PostMaster relies on Python 2.7: diff --git a/ops/ansible/roles/postmaster_deploy/tasks/main.yml b/ops/ansible/roles/postmaster_deploy/tasks/main.yml index 40b27e9..feb61c3 100644 --- a/ops/ansible/roles/postmaster_deploy/tasks/main.yml +++ b/ops/ansible/roles/postmaster_deploy/tasks/main.yml @@ -18,7 +18,6 @@ - libffi-dev - apache2 - libapache2-mod-wsgi - - libmysqlclient-dev when: provision_type == "dev" - name: Create virtualenv directory diff --git a/ops/ansible/roles/postmaster_deploy/tasks/mysql.yml b/ops/ansible/roles/postmaster_deploy/tasks/mysql.yml index 2bc2bca..4e77971 100644 --- a/ops/ansible/roles/postmaster_deploy/tasks/mysql.yml +++ b/ops/ansible/roles/postmaster_deploy/tasks/mysql.yml @@ -13,10 +13,6 @@ become: yes apt: pkg=mysql-server state=latest -- name: Install mysql-python globally for this next command :( - pip: name=MySQL-python - become: yes - - name: Create default database for mysql mysql_db: name=servermail state=present login_user=root login_password=vagrant From e37b45d97a12dffb376b73d116b00712e27209a2 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 19 Oct 2016 11:34:39 -0400 Subject: [PATCH 4/5] Adds mysql dialect for pymysql config Signed-off-by: Kevin --- config.default.py | 2 +- docs/Installation/Docker.md | 2 +- docs/Installation/Ubuntu1404.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config.default.py b/config.default.py index 452f01f..1459af9 100644 --- a/config.default.py +++ b/config.default.py @@ -14,7 +14,7 @@ class BaseConfiguration(object): # Make this random (used to generate session keys) SECRET_KEY = '123456789abcdef123456789' SQLALCHEMY_TRACK_MODIFICATIONS = True - SQLALCHEMY_DATABASE_URI = 'pymysql://root:vagrant@localhost:3306/servermail' + SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:vagrant@localhost:3306/servermail' basedir = path.abspath(path.dirname(__file__)) LOG_LOCATION = '/opt/postmaster/logs/postmaster.log' diff --git a/docs/Installation/Docker.md b/docs/Installation/Docker.md index 435fffe..43e17be 100644 --- a/docs/Installation/Docker.md +++ b/docs/Installation/Docker.md @@ -54,7 +54,7 @@ Make sure to replace 'password_changeme' and 'docker.postmaster.local' with what docker run \ -p 0.0.0.0:80:8082 \ - -e DB_URI=pymysql://postmasteruser:password_changeme@docker.postmaster.local:3306/servermail \ + -e DB_URI=mysql+pymysql://postmasteruser:password_changeme@docker.postmaster.local:3306/servermail \ -v /opt/postmaster_data/logs:/opt/postmaster/logs \ -d postmaster diff --git a/docs/Installation/Ubuntu1404.md b/docs/Installation/Ubuntu1404.md index 0d8e3ac..ce12e48 100644 --- a/docs/Installation/Ubuntu1404.md +++ b/docs/Installation/Ubuntu1404.md @@ -45,7 +45,7 @@ Make sure to replace "password_changeme" with the actual password supplied in st replace '127.0.0.1' with the IP address or DNS specified in step 2 of MySQL Preparation: cd /opt/postmaster/git - python manage.py setdburi 'pymysql://postmasteruser:password_changeme@127.0.0.1:3306/servermail' + python manage.py setdburi 'mysql+pymysql://postmasteruser:password_changeme@127.0.0.1:3306/servermail' 5. PostMaster needs to create a few tables under the servermail database. This is done via a database migration, which means that only the necessary changes to the database are made, and these changes are reversible if something went wrong. From c74f6ca5356a465d8d46c64c810e3d99d5b900a2 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 19 Oct 2016 11:48:05 -0400 Subject: [PATCH 5/5] installs python-mysqldb to create database in ansible (on dev) Signed-off-by: Kevin --- ops/ansible/roles/postmaster_deploy/tasks/mysql.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ops/ansible/roles/postmaster_deploy/tasks/mysql.yml b/ops/ansible/roles/postmaster_deploy/tasks/mysql.yml index 4e77971..13008d2 100644 --- a/ops/ansible/roles/postmaster_deploy/tasks/mysql.yml +++ b/ops/ansible/roles/postmaster_deploy/tasks/mysql.yml @@ -13,6 +13,10 @@ become: yes apt: pkg=mysql-server state=latest +- name: Install mysql-python using apt for this next command + become: yes + apt: name=python-mysqldb state-latest + - name: Create default database for mysql mysql_db: name=servermail state=present login_user=root login_password=vagrant