1
0
mirror of https://github.com/krislamo/vagrant-easyredmine synced 2024-11-09 22:40:36 +00:00

many fixes; now run redmine installer via wrapper

This commit is contained in:
Mark Heiges 2015-11-11 23:14:03 -05:00
parent 459abad2e2
commit 786245d907
9 changed files with 220 additions and 82 deletions

10
README.md Normal file
View File

@ -0,0 +1,10 @@
Redmine sample data
To import a copy of an existing Redmine database, place a copy of the MySQL dump file
at `scratch/redmine_dump.sql.gz`. _(One of the daily backups on our production
Redmine server is suitable. See `/var/lib/mysql.backups/daily/redmine/`.)_

View File

@ -4,3 +4,47 @@
- mysql-devel
- mariadb-server
- MySQL-python
- service: name='{{ redmine_db_service_provider }}'
state=started
sudo: yes
- mysql_db: name='{{ redmine_db_name }}'
state=present
encoding=utf8
sudo: yes
register: redmine_db_created
# source database may not have same name as VM db.
# So remove CREATE or USE statements from dump.
# while unpacking.
- name: unpack mysql dump file
shell: "/usr/bin/gunzip -c {{ redmine_db_dump_file }} | /usr/bin/sed '/^CREATE DATABASE \\|^USE /d' > {{ _redmine_db_import_file }}"
args:
creates: '{{ _redmine_db_import_file }}'
when: do_redmine_db_import == True
- stat: path='{{ _redmine_db_import_success }}'
register: redmine_db_import_done
when: do_redmine_db_import == True
- name: import database
mysql_db: name='{{ redmine_db_name }}'
state=import
target='{{ _redmine_db_import_file }}'
register: redmine_db_import
when: do_redmine_db_import == True and (redmine_db_import_done.stat.exists == False or redmine_db_created|changed)
- file: path='{{ _redmine_db_import_success }}'
state=touch
when: do_redmine_db_import == True and redmine_db_import_done.stat.exists == False and redmine_db_import|success
- name: create db user
mysql_user: name='{{ redmine_db_user }}'
password='{{ redmine_db_password }}'
append_privs=yes
priv='{{ redmine_db_name }}.*:ALL'
state=present
sudo: yes

View File

@ -8,88 +8,18 @@
# mode=0644
# sudo: yes
- yum: name=epel-release
sudo: yes
- include: database.yml
- get_url: url=https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo
dest=/etc/yum.repos.d/passenger.repo
sudo: yes
- rpm_key: key=https://packagecloud.io/gpg.key
sudo: yes
- include: redmine.yml
# this makecache is mostly because I can not find any other way to fully import the GPG.
# key for the Passenger repo. 'rpm --import' is not sufficient.
- command: yum -q makecache -y --disablerepo='*' --enablerepo='passenger*'
sudo: yes
changed_when: False
- include: nginx.yml
- yum: name='{{ item }}'
sudo: yes
with_items:
- unzip
- rubygems
- ruby-devel
- zlib-devel
- openssl-devel
- gcc-c++
- mysql-devel
- ImageMagick-devel
- mariadb-server
- MySQL-python
- nginx
- passenger
- gem: name='{{ item }}'
sudo: yes
with_items:
- bundler
- redmine-installer
- stat: path='{{ cache_dir }}/{{ installer_package }}'
register: has_installer_package
- name: download installer
get_url: url='http://software.apidb.org/source/{{ installer_package }}'
dest='{{ cache_dir }}'
mode=0640
force=no
when: has_installer_package.stat.exists == False
- service: name='{{ redmine_db_service }}'
state=started
sudo: yes
- mysql_db: name='{{ redmine_db_name }}'
state=present
encoding=utf8
sudo: yes
- mysql_user: name='{{ redmine_db_user }}'
password='{{ redmine_db_password }}'
append_privs=yes
priv='{{ redmine_db_name }}.*:ALL'
state=present
sudo: yes
#- command: ~/bin/redmine install '{{ cache_dir }}/{{ installer_package }}'
#- command: ~/bin/redmine install '{{ installer_package }}'
# sudo: no
- template: dest=/etc/nginx/conf.d/easyredmine.conf
src=easyredmine.conf.j2
sudo: yes
notify: restart nginx
- template: dest=/etc/nginx/conf.d/passenger.conf
src=passenger.conf.j2
sudo: yes
notify: restart nginx
- service: name=nginx
state=started
sudo: yes
# when: redmine_db_created|changed
# {{ redmine_root }}
# {{ redmine_root_dir }}
# 1
# {{ redmine_db_name }}
# {{ redmine_db_host }}

View File

