Skip to content
This repository has been archived by the owner on Feb 14, 2022. It is now read-only.

Commit

Permalink
Redmine 3.2対応 + データベースをPostgreSQLに変更
Browse files Browse the repository at this point in the history
  • Loading branch information
vividtone committed Dec 7, 2015
1 parent a2d8e38 commit b21b6a0
Show file tree
Hide file tree
Showing 14 changed files with 185 additions and 133 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# redmine-centos7-mariadb-ansible
# redmine-centos7-ansible


最小構成でインストールしたCentOSにRedmineを自動インストールするためのAnsibleプレイブックです。

コマンド5個実行するだけで、あとはしばらく放置すればインストールが完了します。


## 概要
## 概要

Ansibleを使ってRedmineを自動インストールするためのプレイブックです。以下のwebサイトで紹介されている手順におおむね準拠しています。

[Redmine 3.1をCentOS 7.1にインストールする手順](http://blog.redmine.jp/articles/3_1/installation_centos/)
[Redmine 3.2をCentOS 7.1にインストールする手順](http://blog.redmine.jp/articles/3_2/install/centos/)


## システム構成

* Redmine 3.1
* Redmine 3.2
* CentOS 7
* MariaDB
* PostgreSQL
* Apache


Expand All @@ -36,23 +36,23 @@ yum install -y ansible git
### playbookのダウンロード

```
git clone https://github.com/farend/redmine-centos7-mariadb-ansible.git
git clone https://github.com/farend/redmine-centos7-ansible.git
```

### MariaDBに設定するパスワードの変更
### PostgreSQLに設定するパスワードの変更

ファイル `group_vars/redmine-servers` をエディタで開き、 `db_passwd_root``db_passwd_redmine` を適当な内容に変更してください。これらはそれぞれ、MariaDBの root ユーザーとRedmine用のユーザー db_redmine に設定されるパスワードです。
ダウンロードしたプレイブック内のファイル `group_vars/redmine-servers` をエディタで開き、 `db_passwd_redmine` を適当な内容に変更してください。これはPostgreSQLのRedmine用ユーザー redmine に設定されるパスワードです。

### playbook実行

下記コマンドを実行してください。Redmineの自動インストールが開始されます。

```
cd redmine-centos7-mariadb-ansible
cd redmine-centos-ansible
ansible-playbook -i hosts site.yml
```

10分前後でインストールが完了します。webブラウザで `http://サーバIPアドレス` にアクセスしてください。Redmineの画面が表示されるはずです。
10〜20分ほどでインストールが完了します。webブラウザで `http://サーバIPアドレス` にアクセスしてください。Redmineの画面が表示されるはずです。


## ライセンス
Expand Down
19 changes: 12 additions & 7 deletions group_vars/redmine-servers
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
# ----------------------------------------------------------------------
# MariaDBのユーザーに設定するパスワード。変更推奨。
# root
db_passwd_root: Must_be_changed!

# user_redmine (RedmineからMariaDBに接続するときのユーザー)
# データベースの redmine ユーザーのパスワード (変更推奨)
db_passwd_redmine: Must_be_changed!
# ----------------------------------------------------------------------

# Redmineのチェックアウト元URL
redmine_svn_url: http://svn.redmine.org/redmine/branches/3.1-stable
redmine_svn_url: http://svn.redmine.org/redmine/branches/3.2-stable

# Redmineのデプロイ先URL
# Redmineのデプロイ先ディレクトリ
redmine_dir: /var/lib/redmine

# Redmineのデプロイ先ディレクトリのオーナー:グループ
redmine_dir_owner: apache:apache

# Redmineで使用する日本語フォントファイル
redmine_font_path: /usr/share/fonts/truetype/takao-gothic/TakaoPGothic.ttf

# pg_hba.confのパス
pg_hba_conf_path: /var/lib/pgsql/data/pg_hba.conf

# ダウンロードするRubyのソースコード
ruby_url_dir: https://cache.ruby-lang.org/pub/ruby/2.2
ruby_archive_version: ruby-2.2.3
Expand Down
22 changes: 9 additions & 13 deletions roles/apache/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
- name: Apacheのインストール
sudo: yes
yum: name='httpd,httpd-devel'

- name: Redmineディレクトリ以下のオーナーを変更
sudo: yes
command:
chown -R apache:apache {{ redmine_dir }}
chown -R {{ redmine_dir_owner }} {{ redmine_dir }}

- name: Passengerがインストールされているか確認
command:
Expand All @@ -17,8 +13,9 @@

- name: Passengerをインストール
sudo: yes
command:
gem install passenger --no-rdoc --no-ri
gem:
name=passenger
user_install=no
environment:
PATH: "/usr/local/bin:{{ ansible_env.PATH }}"
when: result.rc == 1
Expand All @@ -44,13 +41,12 @@
src=redmine.conf
dest=/etc/httpd/conf.d/redmine.conf

- name: DocumentRootをRedmineのpublicに変更
- name: Redmineに /redmine でアクセスするためのシンボリックリンク作成
sudo: yes
lineinfile:
dest=/etc/httpd/conf/httpd.conf
backup=yes
regexp='^DocumentRoot .*'
line='DocumentRoot "/var/lib/redmine/public"'
file:
state=link
src={{ redmine_dir }}/public
dest=/var/www/html/redmine

- name: httpdの再起動
sudo: yes
Expand Down
2 changes: 2 additions & 0 deletions roles/apache/templates/redmine.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ PassengerHighPerformance on
PassengerStatThrottleRate 10
PassengerSpawnMethod smart
PassengerFriendlyErrorPages off

RackBaseURI /redmine
58 changes: 0 additions & 58 deletions roles/mariadb/tasks/main.yml

This file was deleted.

23 changes: 0 additions & 23 deletions roles/mariadb/templates/my.cnf

This file was deleted.

11 changes: 11 additions & 0 deletions roles/pg/files/pg_hba_conf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- pg_hba.conf.org 2015-12-06 15:49:05.282188570 +0900
+++ pg_hba.conf 2015-12-06 15:33:01.377197287 +0900
@@ -71,6 +71,8 @@
# "host" records. In that case you will also need to make PostgreSQL
# listen on a non-local interface via the listen_addresses
# configuration parameter, or via the -i or -h command line switches.
+host redmine redmine 127.0.0.1/32 md5
+host redmine redmine ::1/128 md5



55 changes: 55 additions & 0 deletions roles/pg/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
- name: PostgreSQL initdb
command:
postgresql-setup initdb
register:
result
failed_when: result.rc not in [0, 1]
changed_when: result.rc == 0

- name: pg_hba.confにredmine用設定が存在するか確認
sudo: yes
command:
grep redmine {{ pg_hba_conf_path }}
register:
result_pg_hba
failed_when: result_pg_hba.rc not in [0, 1]
changed_when: false

- name: pg_hba.conf設定変更用パッチを配置
sudo: yes
copy:
src=pg_hba_conf.patch
dest={{ work_dir }}
when:
result_pg_hba.rc == 1

- name: pg_hba.confにredmine用設定を追加
sudo: yes
shell:
patch -tNp0 {{ pg_hba_conf_path }} < {{ work_dir }}/pg_hba_conf.patch
when:
result_pg_hba.rc == 1

- name: PostgreSQL起動
sudo: yes
service:
name=postgresql
state=restarted
enabled=yes

- name: PostgreSQL ユーザー作成
sudo: yes
sudo_user: postgres
postgresql_user:
name=redmine
password={{ db_passwd_redmine }}

- name: PostgreSQL データベース作成
sudo: yes
sudo_user: postgres
postgresql_db:
name=redmine
encoding='UTF-8'
lc_collate='ja_JP.UTF-8'
lc_ctype='ja_JP.UTF-8'
template='template0'
42 changes: 37 additions & 5 deletions roles/redmine/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
- name: ImageMagickと日本語フォント(IPA Pゴシック)のインストール
sudo: yes
yum: name='ImageMagick,ImageMagick-devel,ipa-pgothic-fonts'

- name: Redmineのソースコードをチェックアウト
sudo: yes
subversion:
Expand All @@ -13,12 +9,24 @@
template:
src=database.yml
dest={{ redmine_dir }}/config/database.yml
force=no
register:
result_database_yml

- name: configuration.ymlの作成
sudo: yes
template:
src=configuration.yml
dest={{ redmine_dir }}/config/configuration.yml
force=no

- name: Gemfile.lockが存在するか確認
command:
test -f {{ redmine_dir }}/Gemfile.lock
register:
result_test_gemfile
failed_when: result_test_gemfile.rc not in [0, 1]
changed_when: false

- name: gemsパッケージのインストール
sudo: yes
Expand All @@ -27,6 +35,18 @@
chdir={{ redmine_dir }}
environment:
PATH: "/usr/local/bin:{{ ansible_env.PATH }}"
when:
result_test_gemfile.rc == 1

- name: gemsパッケージのアップデート
sudo: yes
command:
bundle update
chdir={{ redmine_dir }}
environment:
PATH: "/usr/local/bin:{{ ansible_env.PATH }}"
when:
result_test_gemfile.rc == 0

- name: secret tokenの作成
sudo: yes
Expand All @@ -49,12 +69,14 @@
- name: デフォルトデータ(日本語)をロード
sudo: yes
command:
/usr/local/bin/bundle exec rake redmine:load_default_data
bundle exec rake redmine:load_default_data
chdir={{ redmine_dir }}
environment:
PATH: "/usr/local/bin:{{ ansible_env.PATH }}"
RAILS_ENV: production
REDMINE_LANG: ja
when:
result_database_yml|changed

- name: farend_basicテーマのダウンロード
sudo: yes
Expand All @@ -70,6 +92,8 @@
environment:
PATH: "/usr/local/bin:{{ ansible_env.PATH }}"
RAILS_ENV: production
when:
result_database_yml|changed

- name: デフォルトの言語を日本語に変更
sudo: yes
Expand All @@ -79,6 +103,8 @@
environment:
PATH: "/usr/local/bin:{{ ansible_env.PATH }}"
RAILS_ENV: production
when:
result_database_yml|changed

- name: ユーザー名の表示形式を「姓 名」に変更
sudo: yes
Expand All @@ -88,6 +114,8 @@
environment:
PATH: "/usr/local/bin:{{ ansible_env.PATH }}"
RAILS_ENV: production
when:
result_database_yml|changed

- name: 添付ファイルとリポジトリのエンコーディングを設定
sudo: yes
Expand All @@ -97,6 +125,8 @@
environment:
PATH: "/usr/local/bin:{{ ansible_env.PATH }}"
RAILS_ENV: production
when:
result_database_yml|changed

- name: 添付ファイルのサムネイルを表示
sudo: yes
Expand All @@ -106,3 +136,5 @@
environment:
PATH: "/usr/local/bin:{{ ansible_env.PATH }}"
RAILS_ENV: production
when:
result_database_yml|changed
Loading

0 comments on commit b21b6a0

Please sign in to comment.