Skip to content

Commit

Permalink
Provisioning/ansible/add languages (#134)
Browse files Browse the repository at this point in the history
* feat: 多言語参考実装に対応

* feat: perl longdouble対応

* feat: packerを2段階で実施できるようにした (#142)

* feat: packer 1.6.0対応と高速化 (#144)

* fix: packer fix

* chore: ansible高速化

* feat: perlのansible追加 (#145)

* wip: perl追加

* feat: perl のpackage installを追加

* feat: add isuumo perl setting

* fix: password (#150)

* feat: ruby settings (#148)

Co-authored-by: yuya_mizuki <[email protected]>

* feature:deno (#149)

* fix: ruby service name

* fix: install user

* fix: cartonを使わないように修正,不要なchownを削除 (#151)

* fix: deno

* fix: ruby image

Co-authored-by: yuya_mizuki <[email protected]>
Co-authored-by: Katsuya Miyachi <[email protected]>
  • Loading branch information
3 people authored Sep 10, 2020
1 parent 29934c2 commit eba6d20
Show file tree
Hide file tree
Showing 24 changed files with 555 additions and 124 deletions.
4 changes: 2 additions & 2 deletions provisioning/ansible/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ Vagrant.configure("2") do |config|
vb.gui = true

# Customize the amount of memory on the VM:
vb.cpus = 2
vb.memory = "2048"
vb.cpus = 4
vb.memory = "4096"
end
#
# View the documentation for the provider you are using for more
Expand Down
6 changes: 6 additions & 0 deletions provisioning/ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
[defaults]
private_key_file=~/.ssh/id_rsa
callback_whitelist = profile_tasks


[ssh_connection]
pipeline = false
ssh_args = -o ControlMaster=auto -o ControlPersist=300s
2 changes: 1 addition & 1 deletion provisioning/ansible/competitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
- role: common
- role: langs
- role: web
- role: remove
# - role: remove
6 changes: 6 additions & 0 deletions provisioning/ansible/multistage-bench.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- hosts: all
become: yes
become_user: root
roles:
- role: web
- role: bench
6 changes: 6 additions & 0 deletions provisioning/ansible/multistage-competitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- hosts: all
become: yes
become_user: root
roles:
- role: web
- role: remove
6 changes: 6 additions & 0 deletions provisioning/ansible/multistage-lang.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- hosts: all
become: yes
become_user: root
roles:
- role: common
- role: langs
4 changes: 2 additions & 2 deletions provisioning/ansible/roles/bench/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
args:
chdir: /home/isucon/isucon10-qualify/initial-data/
environment:
PATH: "/home/isucon/bin:/home/isucon/.local/bin:/usr/local/node/bin:/usr/local/python/bin:/usr/local/go/bin:/home/isucon/go/bin:/usr/local/bin:/usr/bin:/bin"
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: |
go build -o ./make_verification_data/main ./make_verification_data/*.go && ./make_verification_data/main -fixture-dir ../webapp/fixture -dest-dir ./result/verification_data -target-url http://localhost:1323
Expand All @@ -20,7 +20,7 @@
args:
chdir: /home/isucon/isucon10-qualify/bench/
environment:
PATH: "/home/isucon/bin:/home/isucon/.local/bin:/usr/local/node/bin:/usr/local/python/bin:/usr/local/go/bin:/home/isucon/go/bin:/usr/local/bin:/usr/bin:/bin"
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: |
make
Expand Down
68 changes: 37 additions & 31 deletions provisioning/ansible/roles/common/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
name: isucon
uid: 1100
group: isucon
password: isucon
password: $6$a3ehJA1nkzvm3EiW$3vTxieCi5P8brkaJzzBDji3wyjJRQYWBtcRgf27f2BRdEMKeM7Pycb2JZ6eTdSw2/hqLh59xVH7PTr6r9wNiQ0
home: /home/isucon
shell: /bin/bash
state: present
Expand All @@ -38,39 +38,45 @@
replace: 'http://ftp.jaist.ac.jp/pub/Linux/ubuntu/'
backup: yes

- name: Check isucon10-qualify
become: no
stat:
path: "/home/isucon/isucon10-qualify"
register: chk_file

- name: Delete isucon10-qualify if exists
- name: Install Package(Build)
become: yes
become_user: root
file:
path: /home/isucon/isucon10-qualify
state: absent
when: chk_file.stat.exists
apt:
name:
- libssl-dev
- libreadline-dev
- gcc
- make
- libffi-dev
- zlib1g-dev
- unzip
- pkg-config
- autoconf
- automake
- build-essential
- nginx
- libxml2-dev
- libsqlite3-dev
- libbz2-dev
- libkrb5-dev
- libcurl4-openssl-dev
- libpng-dev
- libjpeg-dev
- libfreetype6-dev
- libc-client2007e-dev
- libxslt-dev
- libonig-dev
- libtidy-dev
- libzip-dev
- default-mysql-client
- default-libmysqlclient-dev
update_cache: yes

- name: Clone isucon10-qualify
become: no
- name: install xbuild
become: yes
become_user: isucon
git:
repo: [email protected]:isucon/isucon10-qualify.git
repo: https://github.com/tagomoris/xbuild.git
dest: /tmp/xbuild
version: master
dest: /tmp/isucon10-qualify
accept_hostkey: yes

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

- name: Deploy isucon10-qualify
become: yes
become_user: isucon
command: mv /tmp/isucon10-qualify /home/isucon/isucon10-qualify
145 changes: 112 additions & 33 deletions provisioning/ansible/roles/langs/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
- name: Install Package(Build)
become: yes
become_user: root
apt:
name:
- libssl-dev
- libreadline-dev
- gcc
- make
- libffi-dev
- zlib1g-dev
- unzip
update_cache: yes
---
- name: Install Rust
become: yes
become_user: isucon
shell: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
- name: Add PATH for Rust
become: yes
become_user: isucon
blockinfile:
marker: "# {mark} ANSIBLE MANAGED BLOCK Rust"
path: /home/isucon/.bashrc
content: |
export PATH=/home/isucon/.cargo/bin:$PATH
- name: Update v1.46.0(stable)
become: yes
become_user: isucon
command: /home/isucon/.cargo/bin/rustup update stable

- name: Install Deno v1.3.2
become: yes
become_user: isucon
shell: |
curl -fsSL https://deno.land/x/install/install.sh | sh -s v1.3.2
- name: Add PATH for deno
become: yes
become_user: isucon
blockinfile:
marker: "# {mark} ANSIBLE MANAGED BLOCK deno"
path: /home/isucon/.bashrc
content: |
export PATH=/home/isucon/.deno/bin:$PATH
- name: install xbuild
become: yes
Expand All @@ -20,41 +41,99 @@
dest: /tmp/xbuild
version: master

- name: Install Go 1.14
- name: Install PHP
become: yes
become_user: root
command: /tmp/xbuild/go-install 1.14.1 /usr/local/go
become_user: isucon
args:
chdir: /home/isucon
command: >
/tmp/xbuild/php-install 7.4.9 /home/isucon/local/php --
--with-pcre-regex --with-zlib --enable-fpm --enable-pdo --with-pear
--with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl
--with-pcre-regex --with-pcre-dir --with-libxml-dir --enable-opcache
--enable-bcmath --with-bz2 --enable-calendar --enable-cli --enable-shmop
--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"

- name: Add PATH for Go
- name: Add PATH for PHP
become: yes
become_user: isucon
blockinfile:
marker: "# {mark} ANSIBLE MANAGED BLOCK go"
path: &bash_aliases /home/isucon/.bashrc
marker: "# {mark} ANSIBLE MANAGED BLOCK php"
dest: /home/isucon/.bashrc
content: |
export PATH=/usr/local/go/bin:/home/isucon/go/bin:$PATH
export GOROOT=/usr/local/go
export PATH=/home/isucon/local/php/bin:$PATH
- name: Install Ruby v2.7.1
become: yes
become_user: isucon
command: /tmp/xbuild/ruby-install 2.7.1 /home/isucon/local/ruby

- name: Install Node v12.17.0
- name: Add PATH for Ruby
become: yes
become_user: root
command: /tmp/xbuild/node-install v12.17.0 /usr/local/node
become_user: isucon
blockinfile:
marker: "# {mark} ANSIBLE MANAGED BLOCK Ruby"
path: /home/isucon/.bashrc
content: |
export PATH=/home/isucon/local/ruby/bin:$PATH
- 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

- name: Add PATH for perl
become: yes
become_user: isucon
blockinfile:
marker: "# {mark} ANSIBLE MANAGED BLOCK perl"
path: /home/isucon/.bashrc
content: |
export PATH=/home/isucon/local/perl/bin:$PATH
- name: Install Node v14.9.0
become: yes
become_user: isucon
command: /tmp/xbuild/node-install v14.9.0 /home/isucon/local/node

- name: Add PATH for Node
become: yes
become_user: isucon
blockinfile:
marker: "# {mark} ANSIBLE MANAGED BLOCK Node"
path: *bash_aliases
path: /home/isucon/.bashrc
content: |
export PATH=/home/isucon/local/node/bin:$PATH
- name: Install Go 1.14.7
become: yes
become_user: isucon
command: /tmp/xbuild/go-install 1.14.7 /home/isucon/local/go

- name: Add PATH for Go
become: yes
become_user: isucon
blockinfile:
marker: "# {mark} ANSIBLE MANAGED BLOCK go"
path: /home/isucon/.bashrc
content: |
export PATH=/usr/local/node/bin:$PATH
export PATH=/home/isucon/local/go/bin:/home/isucon/go/bin:$PATH
export GOROOT=/home/isucon/local/go
- name: Install python3 pip
- name: Install python v3.7.9
become: yes
become_user: root
apt:
name:
- python3.6
- python3-pip
become_user: isucon
command: /tmp/xbuild/python-install 3.7.9 /home/isucon/local/python

- name: Add PATH for python
become: yes
become_user: isucon
blockinfile:
marker: "# {mark} ANSIBLE MANAGED BLOCK python"
path: /home/isucon/.bashrc
content: |
export PATH=/home/isucon/local/python/bin:$PATH
update_cache: yes
2 changes: 1 addition & 1 deletion provisioning/ansible/roles/remove/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
become: yes
become_user: root
file:
path: "/home/isucon/isucon10-qualify/{{ item }}"
path: "/home/isucon/isuumo/{{ item }}"
state: absent
with_items:
- agreed
Expand Down
15 changes: 15 additions & 0 deletions provisioning/ansible/roles/web-perl/files/isuumo.perl.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=isuumo.perl

[Service]
WorkingDirectory=/home/isucon/isuumo/webapp/perl
EnvironmentFile=/home/isucon/env.sh

User=isucon
Group=isucon
ExecStart=/home/isucon/local/perl/bin/plackup -s Starlet -p 1323 app.psgi

Restart = always
Type = simple
[Install]
WantedBy=multi-user.target
27 changes: 27 additions & 0 deletions provisioning/ansible/roles/web-perl/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
- name: Download cpm
get_url:
url: https://raw.githubusercontent.com/skaji/cpm/master/cpm
dest: /home/isucon/local/perl/bin/cpm
mode: '0755'

- name: Install isuumo.perl Pacakges
become: yes
become_user: isucon
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"
args:
chdir: /home/isucon/isuumo/webapp/perl
shell: |
/home/isucon/local/perl/bin/cpm install -g --show-build-log-on-failure
- name: Copy Service file
copy:
src: "{{ item }}"
dest: "/etc/systemd/system"
owner: "root"
group: "root"
mode: "0644"
with_items:
- isuumo.perl.service
18 changes: 18 additions & 0 deletions provisioning/ansible/roles/web-ruby/files/isucon-ruby.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=isucon-ruby
After=syslog.target

[Service]
WorkingDirectory=/home/isucon/isuumo/webapp/ruby
EnvironmentFile=/home/isucon/env.sh
PIDFile=/home/isucon/isuumo/webapp/ruby/server.pid

User=isucon
Group=isucon
ExecStart=/home/isucon/local/ruby/bin/bundle exec unicorn -c unicorn.conf.rb
ExecStop=/bin/kill -s QUIT $MAINPID

Restart = always
Type = simple
[Install]
WantedBy=multi-user.target
Loading

0 comments on commit eba6d20

Please sign in to comment.