deployerをちょろっとためしたいだけなのにいきなりsyntax errorされた件
deployerについてはこちら↓
Deployer — Deployment Tool for PHP
ちなみに選定理由はPHP製デプロイツールをググって一番最初に出てきたことです
あと公式サイトがかっこよすぎてやばい
導入
$ curl -L -O http://deployer.org/deployer.phar
エラー内容
PHP Parse error: syntax error, unexpected '[' in phar:///home/vagrant/deployer.phar/bin/dep on line 14
PHP5.5以上をインストール
$ sudo rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm $ sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm $ sudo yum -y install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd $ php deployer.phar deploy [RuntimeException] You need to specify at least one server or stage. deploy [-p|--parallel]
動きはした
一旦動かしたいだけなので不思議な動かし方をしていることは気にしない
vagrantでWarning: Authentication failure. Retrying...が出まくる時
仮想環境準備
Vagrant by HashiCorp
Downloads – Oracle VM VirtualBox
A list of base boxes for Vagrant - Vagrantbox.es
$ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Box 'bento/centos-6.7' could not be found. Attempting to find and install... default: Box Provider: virtualbox default: Box Version: >= 0 ==> default: Loading metadata for box 'bento/centos-6.7' default: URL: https://atlas.hashicorp.com/bento/centos-6.7 ==> default: Adding box 'bento/centos-6.7' (v2.2.7) for provider: virtualbox default: Downloading: https://atlas.hashicorp.com/bento/boxes/centos-6.7/versions/2.2.7/providers/virtualbox.box ==> default: Successfully added box 'bento/centos-6.7' (v2.2.7) for 'virtualbox'! ==> default: Importing base box 'bento/centos-6.7'... ==> default: Matching MAC address for NAT networking... ==> default: Checking if box 'bento/centos-6.7' is up to date... ==> default: Setting the name of the VM: default_1470938359502_67401 ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: hostonly ==> default: Forwarding ports... default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: default: Vagrant insecure key detected. Vagrant will automatically replace default: this with a newly generated keypair for better security. default: default: Inserting generated public key within guest... default: Removing insecure key from the guest if it's present... default: Key inserted! Disconnecting and reconnecting using new SSH key... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... ... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. 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 the timeout ("config.vm.boot_timeout") value.
ひたすら
default: Warning: Authentication failure. Retrying...
した挙句にエラーを吐き、vagrant sshでパスワードを求められる
原因
vagrant1.7以降の仕様です
vagrant upすると、対象のゲストOSに対して新たな鍵のペアを生成して配置するため、
環境によってはデフォルトのinsecure_private_keyとの合わずにエラーが発生する
config.ssh.insert_key - If true, Vagrant will automatically insert a keypair to use for SSH, replacing Vagrant's default insecure key inside the machine if detected. By default, this is true.
This only has an effect if you do not already use private keys for authentication or if you are relying on the default insecure key. If you do not have to care about security in your project and want to keep using the default insecure key, set this to false.
ssh.insert_key がtrueの場合、
vagrantはvagrant内のデフォルトの安全でないキーが検出されると、SSHで使用する鍵ペアを置き換える未使用の秘密鍵の場合、デフォルトの安全でないキーを使用している場合にのみ影響がある
セキュリティを気にする必要があり、デフォルト安全でないキーを使用したい場合、これをfalseに設定してください
直し方
Vagrantfileに下記追加
config.ssh.insert_key = false
追加前
vagrant ssh-config ⏎ Host default HostName 127.0.0.1 User vagrant Port 2222 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile /Users/heleeen/work/infra/deploy_test/.vagrant/machines/default/virtualbox/private_key IdentitiesOnly yes LogLevel FATAL
追加後
$ vagrant ssh-config Host default HostName 127.0.0.1 User vagrant Port 2222 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile /Users/heleeen/.vagrant.d/insecure_private_key # ここが変わる IdentitiesOnly yes LogLevel FATAL
crontabして何も見つからないのに設定ファイルはあるとき
cronの設定ファイルはあるのに設定を見れなくて困ったのでめも
hogeユーザに設定はなし
$ crontab -l no crontab for hoge
cronの実行権限を持つユーザーを確認する
$ sudo ls /var/spool/cron/ heleeen
このユーザーじゃないとcrontabできないっぽい
別ユーザーの持つcronを確認する
# crontab -u user_name -l $ sudo crontab -u heleeen -l * * * * * hoge.sh
sshでUNPROTECTED PRIVATE KEY FILE!されたとき
sshしようとしたときに
$ ssh hoge@XXX.XXX.XXX.XXX -i ~/.ssh/hoge_rsa @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0644 for '.ssh/hoge_rsa' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. bad permissions: ignore key: .ssh/hoge_rsa Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
.ssh/hoge_rsaの権限が644になっているのが問題っぽい
他にアクセスさせるなということで600にしたら出なくなりました
$ ls -la .ssh -rw-r--r--@ 1 heleeen heleeen 7 1 11:10 hoge_rsa # 600に変更 $ chmod 600 .ssh/hoge_rsa # 確認 $ ls -la .ssh -rw-------@ 1 heleeen heleeen 7 1 11:10 hoge_rsa
ファイルコピーしたときに権限が変わるっぽい
railsでChartkickを使ってみた
Chartkick
- rubyにJSで綺麗にグラフを書いてくれる
- 折れ線グラフや円グラフ、タイムラインをかける
- googleJSAPIも使う
- 配列・ハッシュで数値をグラフに渡すことができて簡単に書ける
導入
1. Gemfileに以下追記してbundle install
gem "chartkick"
2. GoogleCharts読み込み
グラフ描画ライブラリはヘルパーメソッドの前に読まれるようにする
:content_forオプションを使うときは気にしなくて良い
//= require chartkick
:content_for
コンテンツを指定の場所でロードする
# layout <%= yield :extend_menu %> # view <% content_for :extend_menu do %> [<%= link_to 文字列A, action => "A" %>] <% end %>
3. chartkick.js読み込み
JSのライブラリを読み込む
<%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %>
使ってみる
View
<%= line_chart @line_chart %> <%= pie_chart @pie_chart %>
Controller
def index # 配列の場合 @line_chart = [['2014-04-01', 30], ['2014-04-02', 40], ['2014-04-03', 50]] # ハッシュの場合 @pie_chart = {'2014-04-01' => 20, '2014-04-02' => 50, '2014-04-03' => 30} end
こうなる
そしてやっぱりドキュメントを読むのが一番確実だなと思いました