@ -0,0 +1,35 @@
- get_url: url=https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo
dest=/etc/yum.repos.d/passenger.repo
sudo: yes
- rpm_key: key=https://packagecloud.io/gpg.key
sudo: yes
# this makecache is mostly because I can not find any other way to fully
# import the GPG. key for the Passenger repo. 'rpm --import' is not
# sufficient.
- command: yum -q makecache -y --disablerepo='*' --enablerepo='passenger*'
sudo: yes
changed_when: False
- yum: name=epel-release
sudo: yes
- yum: name='{{ item }}'
sudo: yes
with_items:
- nginx
- passenger
- template: dest=/etc/nginx/conf.d/easyredmine.conf
src=easyredmine.conf.j2
sudo: yes
notify: restart nginx
- template: dest=/etc/nginx/conf.d/passenger.conf
src=passenger.conf.j2
sudo: yes
notify: restart nginx
- service: name=nginx
state=started
sudo: yes

View File

@ -0,0 +1,52 @@
- yum: name='{{ item }}'
sudo: yes
with_items:
- unzip
- rubygems
- ruby-devel
- zlib-devel
- openssl-devel
- gcc-c++
- ImageMagick-devel
- expect # for install_wrapper
- gem: name='{{ item }}'
sudo: yes
with_items:
- bundler
- redmine-installer
- stat: path='{{ installer_package }}'
register: has_installer_package
sudo: no
- name: download installer
get_url: url='{{ installer_package_url }}'
dest='{{ cache_dir }}'
mode=0640
force=no
when: has_installer_package.stat.exists == False
sudo: no
- template: dest='{{ _redmine_install_wrapper }}'
src=install_wrapper.j2
mode=750
sudo: no
- name: delete contents of redmine root directory
file: path='{{ redmine_root_dir }}'
state=absent
sudo: yes
when: redmine_db_created|changed
- file: path='{{ redmine_root_dir }}'
state=directory
owner=vagrant
mode=755
sudo: yes
register: mk_redmine_root_dir
- name: run redmine installer
command: '{{ _redmine_install_wrapper }}'
when: mk_redmine_root_dir|changed
sudo: no

View File

@ -1,6 +1,6 @@
server {
listen 80;
server_name {{ ansible_fqdn }};
root {{ redmine_root }}/public;
root {{ redmine_root_dir }}/public;
passenger_enabled on;
}

View File

@ -0,0 +1,49 @@
#!/usr/bin/expect
# EuPathDB wrapper on EasyRedmine installer for
# non-interactive installs by Ansible
set timeout -1
spawn ~/bin/redmine install /vagrant/scratch/easyredmine_package_u2072_d201511101601.zip
expect -re {[\r\n]+Path for redmine_root}
send "{{ redmine_root_dir }}\r"
# Database Configuration
expect -re {[\r\n]+> }
send "1\r"; # MySQL
expect -re {[\r\n]+Database: }
send "{{ redmine_db_name }}\r"
expect -re {[\r\n]+Host }
send "{{ redmine_db_host }}\r"
expect -re {[\r\n]+Username:}
send "{{ redmine_db_user }}\r"
expect -re {[\r\n]+Password:}
send "{{ redmine_db_password }}\r"
expect -re {[\r\n]+Encoding}
send "{{ redmine_db_encoding }}\r"
expect -re {[\r\n]+Port}
send "{{ redmine_db_port }}\r"
# Email sending configuration
expect -re {[\r\n]+> }
send "2\r"; # Sendmail
expect -re {[\r\n]+Location}
send "{{ sendmail_path }}\r"
expect -re {[\r\n]+Arguments}
send -- "{{ sendmail_args }}\r"
# What web-server do you want
expect -re {[\r\n]+> }
send "4\r"; # Passenger (nginx)
interact

View File

@ -0,0 +1,11 @@
{{ redmine_root_dir }}
1
{{ redmine_db_name }}
{{ redmine_db_host }}
{{ redmine_db_user }}
{{ redmine_db_password }}
{{ redmine_db_encoding }}
{{ redmine_db_port }}
2
{{ sendmail_path }}
{{ sendmail_args }}

View File

@ -1,16 +1,19 @@
---
# vars file for easyredmine
do_redmine_db_import: False
cache_dir: /vagrant/scratch
installer_package: easyredmine_package_u2072_d201511101601.zip
installer_package: '{{ cache_dir }}/easyredmine_package_u2072_d201511101601.zip'
installer_package_url: 'http://software.apidb.org/source/{{ installer_package }}'
mysql_dump: redmine_2015-11-10_03h09m.Tuesday.sql.gz
redmine_db_dump_file: '{{ cache_dir }}/redmine_dump.sql.gz'
redmine_root: /opt/easyredmine
redmine_root_dir: /opt/easyredmine
redmine_db_service: mariadb
redmine_db_service_provider: mariadb # or mysqld
redmine_db_name: easyredmine
redmine_db_host: localhost
redmine_db_user: redmine
@ -22,4 +25,8 @@ redmine_email_addr: mheiges@uga.edu
redmine_email_port: 587
sendmail_path: /usr/sbin/sendmail
sendmail_args: -i -t
sendmail_args: -i -t
_redmine_db_import_file: /tmp/redmine_dump.sql
_redmine_db_import_success: /tmp/redmine_db_import_success
_redmine_install_wrapper: /home/vagrant/bin/install_wrapper