Skip to content

Commit

Permalink
[provisioning] provision配下を公開用に変更した (#175)
Browse files Browse the repository at this point in the history
* remove: benchをcliモードに切り替える

* remove: portal files

* remove:packer files

* feat: ansible files

* remove: unused file

* cpu並列数を変更

* 不要な設定の削除

* Vagrantとplaybook関連の依存修正

* ビルドの並列数を環境変数から決めるようにした

* Vagrantfileの修正

* docs: README追記

* remove:不要ファイル削除

* docs: README追記

* docker-compose.yaml path修正

Co-authored-by: yuya_mizuki <[email protected]>
  • Loading branch information
mikiya771 and yuya-mizuki771 authored Sep 18, 2020
1 parent 63fef4d commit 02cddc4
Show file tree
Hide file tree
Showing 30 changed files with 94 additions and 424 deletions.
57 changes: 57 additions & 0 deletions provisioning/ansible/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# isucon10-provisioning

ansible 2.9.13で動作確認しています

## playbooks
- bench.yaml
- ベンチマーカーがセットアップされます
- competitor.yaml
- 競技者に提供された各種言語実装がセットアップされます
- allinone.yaml
- 各種言語実装に加えてベンチマーカーのセットアップもされます(.gitファイルや,中間生成ファイルの削除はおこなわれません)

## Vagrantを利用して,環境をセットアップする

本Vagrantファイルは1台構成で,allinone.yamlを実行した結果を提供しています
別の,設定を利用したい場合は,
- Vagrant ファイルの書き換え
ansible.playbook = "allinone.yaml"
- inventory/hostsの書き換え
を行ってから,下記の操作を行ってください.

### 初回構築

下記コマンドによって,VMを一度破棄して新しく作り直します
```
make vagrant/init
```

### ファイル初期化/再構築

ansibleの実行中に,通信環境エラーなどが起きた場合,下記のコマンドで再実行できます
```
vagrant provision
```


## サーバーへのprovisionning

inventory/hostsの該当セクションを書き換えて,ansible playbookを実行してください.

### ベンチマーカーサーバー

```
ansible-playbook bench.yaml -i inventory/hosts
```

### 競技用サーバー

```
ansible-playbook competitor.yaml -i inventory/hosts
```

### ベンチつき競技用サーバー

```
ansible-playbook allinone.yaml -i inventory/hosts
```
6 changes: 3 additions & 3 deletions provisioning/ansible/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Vagrant.configure("2") do |config|
vb.gui = true

# Customize the amount of memory on the VM:
vb.cpus = 4
vb.cpus = 2
vb.memory = "4096"
end
#
Expand All @@ -71,8 +71,8 @@ Vagrant.configure("2") do |config|
SHELL
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provision "ansible" do |ansible|
ansible.playbook = "competitor.yaml"
ansible.inventory_path = "hosts.yaml"
ansible.playbook = "allinone.yaml"
ansible.inventory_path = "inventory/hosts"
ansible.limit = 'all'
ansible.verbose = "v"
# ansible.raw_arguments = "--vault-password-file=.vault_password"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
- hosts: all
- hosts: allinone
become: yes
become_user: root
roles:
- role: common
- role: langs
- role: web-bootstrap
- role: web-php
- role: web-go
- role: web-node
- role: web-perl
- role: web-python
- role: web-rust
- role: web-ruby
- role: web-rust
- role: web-deno
- role: web-php
- role: web-perl
- role: web-python
- role: web-prepare
- role: remove
- role: bench
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
- hosts: all
- hosts: bench
become: yes
become_user: root
roles:
- role: common
- role: langs
- role: web-bootstrap
- role: web-go
- role: web-prepare
- role: bench
11 changes: 10 additions & 1 deletion provisioning/ansible/competitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,14 @@
roles:
- role: common
- role: langs
- role: web
- role: web-bootstrap
- role: web-go
- role: web-node
- role: web-ruby
- role: web-rust
- role: web-deno
- role: web-php
- role: web-perl
- role: web-python
- role: web-prepare
- role: remove
7 changes: 0 additions & 7 deletions provisioning/ansible/development.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions provisioning/ansible/hosts.yaml

This file was deleted.

4 changes: 4 additions & 0 deletions provisioning/ansible/inventory/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[bench]
[competitor]
[allinone]
192.168.33.10
6 changes: 0 additions & 6 deletions provisioning/ansible/multistage-bench.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions provisioning/ansible/multistage-lang.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions provisioning/ansible/roles/bench/files/.gitconfig

This file was deleted.

1 change: 0 additions & 1 deletion provisioning/ansible/roles/bench/files/env.sh

This file was deleted.

18 changes: 0 additions & 18 deletions provisioning/ansible/roles/bench/files/isuumo.supervisor.service

This file was deleted.

87 changes: 1 addition & 86 deletions provisioning/ansible/roles/bench/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
become: yes
become_user: isucon
command: curl -X POST http://localhost/initialize
- name: Copy GitConfig
copy:
src: "{{ item }}"
dest: "/home/isucon/.gitconfig"
owner: "isucon"
group: "isucon"
mode: "0644"
with_items:
- .gitconfig

- name : Snapshot isucon10
become: yes
Expand All @@ -31,82 +22,6 @@
environment:
PATH: "/home/isucon/local/go/bin:/home/isucon/local/node/bin:/home/isucon/local/ruby/bin:/home/isucon/local/python/bin:/home/isucon/local/perl/bin:/home/isucon/local/php/bin:/home/isucon/.cargo/bin:/home/isucon/.deno/bin:/home/isucon/bin:/home/isucon/.local/bin:/usr/bin:/sbin:/bin"
shell: |
mkdir -p ~/.ssh && ssh-keyscan github.com > ~/.ssh/known_hosts && make && rm ~/.gitconfig
make
- name: Disable Unused Services
become: yes
become_user: root
shell: |
systemctl disable isucon-go && \
systemctl disable mysql && \
systemctl disable nginx
- name: Check isucon10-portal
become: no
stat:
path: "/home/isucon/portal"
register: chk_file

- name: Delete isucon10-portal if exists
become: yes
become_user: root
file:
path: /home/isucon/poratl
state: absent
when: chk_file.stat.exists

- name: Clone isucon10-portal
become: no
git:
repo: [email protected]:isucon/isucon10-portal.git
version: master
dest: /tmp/isucon10-portal
accept_hostkey: yes

- name: Chgroup sisucon10-portal repo
become: yes
become_user: root
file:
path: /tmp/isucon10-portal
state: directory
owner: isucon
group: isucon
recurse: yes

- name: Deploy isucon10-portal
become: yes
become_user: isucon
command: mv /tmp/isucon10-portal /home/isucon/portal

- name: Make Supervisor
become: yes
become_user: isucon
args:
chdir: /home/isucon/portal/supervisor
environment:
PATH: "/home/isucon/local/go/bin:/home/isucon/local/node/bin:/home/isucon/local/ruby/bin:/home/isucon/local/python/bin:/home/isucon/local/perl/bin:/home/isucon/local/php/bin:/home/isucon/.cargo/bin:/home/isucon/.deno/bin:/home/isucon/bin:/home/isucon/.local/bin:/usr/bin:/sbin:/bin"
shell: |
cargo build --release
- name: Copy env.sh for supervisor
become: yes
become_user: isucon
copy:
src: "env.sh"
dest: /home/isucon/portal
- name: Copy service file
copy:
src: "{{ item }}"
dest: "/etc/systemd/system"
owner: "root"
group: "root"
mode: "0644"
with_items:
- isuumo.supervisor.service
- name: Start "supevisor"
systemd:
daemon_reload: "yes"
name: "isuumo.supervisor"
state: "stopped"
enabled: "yes"
4 changes: 2 additions & 2 deletions provisioning/ansible/roles/langs/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
--enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-mbregex
--enable-mbstring --enable-pcntl --enable-sockets --with-curl --enable-zip
environment:
PHP_BUILD_EXTRA_MAKE_ARGUMENTS: "-j 4"
PHP_BUILD_EXTRA_MAKE_ARGUMENTS: "-j {{ ansible_processor_vcpus }}"

- name: Add PATH for PHP
become: yes
Expand All @@ -82,7 +82,7 @@
- name: Install perl v5.32.0
become: yes
become_user: isucon
command: /tmp/xbuild/perl-install 5.32.0 /home/isucon/local/perl -- -Duselongdouble -j 4
command: /tmp/xbuild/perl-install 5.32.0 /home/isucon/local/perl -- -Duselongdouble -j {{ ansible_processor_vcpus }}

- name: Add PATH for perl
become: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ events {
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format with_time '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time';
access_log /var/log/nginx/access.log with_time;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

server {
listen 80 default_server;
Expand Down

This file was deleted.

4 changes: 0 additions & 4 deletions provisioning/packer/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions provisioning/packer/Dockerfile

This file was deleted.

23 changes: 0 additions & 23 deletions provisioning/packer/Makefile

This file was deleted.

7 changes: 0 additions & 7 deletions provisioning/packer/docker-compose-img.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions provisioning/packer/docker-compose-ssh.yaml

This file was deleted.

Loading

0 comments on commit 02cddc4

Please sign in to comment.