AnsibleでCentOS7上にGROWIを立てる
環境
ansible 2.9.3
ターゲットノード:CentOS Linux release 7.7.1908 (Core)
Growiって何
Markdown で書ける wikiらしいです。
高機能な使い方ができるぽい?ので個人で使う場合もいいかもです。
https://docs.growi.org/ja/guide/
ディレクトリ構造
|-- docker_playbook.yml
|-- files
| `-- docker-compose.yml
`-- hosts
docker_playbook.yml
docker_playbook.yml
---
- hosts: growi
tasks:
- name: upgrade all packages
yum:
name: '*'
state: latest
- name: yum install for docokertools
yum:
name: device-mapper-persistent-data,lvm2,yum-utils,git
state: latest
update_cache: yes
- name: add docker repo
tags: dockerinst
shell: "yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo"
args:
chdir: "/etc/yum.repos.d"
creates: docker-ce.repo
- name: yum install docker ce
tags: dockerinst
yum:
name: docker-ce,docker-ce-cli,containerd.io
state: latest
update_cache: yes
- name: Make sure a service is running
tags: dockerinst
systemd:
state: started
enabled: yes
name: docker
- name: mkdir /growi/
tags: docker_settings
file:
path: /growi/
state: directory
owner: root
group: root
mode: 0755
- name: git clone groei-docker-compose.git
git:
repo: https://github.com/weseek/growi-docker-compose.git
dest: /growi/
force: yes
- name: copy docker-comopose.yml
tags: files_copy
copy:
src: ./files/docker-compose.yml
dest: /growi/
- name: docker-comopose install
tags: docker_settings
shell: "curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose"
- name: docker-comopose chmod
tags: docker_settings
shell: "chmod +x /usr/local/bin/docker-compose"
docker-compose.yml
|-- docker_playbook.yml
|-- files
| `-- docker-compose.yml
`-- hosts
docker_playbook.yml
---
- hosts: growi
tasks:
- name: upgrade all packages
yum:
name: '*'
state: latest
- name: yum install for docokertools
yum:
name: device-mapper-persistent-data,lvm2,yum-utils,git
state: latest
update_cache: yes
- name: add docker repo
tags: dockerinst
shell: "yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo"
args:
chdir: "/etc/yum.repos.d"
creates: docker-ce.repo
- name: yum install docker ce
tags: dockerinst
yum:
name: docker-ce,docker-ce-cli,containerd.io
state: latest
update_cache: yes
- name: Make sure a service is running
tags: dockerinst
systemd:
state: started
enabled: yes
name: docker
- name: mkdir /growi/
tags: docker_settings
file:
path: /growi/
state: directory
owner: root
group: root
mode: 0755
- name: git clone groei-docker-compose.git
git:
repo: https://github.com/weseek/growi-docker-compose.git
dest: /growi/
force: yes
- name: copy docker-comopose.yml
tags: files_copy
copy:
src: ./files/docker-compose.yml
dest: /growi/
- name: docker-comopose install
tags: docker_settings
shell: "curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose"
- name: docker-comopose chmod
tags: docker_settings
shell: "chmod +x /usr/local/bin/docker-compose"
docker-compose.yml
別サーバからアクセスさせたい為、公式ドキュメントに記載の通り初期設定からportsの部分を編集します。
version: '3'
services:
app:
build:
context: .
dockerfile: ./Dockerfile
ports:
- 3000:3000 # localhost only by default
links:
- mongo:mongo
- elasticsearch:elasticsearch
depends_on:
- mongo
- elasticsearch
environment:
- MONGO_URI=mongodb://mongo:27017/growi
- ELASTICSEARCH_URI=http://elasticsearch:9200/growi
- PASSWORD_SEED=changeme
# - FILE_UPLOAD=mongodb # activate this line if you use MongoDB GridFS rather than AWS
# - FILE_UPLOAD=local # activate this line if you use local storage of server rather than AWS
# - MATHJAX=1 # activate this line if you want to use MathJax
# - PLANTUML_URI=http:// # activate this line and specify if you use your own PlantUML server rather than public plantuml.com
# - HACKMD_URI=http:// # activate this line and specify HackMD server URI which can be accessed from GROWI client browsers
# - HACKMD_URI_FOR_SERVER=http://hackmd:3000 # activate this line and specify HackMD server URI which can be accessed from this server container
# - FORCE_WIKI_MODE='public' # activate this line to force wiki public mode
# - FORCE_WIKI_MODE='private' # activate this line to force wiki private mode
command: "dockerize
-wait tcp://mongo:27017
-wait tcp://elasticsearch:9200
-timeout 60s
npm run server:prod"
restart: unless-stopped
volumes:
- growi_data:/data
mongo:
image: mongo:3.6
restart: unless-stopped
volumes:
- mongo_configdb:/data/configdb
- mongo_db:/data/db
elasticsearch:
build:
context: ./elasticsearch
dockerfile: ./Dockerfile
environment:
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms256m -Xmx256m" # increase amount if you have enough memory
ulimits:
memlock:
soft: -1
hard: -1
restart: unless-stopped
volumes:
- es_data:/usr/share/elasticsearch/data
- ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
volumes:
growi_data:
mongo_configdb:
mongo_db:
es_data:
hosts
ansibleのインベントリなので必要に応じて書き換えてください。
[growi]
192.168.1.107 ansible_user=root ansible_password=password
実行する
# ansible-playbook -i hosts docker_playbook.yml
実行後
# ansible-playbook -i hosts docker_playbook.yml
対象のサーバへssh後docker-compose up -dします。
# cd /growi/
# docker-compose up -d
Author And Source
この問題について(AnsibleでCentOS7上にGROWIを立てる), 我々は、より多くの情報をここで見つけました https://qiita.com/sicksixrock66/items/b6c2b1e2b5fe4d1f1fc1著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .