Hejdaの見る夢

一人前のエンジニアを目指して頑張ったこととかをつらつら書くブログ

Warning: Remote connection disconnect. Retrying...の話

最近、macvagrantがおかしい様子…

ローカル開発でvagrantを使っているのですが、最近になって様子がおかしい…

最初のupでは普通に立ち上がるのだけど、halt後のupやsnapshotをロールバックした後のupもコケる様子。

$ vagrant snapshot go first_snap
Powering off machine 3264830a-160b-4bb2-8d06-d5a1fb1f4721
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Restoring snapshot 6ba7eaa2-d91e-4a2f-a1c5-6bf2e0cbda96
Starting restored VM
==> svr03: Checking if box 'bento/centos-6.7' is up to date...
==> svr03: Resuming suspended VM...
==> svr03: Booting VM...
==> svr03: Waiting for machine to boot. This may take a few minutes...
    svr03: SSH address: 127.0.0.1:2201
    svr03: SSH username: vagrant
    svr03: SSH auth method: private key
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase

過去にも同様のとこで悩んでいる方々もちらほら…

Vagrant で default: Warning: Remote connection disconnect. Retrying…

で、解決策としては1回destroyしてまっさらにすればup出来るのだけど、

それだとansibleのrole作成等々でとても不便…

今はboxを変えてみたりして試行錯誤中です(´・ω・`)

brew updateでエラーが出た話

普段はMacを使っているのですが、ローカルのphpをupdateしたくて

軽い気持ちでbrew updateしたら怒られた…

$ brew update
error: The following untracked working tree files would be overwritten by merge:
    Library/Formula/agedu.rb
    Library/Formula/appledoc.rb
    Library/Formula/blackbox.rb
    Library/Formula/connect.rb
    Library/Formula/dromeaudio.rb
    Library/Formula/geany.rb
    Library/Formula/gerbv.rb
    Library/Formula/gkrellm.rb
    Library/Formula/glade.rb
    Library/Formula/gnumeric.rb
    Library/Formula/gtksourceviewmm.rb
    Library/Formula/gtksourceviewmm3.rb
    Library/Formula/ldid.rb
    Library/Formula/mlton.rb
    Library/Formula/mydumper.rb
    Library/Formula/owamp.rb
    Library/Formula/serf.rb
    Library/Formula/sslscan.rb
    Library/Formula/sylpheed.rb
    Library/Formula/tcpurify.rb
    Library/Formula/zenity.rb
Please move or remove them before you can merge.
Aborting
Error: Failure while executing: git pull --ff --no-rebase --quiet origin refs/heads/master:refs/remotes/origin/master

結構あるな〜(´・ω・`)なんて眺めていても仕方ないので、さくさくっと更新します。

参考したのは以下のサイト

ヾ(o゚ω゚o)ノ゙brew updateでエラーでたった[Homebrew]

※ 尚、OSはMacOSX 10.11.4です

対応コマンド(下準備)

実際にはこんな感じ

$ cd $(brew --prefix)
$ git fetch origin
$ sudo git reset --hard origin/master

参考資料には

$ git reset --hard origin/master

ってあったけど、

$ git reset --hard origin/master
warning: unable to unlink CONTRIBUTING.md: Permission denied
warning: unable to unlink SUPPORTERS.md: Permission denied

って怒られる。今思えば、権限変更すれば良かった思っている。

また、pathに関しても参考資料と一致していたので

OSが1つくらい違っても無問題。

$ cd $(brew --prefix)
$ pwd
/usr/local

対応コマンド(upadte)

あとは、updateするのみ!

$ brew update
Error: /usr/local must be writable!

…また、怒られました。

どうやら、上記でsudoでupdateしたところの権限が問題のようです。

権限を直してリトライしたところ、通るようになりました

$ sudo chown -R $(whoami):admin /usr/local
Password:
$ brew update
$ brew upgrade 

追記 1

作法としては

$ brew doctor
$ brew update
$ brew upgrade

の様です。

素人がEl Capitanにアップデートしてみたやつ。

追記 2

当初の目的に関してはmacにhomebrewでPHP5.6環境をインストールしてみるを参考にやりました。

$ xcode-select --install
  • brewを最新にする
$ brew update
$ brew upgrade
$ brew tap homebrew/php
$ brew tap homebrew/dupes
$ brew install php56 --with-apxs2=/usr/sbin/apxs
$ brew services start homebrew/php/php56

上記で対応できます。

追記 3

実はFormulaeでこけていた

php5.6をインストールしようとしたら、フォーミュラでコケた…

$ brew install homebrew/php/php56 --with-apxs2=/usr/sbin/apxs
==> Installing php56 from homebrew/php
Error: Formulae found in multiple taps: 
 * homebrew/php/php53
 * josegonzalez/php/php53

フォーミュラの名前重複が気に食わないらしいので、それを解除する。

$ brew untap josegonzalez/php

追記 4

インストール後に再起動が必要になるが、 それでもphpのバージョンがupdateされない場合は以下を設定

  • ~/.bashrc
# php56
export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"

# php70
export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH"

ansible-playbookで[DEPRECATION WARNING]が出た話

環境

# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=15.04
DISTRIB_CODENAME=vivid
DISTRIB_DESCRIPTION="Ubuntu 15.04"
# arch
x86_64
# ansible --version
ansible 2.0.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

事象

上記の環境でansible-playbookを回した場合に下記のように怒られた

[DEPRECATION WARNING]: Instead of sudo/sudo_user, use become/become_user and make sure become_method is 'sudo' (default).
This
feature will be removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in
ansible.cfg.

公式ドキュメントを読むと、1.9系からはsudoじゃなくてbecomeを使ってねとのこと。

Become (Privilege Escalation) — Ansible Documentation

対処方法

playbook内のsudoをbecomeにする

-  sudo: yes
+  become: yes

と変更すれば、すんなり通る。

もしくはsudo無しで実行してしまう。

個人的には最初の構築はrootで行ない、

構築後の変更(deploy等)はbecomeで行うように用途を分けているのだけれど

そもそも絶対にbecome(sudo)でしか実行出来ない用途が思いつかないので

無しでいいと思ってしまった。

DigitalOceanを使ってみた感想とかの話

DigitalOcean

以前から登録はしていたのですが、実際に使ってみたのはつい最近からです。

元々、さくらとAWSを使っていたのですが

2 ~3時間くらいのスポットのテスト環境が欲しい時って

さくらだと燃費悪いし、AWSも設定がめんどくさいな〜と感じていたので

DigitalOceanを使ってみました。

TOP

f:id:nari_kyu:20160407072337p:plain

こんな感じです。

具体的な使用方法は他の人のブログに任せます。

で、実際にサーバーを立ち上げるのに必要な動作はわずか8クリックで済みました。

(クレジットカード登録や、SSH keysの登録は済んだ状態の話)

f:id:nari_kyu:20160407072912p:plain

上記は実際に

  • centos 6.7 x64
  • mem 512MB / 1CPU / SSD 20GB / Transfer 1000GB
  • Singapore
  • 3台

で構築した図ですが、3つとも1分経たずに使用可能になりました。

また、手元にansibleのplaybookがあったので、

公開鍵を別途登録して3台に一斉に流してみたところ

すんなり環境構築も出来ました。

f:id:nari_kyu:20160407080412p:plain

これだけお手軽に環境構築出来て安いのであれば、

ローカル環境以上プロダクション環境以下かつ、

スポットで欲しいときはうってつけかなと個人的に思っています。

またvagrantのpluginもあって、vagrant upのboxとしてDigitalOceanのdropsを使えるらしいです。

こちらもそのうち使ってみたいと思います!