[VCCW2.x] プロビジョニングでwp-cliのsyncに失敗する

久々にVCCWの2系でwordpress環境を作成したところ、すんなりいかなかったので、wordpress環境ができるまでの備忘録です。

## 環境
| CentOS | 6.7 |
|:-:|:-:|
| PHP | 5.4.45  |
| VCCW | 2.21 |

## やったこと
### 一旦vagran upしてみる（local）
```
$ vagrant up
(略)
==> test.example: [2018-06-11T01:23:04+00:00] ERROR: git[/usr/share/wp-cli] (wpcli::default line 17) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '128'
==> test.example: ---- Begin output of git ls-remote "https://github.com/wp-cli/builds.git" "HEAD" ----
==> test.example: STDOUT: 
==> test.example: STDERR: error:  while accessing https://github.com/wp-cli/builds.git/info/refs
==> test.example: 
==> test.example: fatal: HTTP request failed
==> test.example: ---- End output of git ls-remote "https://github.com/wp-cli/builds.git" "HEAD" ----
==> test.example: Ran git ls-remote "https://github.com/wp-cli/builds.git" "HEAD" returned 128
==> test.example: [2018-06-11T01:23:04+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
```

## gitの再インストール
エラーの原因は調べてみたところgitのバージョンが古いことが原因のようです
### gitのversionを確認(vagrant内)

```
$ vagrant ssh
$ git --version
git version 1.7.1
```

### 2.x系のgitをインストールする(vagrant内)

```
$ vagrant ssh
$ sudo yum -y remove git
$ sudo yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker
$ wget https://www.kernel.org/pub/software/scm/git/git-2.4.0.tar.gz
$ tar zxvf git-2.4.0.tar.gz
$ cd git-2.4.0
$ make configure
$ ./configure --prefix=/usr
$ make all
$ sudo make install
```

### gitのversionを確認(vagrant内)

```
$ git --version
git version 2.4.0
```

### 再度プロビジョニング（local）しましたが

```
$ vagrant provision
==> test.example:     ================================================================================
==> test.example:     Error executing action `sync` on resource 'git[/usr/share/wp-cli]'
==> test.example:     ================================================================================
==> test.example:
==> test.example:     Mixlib::ShellOut::ShellCommandFailed
==> test.example:     ------------------------------------
==> test.example:     Expected process to exit with [0], but received '128'
==> test.example:     ---- Begin output of git ls-remote "https://github.com/wp-cli/builds.git" "HEAD" ----
==> test.example:     STDOUT:
==> test.example:     STDERR: fatal: unable to access 'https://github.com/wp-cli/builds.git/': SSL connect error
==> test.example:     ---- End output of git ls-remote "https://github.com/wp-cli/builds.git" "HEAD" ----
==> test.example:     Ran git ls-remote "https://github.com/wp-cli/builds.git" "HEAD" returned 128
==> test.example:
==> test.example:     Resource Declaration:
==> test.example:     ---------------------
==> test.example:     # In /tmp/vagrant-chef/f59344bd9aea1e7a96e8c5bc92876d88/cookbooks/wpcli/recipes/default.rb
==> test.example:
==> test.example:      17: git node[:wpcli][:dir] do
==> test.example:      18:   repository "https://github.com/wp-cli/builds.git"
==> test.example:      19:   action :sync
==> test.example:      20: end
==> test.example:      21:
==> test.example:
==> test.example:     Compiled Resource:
==> test.example:     ------------------
==> test.example:     # Declared in /tmp/vagrant-chef/f59344bd9aea1e7a96e8c5bc92876d88/cookbooks/wpcli/recipes/default.rb:17:in `from_file'
==> test.example:
==> test.example:     git("/usr/share/wp-cli") do
==> test.example:       provider Chef::Provider::Git
==> test.example:       action [:sync]
==> test.example:       retries 0
==> test.example:       retry_delay 2
==> test.example:       guard_interpreter :default
==> test.example:       destination "/usr/share/wp-cli"
==> test.example:       enable_checkout true
==> test.example:       revision "HEAD"
==> test.example:       remote "origin"
==> test.example:       checkout_branch "deploy"
==> test.example:       cookbook_name :wpcli
==> test.example:       recipe_name "default"
==> test.example:       repository "https://github.com/wp-cli/builds.git"
==> test.example:     end
==> test.example:
==> test.example: [2018-06-11T01:42:56+00:00] INFO: Running queued delayed notifications before re-raising exception
==> test.example:
==> test.example: Running handlers:
==> test.example: [2018-06-11T01:42:56+00:00] ERROR: Running exception handlers
==> test.example: Running handlers complete
==> test.example: [2018-06-11T01:42:56+00:00] ERROR: Exception handlers complete
==> test.example: [2018-06-11T01:42:56+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> test.example: Chef Client failed. 0 resources updated in 7.336955226 seconds
==> test.example: [2018-06-11T01:42:56+00:00] ERROR: git[/usr/share/wp-cli] (wpcli::default line 17) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '128'
==> test.example: ---- Begin output of git ls-remote "https://github.com/wp-cli/builds.git" "HEAD" ----
==> test.example: STDOUT:
==> test.example: STDERR: fatal: unable to access 'https://github.com/wp-cli/builds.git/': SSL connect error
==> test.example: ---- End output of git ls-remote "https://github.com/wp-cli/builds.git" "HEAD" ----
==> test.example: Ran git ls-remote "https://github.com/wp-cli/builds.git" "HEAD" returned 128
==> test.example: [2018-06-11T01:42:56+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
```

上記のようなエラーが...
SSL connect errorとあるので
調べてみたところ[CentOS 6 の Git で SSL connect error にハマった](https://mseeeen.msen.jp/git-ssl-or-nss-connect-error-in-centos-6/)という記事に出会いました。


```
$ vagrant ssh
$ sudo yum -y update nss
```

### 再度プロビジョニング（local）

```
$ vagrant provision
```

これでイケました。

## 参考
[Chefでwp-cliのsyncアクションが実行できず、vccwのv2でのvagrant upに失敗する](https://teratail.com/questions/117998)
[CentOS 6 の Git で SSL connect error にハマった](https://mseeeen.msen.jp/git-ssl-or-nss-connect-error-in-centos-6/)