forked from ISTI-ansible-roles/ansible-roles
redmine: adapt the playbook to the newest redmine version and to Ubuntu 18.04. Add a systemd unit for unicorn. Support nginx.
This commit is contained in:
parent
1d7d31b8f3
commit
ee8c1aaccb
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# Note: this plugin depends on apache. It's not usable with nginx yet
|
||||
#
|
||||
redmine_version: 2.5.2
|
||||
redmine_version: 4.0.1
|
||||
redmine_inst_name: redmine
|
||||
redmine_main_project: redmine
|
||||
redmine_db_user: redm_db_user
|
||||
|
@ -13,7 +13,12 @@ redmine_db_host: localhost
|
|||
# It is a redmine_glob_root_dir subdirectory
|
||||
redmine_inst_dir: redmine
|
||||
redmine_user: redmine
|
||||
redmine_group: redmine
|
||||
redmine_group: '{{ redmine_user }}'
|
||||
|
||||
redmine_sysvinit_service_name: '{{ redmine_inst_name }}'
|
||||
redmine_systemd_service_name: 'unicorn@{{ redmine_inst_name }}.service'
|
||||
redmine_service_name: '{{ redmine_systemd_service_name }}'
|
||||
|
||||
redmine_log_level: warn
|
||||
# Minutes, from 1 to 60
|
||||
redmine_ldap_sync_freq: 10
|
||||
|
@ -70,8 +75,8 @@ rm_issue_templates_plugin: False
|
|||
rm_issue_todo_lists_plugin: False
|
||||
#
|
||||
# IMPORTANT: these are mutually exclusive. One of the two needs to be set to True
|
||||
ruby_use_mod_passenger: True
|
||||
ruby_use_unicorn: False
|
||||
ruby_use_mod_passenger: False
|
||||
ruby_use_unicorn: True
|
||||
# Redmine 2.x only
|
||||
rm_involvement_plugin: False
|
||||
|
||||
|
@ -81,7 +86,7 @@ unicorn_listen_address: 127.0.0.1
|
|||
unicorn_worker_processes: 5
|
||||
unicorn_timeout: 120
|
||||
unicorn_log_dir: /var/log/unicorn
|
||||
unicorn_pid_dir: /run/unicorn
|
||||
unicorn_pid_dir: '{{ unicorn_log_dir }}'
|
||||
unicorn_pid_file: '{{ unicorn_pid_dir }}/unicorn.pid'
|
||||
unicorn_gems:
|
||||
- unicorn
|
||||
|
@ -103,6 +108,7 @@ redmine_base_packages:
|
|||
- ruby
|
||||
- rails
|
||||
- ruby-rmagick
|
||||
- ruby-dev
|
||||
- rails
|
||||
- zlib1g-dev
|
||||
- libpq-dev
|
||||
|
@ -111,6 +117,8 @@ redmine_base_packages:
|
|||
- libmagickcore-dev
|
||||
- imagemagick
|
||||
|
||||
redmine_bionic_packages: '{{ redmine_base_packages }}'
|
||||
|
||||
# For Ubuntu precise
|
||||
redmine_base_packages_old_gems:
|
||||
- subversion
|
||||
|
@ -130,6 +138,6 @@ redmine_base_apache_modules:
|
|||
- rewrite
|
||||
- expires
|
||||
|
||||
redmine_additional_gems:
|
||||
- pry
|
||||
#redmine_additional_gems:
|
||||
# -pry
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
service: name=redmine state=reloaded
|
||||
|
||||
- name: Reload unicorn when needed
|
||||
service: name=redmine state=restarted
|
||||
service: name={{ redmine_service_name }} state=restarted
|
||||
when: ruby_use_unicorn
|
||||
|
||||
- name: Reconfigure redmine
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
dependencies:
|
||||
- role: '../../library/roles/apache'
|
||||
- { role: '../../library/roles/apache', when: ruby_use_mod_passenger }
|
||||
- { role: '../../library/roles/nginx', when: ruby_use_unicorn }
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
---
|
||||
- name: install the packages needed to run the redmine infrastructure. install the ruby packages needed to run redmine. Set ruby 1.9.3 as default
|
||||
apt: pkg={{ item }} state=present
|
||||
with_items: redmine_base_packages_old_gems
|
||||
notify:
|
||||
- set ruby 1.9.3 as default
|
||||
- set gem 1.9.3 as default
|
||||
|
||||
# The standard mod-passenger doesn't work with ruby 1.9
|
||||
- name: install the packages needed to run the redmine infrastructure
|
||||
apt: pkg={{ item }} state=absent
|
||||
with_items:
|
||||
- libapache2-mod-passenger
|
||||
notify: apache2 reload
|
||||
|
||||
- name: Remove the old passenger configuration
|
||||
file: src=/etc/apache2/mods-available/{{ item }} dest=/etc/apache2/mods-enabled/{{ item }} state=absent
|
||||
with_items:
|
||||
- passenger.load
|
||||
- passenger.conf
|
||||
notify: apache2 reload
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
- name: Install the packages needed to run the redmine infrastructure. install the ruby packages needed to run redmine. Use ruby 2.0
|
||||
apt: pkg={{ item }} state=present
|
||||
with_items: redmine_base_packages
|
||||
apt: pkg={{ redmine_base_packages }} state=present
|
||||
tags:
|
||||
- ruby
|
||||
- redmine
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
---
|
||||
- import_tasks: base-packages-old-gems.yml
|
||||
when: is_precise
|
||||
- import_tasks: base-packages.yml
|
||||
when: is_trusty
|
||||
- import_tasks: system-packages.yml
|
||||
when: is_bionic
|
||||
- import_tasks: rubygems.yml
|
||||
- import_tasks: redmine.yml
|
||||
- import_tasks: redmine-plugins.yml
|
||||
#- import_tasks: redmine-plugins.yml
|
||||
- import_tasks: base-config.yml
|
||||
when: ruby_use_mod_passenger
|
||||
- import_tasks: mod_passenger.yml
|
||||
when: ruby_use_mod_passenger
|
||||
- import_tasks: unicorn.yml
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
#
|
||||
# Plugins
|
||||
#
|
||||
- name: Create the directory where the plugins are downloaded
|
||||
file: dest={{ redmine_glob_root_dir }}/plugins_download state=directory
|
||||
tags: [ 'redmine', 'redmine_plugins' ]
|
||||
|
||||
- name: Redmine better gantt plugin
|
||||
get_url: url=https://github.com/kulesa/redmine_better_gantt_chart/releases/download/v.0.9.0/redmine_better_gantt_chart_0.9.0.zip dest={{ redmine_glob_root_dir }}/plugins_download/redmine_better_gantt_chart_0.9.0.zip
|
||||
tags: [ 'redmine', 'redmine_plugins' ]
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
- redmine
|
||||
|
||||
- name: Install the gem packages needed by some external utilities
|
||||
gem: name={{ item }} state=latest
|
||||
with_items: redmine_additional_gems
|
||||
gem: name={{ redmine_additional_gems }} state=latest
|
||||
when: redmine_additional_gems is defined
|
||||
tags:
|
||||
- ruby
|
||||
- redmine
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- name: Install the packages needed to run the redmine infrastructure.
|
||||
apt: pkg={{ redmine_bionic_packages }} state=present cache_valid_time=1800
|
||||
tags: [ 'ruby', 'redmine' ]
|
||||
|
||||
|
|
@ -1,46 +1,66 @@
|
|||
---
|
||||
- name: Install the unicorn ruby-on-rails service and its dependencies
|
||||
gem: name={{ item }} state=latest
|
||||
with_items: '{{ unicorn_gems }}'
|
||||
when: ruby_use_unicorn
|
||||
tags: [ 'ruby', 'redmine', 'unicorn' ]
|
||||
- block:
|
||||
- name: Install the unicorn ruby-on-rails service and its dependencies
|
||||
gem: name={{ item }} state=latest
|
||||
with_items: '{{ unicorn_gems }}'
|
||||
|
||||
- name: Create the unicorn log directory
|
||||
file: dest={{ unicorn_log_dir }} state=directory owner={{ redmine_user }} group={{ redmine_user }} mode=0750
|
||||
tags: [ 'ruby', 'redmine', 'unicorn' ]
|
||||
|
||||
- name: Create the unicorn pid directory
|
||||
file: dest=/var/run/unicorn state=directory owner={{ redmine_user }} group={{ redmine_user }} mode=0750
|
||||
tags: [ 'ruby', 'redmine', 'unicorn' ]
|
||||
|
||||
- name: Install the unicorn startup file for redmine
|
||||
copy: src=redmine.init dest=/etc/init.d/redmine owner=root group=root mode=0755
|
||||
when: ruby_use_unicorn
|
||||
tags: [ 'ruby', 'redmine', 'unicorn', 'unicorn_init' ]
|
||||
- name: Create the unicorn pid directory
|
||||
file: dest=/var/run/unicorn state=directory owner={{ redmine_user }} group={{ redmine_user }} mode=0750
|
||||
|
||||
- name: Install the unicorn startup file for redmine
|
||||
copy: src=redmine.init dest=/etc/init.d/redmine owner=root group=root mode=0755
|
||||
|
||||
- name: Install the unicorn defaults file
|
||||
template: src=unicorn-redmine.default.j2 dest=/etc/default/unicorn-redmine owner=root group=root mode=0644
|
||||
notify: Reload unicorn when needed
|
||||
tags: [ 'ruby', 'redmine', 'unicorn', 'unicorn_init', 'unicorn_conf' ]
|
||||
|
||||
- name: Install the unicorn logrotate file
|
||||
template: src=unicorn-logrotate.j2 dest=/etc/logrotate.d/unicorn-redmine owner=root group=root mode=0644
|
||||
tags: [ 'ruby', 'redmine', 'unicorn', 'unicorn_logrotate', 'unicorn_conf' ]
|
||||
- name: Ensure that the unicorn service is enabled and running on trusty
|
||||
service: name={{ redmine_sysvinit_service_name }} state=started enabled=yes
|
||||
when: ruby_use_unicorn
|
||||
|
||||
- name: Install the unicorn config
|
||||
template: src=unicorn.conf.rb.j2 dest={{ redmine_glob_root_dir }}/{{ redmine_inst_dir }}/config/unicorn.conf.rb owner=root group=root mode=0644
|
||||
when: ruby_use_unicorn
|
||||
notify: Reload unicorn when needed
|
||||
tags: [ 'ruby', 'redmine', 'unicorn', 'unicorn_conf' ]
|
||||
|
||||
- name: Install the needed apache modules
|
||||
apache2_module: name={{ item }} state=present
|
||||
with_items: '{{ unicorn_apache_modules }}'
|
||||
when: ruby_use_unicorn
|
||||
notify: apache2 reload
|
||||
tags: [ 'ruby', 'redmine', 'unicorn' ]
|
||||
when:
|
||||
- ruby_use_unicorn
|
||||
- is_trusty
|
||||
|
||||
- block:
|
||||
- name: Install the unicorn package
|
||||
apt: pkg=unicorn state=present cache_valid_time=1800
|
||||
|
||||
- name: Install a nginx configuration of the unicorn backend
|
||||
template: src=nginx_unicorn.conf dest=/etc/nginx/conf.d/nginx_unicorn.conf
|
||||
notify: Restart nginx
|
||||
|
||||
- name: Ensure that the unicorn service is enabled and running
|
||||
service: name=redmine state=started enabled=yes
|
||||
when: ruby_use_unicorn
|
||||
tags: [ 'ruby', 'redmine', 'unicorn' ]
|
||||
when:
|
||||
- ruby_use_unicorn
|
||||
- is_bionic
|
||||
|
||||
- block:
|
||||
- name: Create the unicorn log directory
|
||||
file: dest={{ unicorn_log_dir }} state=directory owner={{ redmine_user }} group={{ redmine_user }} mode=0750
|
||||
|
||||
- name: Install the unicorn defaults file
|
||||
template: src=unicorn-redmine.default.j2 dest=/etc/default/unicorn-{{ redmine_inst_name }} owner=root group=root mode=0644
|
||||
notify: Reload unicorn when needed
|
||||
|
||||
- name: Install the unicorn logrotate file
|
||||
template: src=unicorn-logrotate.j2 dest=/etc/logrotate.d/unicorn-{{ redmine_inst_name }} owner=root group=root mode=0644
|
||||
|
||||
- name: Install the unicorn config
|
||||
template: src=unicorn.conf.rb.j2 dest={{ redmine_glob_root_dir }}/{{ redmine_inst_dir }}/config/unicorn.conf.rb owner=root group=root mode=0644
|
||||
|
||||
- name: Install the systemd unit that globally manages the unicorn service
|
||||
template: src=systemd_unicorn.service dest={{ redmine_glob_root_dir }}/{{ redmine_inst_dir }}/config/unicorn@.service
|
||||
register: systemd_reload
|
||||
|
||||
- name: Link the systemd unit that globally manages the unicorn service
|
||||
file: src={{ redmine_glob_root_dir }}/{{ redmine_inst_dir }}/config/unicorn@.service dest=/etc/systemd/system/multi-user.target.wants/unicorn@.service state=link
|
||||
|
||||
- name: Reload systemd after the system unit installation
|
||||
systemd: daemon_reload=yes
|
||||
when: systemd_reload is changed
|
||||
|
||||
- name: Ensure that the unicorn service for redmine is started and enabled
|
||||
service: name={{ redmine_systemd_service_name }} state=started enabled=yes
|
||||
ignore_errors: True
|
||||
|
||||
tags: [ 'ruby', 'redmine', 'unicorn' ]
|
||||
when: ruby_use_unicorn
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
upstream unicorn {
|
||||
# fail_timeout=0 means we always retry an upstream even if it failed
|
||||
# to return a good HTTP response (in case the Unicorn master nukes a
|
||||
# single worker for timing out).
|
||||
|
||||
# for UNIX domain socket setups:
|
||||
# server unix:/tmp/.sock fail_timeout=0;
|
||||
|
||||
# for TCP setups, point these to your backend servers
|
||||
{% for i in 0, 4 %}
|
||||
server 127.0.0.1:{{ unicorn_listen_port + i }} fail_timeout=0;
|
||||
{% endfor %}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
[Unit]
|
||||
# You can create multiple unicorn service by linking unicorn@.service to unicorn@appone.service, unicorn@apptwo.service
|
||||
# each application reads its settings from /etc/default/unicorn_appone, /etc/default/unicorn_apptwo
|
||||
Description=Unicorn serving %I app
|
||||
After=syslog.target
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
Type=forking
|
||||
User={{ redmine_user }}
|
||||
Group={{ redmine_group }}
|
||||
WorkingDirectory=/srv/redmine/%I
|
||||
EnvironmentFile=/etc/default/unicorn-%I
|
||||
SyslogIdentifier=unicorn-%I
|
||||
PIDFile={{ unicorn_pid_file }}
|
||||
KillMode=mixed
|
||||
KillSignal=SIGQUIT
|
||||
ExecStart=/usr/bin/bundle exec "${DAEMON} ${DAEMON_OPTS}"
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -1,8 +1,10 @@
|
|||
APP={{ redmine_glob_root_dir }}/{{ redmine_inst_dir }}
|
||||
APP_ROOT={{ redmine_glob_root_dir }}/{{ redmine_inst_dir }}
|
||||
USER={{ redmine_user }}
|
||||
DAEMON=unicorn
|
||||
DAEMON_OPTS="-c $APP/config/unicorn.conf.rb -E production -D -l {{ unicorn_listen_address }}:3999"
|
||||
DAEMON_OPTS="-c {{ redmine_glob_root_dir }}/{{ redmine_inst_dir }}/config/unicorn.conf.rb -E production -D -l {{ unicorn_listen_address }}:3999"
|
||||
NAME=unicorn
|
||||
DESC="Unicorn app for $USER"
|
||||
PID_DIR={{ unicorn_pid_dir }}
|
||||
PID={{ unicorn_pid_file }}
|
||||
RACK_ENV=production
|
||||
|
|
Loading…
Reference in New Issue