Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
193 lines (193 sloc) 6.55 KB
---
- name: add redmine user
user:
name: "{{ redmine_user }}"
system: true
- name: install dependency packages
apt:
name: "{{ redmine_dependency_packages }}"
- name: create install directory
file:
path: "{{ redmine_home }}"
owner: "{{ redmine_user }}"
group: "{{ redmine_user }}"
state: directory
mode: "0755"
- name: setup database(MySQL/Postgresql)
include_tasks: "database/{{ redmine_db_cfg.production.adapter }}.yml"
when:
- (redmine_db_cfg.production.adapter == 'mysql2' or redmine_db_cfg.production.adapter == 'postgresql')
- (redmine_db_cfg.production.host == 'localhost' or redmine_db_cfg.production.host == '127.0.0.1')
- name: setup database(SQLite)
include_tasks: "database/{{ redmine_db_cfg.production.adapter }}.yml"
when: redmine_db_cfg.production.adapter == 'sqlite3'
- block:
- name: checkout Redmine
git:
repo: "https://github.com/redmine/redmine.git"
dest: "{{ redmine_home }}"
version: "{{ redmine_version }}"
register: git_result
- name: create bundler setting directory
file:
path: "{{ redmine_home }}/.bundle"
state: directory
mode: "0755"
- name: copy bundler setting file
copy:
src: config
dest: "{{ redmine_home }}/.bundle/config"
mode: "0644"
- name: set redmine database config variable
set_fact:
redmine_db_cfg:
production: "{{ redmine_db_cfg.production }}"
development: "{{ redmine_db_cfg.production }}"
- name: create database config file
template:
src: database.yml.j2
dest: "{{ redmine_home }}/config/database.yml"
mode: "0644"
register: db_config_result
- name: create Redmine config file
template:
src: configuration.yml.j2
dest: "{{ redmine_home }}/config/configuration.yml"
mode: "0644"
notify: restart redmine
- name: execute bundle update
command: bundle update
args:
chdir: "{{ redmine_home }}"
when: git_result is changed
- name: create secret token
command: bundle exec rake generate_secret_token
args:
chdir: "{{ redmine_home }}"
creates: "{{ redmine_home }}/config/initializers/secret_token.rb"
register: generate_token_result
- name: migrate database
command: bundle exec rake db:migrate
args:
chdir: "{{ redmine_home }}"
notify: restart redmine
when: git_result is changed or db_config_result is changed
- name: load default data
command: bundle exec rake redmine:load_default_data
args:
chdir: "{{ redmine_home }}"
when: generate_token_result is changed
- name: install themes
git:
repo: "{{ item.repo }}"
dest: "{{ redmine_theme_dir }}/{{ item.directory if item.directory is defined else item.name }}"
version: master
loop: "{{ redmine_themes | default([]) }}"
- name: install plugin from git
git:
repo: "{{ item.repo }}"
dest: "{{ redmine_plugin_dir }}/{{ item.directory if item.directory is defined else 'redmine_' + item.name }}"
version: "{{ item.version | default('master') }}"
loop: "{{ redmine_plugins | selectattr('repo', 'defined') | list }}"
notify: restart redmine
register: plugin_install_from_git_result
- name: download plugin archive file
get_url:
url: "{{ item.url }}"
dest: "{{ redmine_home }}/tmp/{{ item.url | basename }}"
loop: "{{ redmine_plugins | selectattr('url', 'defined') | list }}"
- name: unarchive downloaded plugin archive file
unarchive:
src: "{{ redmine_home }}/tmp/{{ item.url | basename }}"
dest: "{{ redmine_plugin_dir }}"
remote_src: true
mode: "0755"
loop: "{{ redmine_plugins | selectattr('url', 'defined') | list }}"
notify: restart redmine
register: plugin_install_from_url_result
- name: unarchive plugin archive file
unarchive:
src: "{{ item.file }}"
dest: "{{ redmine_plugin_dir }}"
mode: "0755"
loop: "{{ redmine_plugins | selectattr('file', 'defined') | list }}"
notify: restart redmine
register: plugin_install_from_file_result
- name: install plugin dependency packages
apt:
name: "{{ item.1 }}"
loop: "{{ redmine_plugins | subelements('required_packages', {'skip_missing': True}) }}"
notify: restart redmine
become: true
become_user: root
- block:
- name: execute bundle install
command: bundle install
args:
chdir: "{{ redmine_home }}"
- name: execute bundle exec rake db:migrate
command: bundle exec rake db:migrate
args:
chdir: "{{ redmine_home }}"
- name: execute bundle exec rake redmine:plugins:migrate
command: bundle exec rake redmine:plugins:migrate
args:
chdir: "{{ redmine_home }}"
- name: execute plugin post install action
shell: "{{ item.post_install_action }}"
args:
chdir: "{{ redmine_home }}"
warn: false
loop: "{{ redmine_plugins | selectattr('post_install_action', 'defined') | list }}"
when: plugin_install_from_git_result is changed or plugin_install_from_url_result is changed or plugin_install_from_file_result is changed
- name: create settings file
template:
src: settings.rb.j2
dest: "{{ redmine_home }}/tmp/settings.rb"
mode: "0644"
register: result
- name: update redmine settings
shell: "bundle exec rails console <{{ redmine_home }}/tmp/settings.rb"
args:
chdir: "{{ redmine_home }}"
- name: remove setting file
file:
path: "{{ redmine_home }}/tmp/settings.rb"
state: absent
- name: create puma config file
template:
src: puma.rb.j2
dest: "{{ redmine_home }}/config/puma.rb"
mode: "0644"
notify: restart redmine
become: true
become_user: "{{ redmine_user }}"
environment:
RAILS_ENV: "{{ redmine_mode }}"
REDMINE_LANG: "{{ redmine_lang }}"
- name: set cron variable
cronvar:
name: RAILS_ENV
value: "{{ redmine_mode }}"
user: "{{ redmine_user }}"
- name: set/unset issue reminder mail cron job
import_tasks: cron/send_reminders.yml
- name: set/unset issue receive mail(imap) cron job
import_tasks: cron/receive_imap.yml
- name: set/unset issue receive mail(pop3) cron job
import_tasks: cron/receive_pop3.yml
- name: set/unset plugins cron job
import_tasks: cron/plugin.yml
- name: create redmine systemd unit file
template:
src: redmine.service.j2
dest: /lib/systemd/system/redmine.service
mode: "0644"
notify: restart redmine
register: result
- name: Redmine is active and enable on system startup
systemd:
daemon_reload: true
name: redmine
state: started
enabled: true