Skip to content

Instantly share code, notes, and snippets.

@niratama
Created June 25, 2015 13:02
Show Gist options
  • Save niratama/4b690e57840ab5331b2a to your computer and use it in GitHub Desktop.
Save niratama/4b690e57840ab5331b2a to your computer and use it in GitHub Desktop.
IPv6無効化時にyrmcdsが起動に失敗する件の再現環境
options ipv6 disable=0
---
- hosts: all
become: true
tasks:
- name: install epel
yum: |
name=http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
state=installed
with_items: common_repo
# devtools-2.repoを取得する
- name: ensure install devtools-2.repo
get_url: 'url=http://people.centos.org/tru/devtools-2/devtools-2.repo dest=/etc/yum.repos.d/'
# devtoolset-2のインストール
- name: install devtoolset-2 packages
yum: name={{ item }} state=present enablerepo=testing-devtools-2-*
with_items:
- git
- patch
- libmemcached
- devtoolset-2-gcc
- devtoolset-2-binutils
- devtoolset-2-gcc-c++
# 依存パッケージのインストール
- name: install deps
yum: name={{ item }} state=present enablerepo=testing-devtools-2-*
with_items:
- libunwind
- libunwind-devel
- gperftools
- gperftools-libs
- gperftools-devel
# yrmcdsのclone
- name: clone yrmcds repo
git: repo=https://github.com/cybozu/yrmcds.git dest=/usr/local/src/yrmcds update=false accept_hostkey=yes
# パッチの転送
- name: copy patch files
copy: src={{ item }} dest=/usr/local/src/yrmcds
with_items:
- yrmcds-Makefile.diff
- yrmcds-etc_upstart.diff
- yrmcds-etc_yrmcds_conf.diff
# パッチ当て
- name: patch yrmcds
patch: src=/usr/local/src/yrmcds/{{ item }} basedir=/usr/local/src/yrmcds
with_items:
- yrmcds-Makefile.diff
- yrmcds-etc_upstart.diff
- yrmcds-etc_yrmcds_conf.diff
# ビルド
- name: build yrmcds
command: chdir=/usr/local/src/yrmcds scl enable devtoolset-2 -- make
register: yrmcds_build_status
changed_when: |
yrmcds_build_status.stdout != "make: Nothing to be done for `all'."
# バイナリを比較
- name: test build binary
stat: path=/usr/local/src/yrmcds/yrmcdsd
register: yrmcds_build_bin
- name: test installed binary
stat: path=/usr/local/sbin/yrmcdsd
register: yrmcds_installed_bin
# インストール
- name: install yrmcds
command: chdir=/usr/local/src/yrmcds scl enable devtoolset-2 -- make install
when: not yrmcds_installed_bin.stat.exists or (yrmcds_build_bin.stat.md5 != yrmcds_installed_bin.stat.md5)
notify:
- start yrmcds
# ログがなかったら作成する
- name: test log file
stat: path=/var/log/yrmcds.log
register: yrmcds_log
- name: create log file
file: path=/var/log/yrmcds.log owner=nobody group=nobody mode=0644 state=touch
when: not yrmcds_log.stat.exists
# ipv6.confの転送
- name: copy ipv6.conf
copy: src=ipv6.conf dest=/etc/modprobe.d/ipv6.conf
handlers:
# 起動
- name: start yrmcds
service: name=yrmcds state=started enabled=yes
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "centos6.6"
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
ansible.verbose = "v"
end
end
--- etc/upstart.orig 2015-04-17 18:24:41.951527115 +0900
+++ etc/upstart 2015-04-17 18:25:01.826939416 +0900
@@ -15,20 +15,20 @@
pre-start script
[ -d /var/tmp/yrmcds ] || mkdir /var/tmp/yrmcds
chmod 700 /var/tmp/yrmcds
- chown nobody:nogroup /var/tmp/yrmcds
+ chown nobody:nobody /var/tmp/yrmcds
rm -f /var/tmp/yrmcds/*
# make sure keepalived init script was disabled.
# ex) sudo update-rc.d keepalived disable
- /etc/init.d/keepalived start
- sleep 5
+ #/etc/init.d/keepalived start
+ #sleep 5
end script
post-stop script
- /etc/init.d/keepalived stop
+ #/etc/init.d/keepalived stop
# sleep a while to hand-off VIP
- sleep 5
+ #sleep 5
end script
exec /usr/local/sbin/yrmcdsd
--- etc/yrmcds.conf.orig 2015-04-17 18:03:06.561763890 +0900
+++ etc/yrmcds.conf 2015-04-17 18:30:36.105860791 +0900
@@ -4,7 +4,7 @@
user = nobody
# setgid group
-group = nogroup
+group = nobody
# To become the master, virtual_ip address must be owned.
virtual_ip = 127.0.0.1
--- Makefile.orig 2015-05-15 17:45:41.670011285 +0900
+++ Makefile 2015-05-15 17:47:24.047010439 +0900
@@ -19,7 +19,7 @@
CPUFLAGS = #-march=core2 -mtune=corei7
CXXFLAGS = -std=gnu++11 $(OPTFLAGS) $(DEBUGFLAGS) $(shell getconf LFS_CFLAGS) $(WARNFLAGS) $(CPUFLAGS)
LDFLAGS = -L. $(shell getconf LFS_LDFLAGS)
-LDLIBS = $(shell getconf LFS_LIBS) -lyrmcds $(LIBTCMALLOC) -latomic -lpthread
+LDLIBS = $(shell getconf LFS_LIBS) -lyrmcds $(LIBTCMALLOC) -lpthread
CLDOC := LD_LIBRARY_PATH=$(shell llvm-config --libdir 2>/dev/null) cldoc
HEADERS = $(wildcard src/*.hpp src/*/*.hpp cybozu/*.hpp)
@@ -51,11 +51,11 @@
strip $(EXE)
install: $(EXE)
- cp etc/upstart /etc/init/yrmcds.conf
- cp etc/logrotate /etc/logrotate.d/yrmcds
- cp etc/yrmcds.conf $(DEFAULT_CONFIG)
- cp $(EXE) $(PREFIX)/sbin/yrmcdsd
- install -o nobody -g nogroup -m 644 /dev/null /var/log/yrmcds.log
+ install etc/upstart /etc/init/yrmcds.conf
+ install etc/logrotate /etc/logrotate.d/yrmcds
+ install etc/yrmcds.conf $(DEFAULT_CONFIG)
+ install $(EXE) $(PREFIX)/sbin/yrmcdsd
+# install -o nobody -g nobody -m 644 /dev/null /var/log/yrmcds.log
COPYING.hpp: COPYING
echo -n 'static char COPYING[] = R"(' > $@
@niratama
Copy link
Author

vagrant boxは以下のものを使用

$ vagrant box add --name centos6.6 http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.6_chef-provisionerless.box

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment