Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
183 lines (182 sloc) 6.25 KB
---
- name: add redmine user
user:
name: "{{ redmine_user }}"
system: yes
- 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
- 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
- name: copy bundler setting file
copy:
src: config
dest: "{{ redmine_home }}/.bundle/config"
- 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"
register: db_config_result
- name: create Redmine config file
template:
src: configuration.yml.j2
dest: "{{ redmine_home }}/config/configuration.yml"
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: customize language file
import_tasks: customize_lang.yml
when: redmine_customize_language is defined
- 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
with_items: "{{ redmine_themes }}"
- 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') }}"
with_items: "{{ 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 }}"
with_items: "{{ 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: yes
with_items: "{{ 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 }}"
with_items: "{{ redmine_plugins|selectattr('file', 'defined')|list }}"
notify: restart redmine
register: plugin_install_from_file_result
- name: install plugin dependency packages
apt:
name: "{{ item.1 }}"
with_subelements:
- "{{ redmine_plugins|selectattr('required_packages', 'defined')|list }}"
- required_packages
notify: restart redmine
become: yes
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 }}"
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"
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"
notify: restart redmine
become: yes
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
notify: restart redmine
register: result
- name: Redmine is active and enable on system startup
systemd:
daemon_reload: yes
name: redmine
state: started
enabled: yes