Skip to content

Commit

Permalink
Merge pull request #15 from maeda-m/redmine51-ubuntu24
Browse files Browse the repository at this point in the history
Redmine 5.1 + Ubuntu 24.04 に対応する( CI を除く)
  • Loading branch information
maeda-m authored Nov 7, 2024
2 parents 2fe7c84 + 1129975 commit 4cff780
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 69 deletions.
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,37 @@

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

[Redmine 4.2をUbuntu 20.04 LTSにインストールする手順](https://blog.redmine.jp/articles/4_2/install/ubuntu/)

[Redmine 5.1 をUbuntu 24.04 LTSにインストールする手順](https://blog.redmine.jp/articles/5_1/install/ubuntu24/)

## システム構成

* Ansible 5.7.0
* Redmine 4.2
* Ubuntu Server 20.04.4 LTS
* Ansible 2.17.5
* Redmine 5.1
* Ubuntu Server 24.04 LTS
* PostgreSQL
* Apache


## Redmineのインストール手順

インストール直後の Ubuntu 20.04 にログインし以下の操作を行ってください。
インストール直後の Ubuntu Server にログインし以下の操作を行ってください。


### Ansibleとgitのインストール
### Ansibleと必要パッケージのインストール

[Installing Ansible on specific operating systems — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html#installing-ansible-on-ubuntu) を参考にして Ansible をインストールします。

```bash
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install ansible
```
sudo apt-get update

========== Dockerの場合=========
apt-get update
apt-get install -y sudo iproute2
================================
git や [PostgreSQL の操作](https://docs.ansible.com/ansible/latest/collections/community/postgresql/postgresql_db_module.html) で必要なパッケージをインストールします。

sudo apt-get install -y python3-pip libpython2-dev git libssl-dev libpq-dev gcc
sudo pip install ansible\==5.7.0 psycopg2
```bash
sudo apt update
sudo apt install git python3-psycopg2
```

### playbookのダウンロード
Expand All @@ -55,10 +57,13 @@ git clone https://github.com/farend/redmine-ubuntu-ansible.git

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

> [!NOTE]
>
> "BECOME password"にsudoを実行するためのパスワードを入力してください。
```
cd redmine-ubuntu-ansible
ansible-playbook -K -i hosts site.yml
==> "BECOME password"にsudoを実行するためのパスワードを入力してください。
```

10〜20分ほどでインストールが完了します。webブラウザで `http://サーバIPアドレス/redmine` にアクセスしてください。Redmineの画面が表示されるはずです。
Expand Down
12 changes: 7 additions & 5 deletions group_vars/redmine-servers
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ db_passwd_redmine: Must_be_changed!
# ----------------------------------------------------------------------

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

# Redmineのデプロイ先ディレクトリ
redmine_dir: /var/lib/redmine
Expand All @@ -16,12 +16,14 @@ redmine_dir_group: www-data
# Redmineで使用する日本語フォントファイル
redmine_font_path: /usr/share/fonts/truetype/takao-gothic/TakaoPGothic.ttf

# Redmineで使用するlocale
redmine_locale: ja_JP.UTF-8
# Redmine DB で使用する設定
redmine_db_name: redmine
redmine_db_user: redmine
redmine_db_locale: ja_JP.UTF-8

# ダウンロードするRubyのソースコード
ruby_url_dir: https://cache.ruby-lang.org/pub/ruby/2.7
ruby_archive_version: ruby-2.7.4
ruby_url_dir: https://cache.ruby-lang.org/pub/ruby/3.2
ruby_archive_version: ruby-3.2.4
ruby_archive_ext: tar.gz
ruby_archive_name: "{{ ruby_archive_version }}.{{ ruby_archive_ext }}"

Expand Down
13 changes: 2 additions & 11 deletions roles/apache/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,14 @@
group: "{{ redmine_dir_group }}"
recurse: yes

- name: Passengerがインストールされているか確認
- name: PassengerのApache用設定ファイルが存在するか確認
command:
test -f /usr/local/bin/passenger-install-apache2-module
test -f /etc/apache2/conf-available/redmine.conf
register:
result
failed_when: result.rc not in [0, 1]
changed_when: false

- name: Passengerをインストール
become: yes
gem:
name=passenger
user_install=no
environment:
PATH: "/usr/local/bin:{{ ansible_env.PATH }}"
when: result.rc == 1

- name: PassengerのApache用モジュールのインストール
become: yes
command:
Expand Down
4 changes: 2 additions & 2 deletions roles/apache/templates/redmine.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
Require all granted
</Directory>

Alias /redmine /var/lib/redmine/public
Alias /redmine {{ redmine_dir }}/public
<Location /redmine>
PassengerBaseURI /redmine
PassengerAppRoot /var/lib/redmine
PassengerAppRoot {{ redmine_dir }}
</Location>

{{ passenger_snippet_vars.stdout }}
Expand Down
17 changes: 9 additions & 8 deletions roles/pg/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,23 @@
- name: ACLインストール
become: yes
apt:
name='acl'
name: "acl"
when: not result.stat.exists

- name: PostgreSQL ユーザー作成
become: yes
become_user: postgres
postgresql_user:
name=redmine
password={{ db_passwd_redmine }}
name: "{{ redmine_db_user }}"
password: "{{ db_passwd_redmine }}"

- name: PostgreSQL データベース作成
become: yes
become_user: postgres
postgresql_db:
name=redmine
encoding='UTF-8'
lc_collate= {{redmine_locale }}
lc_ctype= {{redmine_locale }}
template='template0'
name: "{{ redmine_db_name }}"
owner: "{{ redmine_db_user }}"
encoding: "UTF-8"
lc_collate: "{{ redmine_db_locale }}"
lc_ctype: "{{ redmine_db_locale }}"
template: "template0"
44 changes: 39 additions & 5 deletions roles/redmine/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
- name: mkdir /var/lib/redmine
become: yes
command:
mkdir -p {{ redmine_dir }}

- name: chown www-data /var/lib/redmine
become: yes
command:
chown {{ redmine_dir_owner }} {{ redmine_dir }}

- name: Redmineのソースコードをチェックアウト
become: yes
subversion:
repo={{ redmine_svn_url }}
dest={{ redmine_dir }}
become_user: "{{ redmine_dir_owner }}"
command:
svn co {{ redmine_svn_url }} {{ redmine_dir }}

- name: database.ymlの作成
become: yes
become_user: "{{ redmine_dir_owner }}"
template:
src=database.yml
dest={{ redmine_dir }}/config/database.yml
Expand All @@ -15,6 +26,7 @@

- name: configuration.ymlの作成
become: yes
become_user: "{{ redmine_dir_owner }}"
template:
src=configuration.yml
dest={{ redmine_dir }}/config/configuration.yml
Expand All @@ -28,10 +40,30 @@
failed_when: result_test_gemfile.rc not in [0, 1]
changed_when: false

- name: gemsパッケージのインストール
- name: gemsパッケージのインストール 1/3
become: yes
become_user: "{{ redmine_dir_owner }}"
template:
src=Gemfile.local
dest={{ redmine_dir }}/Gemfile.local
force=no
when:
result_test_gemfile.rc == 1

- name: gemsパッケージのインストール 2/3
become: yes
command:
bundle config set --local without 'development test'
chdir={{ redmine_dir }}
environment:
PATH: "/usr/local/bin:{{ ansible_env.PATH }}"
when:
result_test_gemfile.rc == 1

- name: gemsパッケージのインストール 3/3
become: yes
command:
bundle install --path vendor/bundle
bundle install
chdir={{ redmine_dir }}
environment:
PATH: "/usr/local/bin:{{ ansible_env.PATH }}"
Expand All @@ -50,6 +82,7 @@

- name: secret tokenの作成
become: yes
become_user: "{{ redmine_dir_owner }}"
command:
bundle exec rake generate_secret_token
chdir={{ redmine_dir }}
Expand All @@ -59,6 +92,7 @@

- name: データベースのマイグレーション
become: yes
become_user: "{{ redmine_dir_owner }}"
command:
bundle exec rake db:migrate
chdir={{ redmine_dir }}
Expand Down
1 change: 1 addition & 0 deletions roles/redmine/templates/Gemfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gem 'passenger', group: :production
4 changes: 2 additions & 2 deletions roles/redmine/templates/database.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
production:
adapter: postgresql
database: redmine
database: "{{ redmine_db_name }}"
host: localhost
username: redmine
username: "{{ redmine_db_user }}"
password: "{{ db_passwd_redmine }}"
encoding: utf8
pool: 5
9 changes: 0 additions & 9 deletions roles/ruby/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,3 @@
make install
chdir={{ work_dir }}/{{ ruby_archive_version }}
when: ruby_test_vars.rc == 1

- name: bundlerのインストール
become: yes
gem:
name=bundler
user_install=no
version=1.17.3
environment:
PATH: "/usr/local/bin:{{ ansible_env.PATH }}"
20 changes: 9 additions & 11 deletions roles/system/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# PostgreSQLでlc_collateとlc_ctypeに ja_JP.UTF-8 を指定するために必要
- name: apt-get update
- name: apt update
become: yes
apt:
update_cache=yes
cache_valid_time=86400
- name: set locale to ja_JP.UTF-8 1/2
become: yes
apt:
name='locales'
- name: set locale to ja_JP.UTF-8 2/2
become: yes
command: localectl set-locale LANG={{ redmine_db_locale }}

# Redmine を動かすために必要なパッケージのインストール
- name: RubyとPassengerのビルドに必要な開発ツールやヘッダファイルのインストール
become: yes
apt:
Expand All @@ -15,16 +23,6 @@
apt:
name='postgresql,libpq-dev'

- name: create locale ja_JP.UTF-8
become: yes
locale_gen:
name: "{{ redmine_locale }}"

- name: set locale to ja_JP.UTF-8
become: yes
command: update-locale LANG={{ redmine_locale }}
when: ansible_env.LANG | default('') != [ redmine_locale ]

- name: Apacheとヘッダファイルのインストール
become: yes
apt:
Expand Down

0 comments on commit 4cff780

Please sign in to comment.