質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Chef

ChefはRuby等で書かれた構成管理ツールです。 システム構築や、運用作業を自動化してくれます。

VirtualBox

VirtualBoxは、現在米オラクル社が開発している、 x86仮想化ソフトウェア・パッケージの一つです。

Q&A

解決済

1回答

1768閲覧

クックブックのインストールのエラーについて

ockun423

総合スコア20

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Chef

ChefはRuby等で書かれた構成管理ツールです。 システム構築や、運用作業を自動化してくれます。

VirtualBox

VirtualBoxは、現在米オラクル社が開発している、 x86仮想化ソフトウェア・パッケージの一つです。

0グッド

0クリップ

投稿2017/03/09 14:42

###実現したいこと
CakePHPで学ぶ継続的インテグレーションを参考に環境を構築しています。
windows PCに仮想環境を構築し、クックブックのインストールを実行するとエラーが発生し進めなくなりました。Google上にもあまり情報が無く困っております。

ご存じの方、解決にご協力いただけましたら幸いでございます。

情報が不足しているなどございましたら、ご指摘をいただけましたら幸いです。

###発生している問題・エラーメッセージ
bundle exec berks vendor ./cookbooksを実行したところ下記エラーが発生しました。

$ bundle exec berks vendor ./cookbooks C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ffi-1.9.18-x64-mingw32/lib/ffi/library.rb:275:in `attach_function': Function 'SetTimeout' not found in [C:\Ruby23-x64\lib\ruby\gems\2.3.0\gems\dep_selector-1.0.4\lib\dep_gecode.so] (FFI::NotFoundError) from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/dep_selector-1.0.4/lib/dep_selector/dep_gecode.rb:89:in `<module:Dep_gecode>' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/dep_selector-1.0.4/lib/dep_selector/dep_gecode.rb:21:in `<top (required)>' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/dep_selector-1.0.4/lib/dep_selector/gecode_wrapper.rb:21:in `require' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/dep_selector-1.0.4/lib/dep_selector/gecode_wrapper.rb:21:in `<top (required)>' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/dep_selector-1.0.4/lib/dep_selector/dependency_graph.rb:21:in `require' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/dep_selector-1.0.4/lib/dep_selector/dependency_graph.rb:21:in `<top (required)>' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/dep_selector-1.0.4/lib/dep_selector/selector.rb:21:in `require' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/dep_selector-1.0.4/lib/dep_selector/selector.rb:21:in `<top (required)>' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/dep_selector-1.0.4/lib/dep_selector.rb:23:in `require' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/dep_selector-1.0.4/lib/dep_selector.rb:23:in `<top (required)>' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/solve-1.2.1/lib/solve/solver.rb:1:in `require' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/solve-1.2.1/lib/solve/solver.rb:1:in `<top (required)>' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/solve-1.2.1/lib/solve.rb:10:in `require_relative' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/solve-1.2.1/lib/solve.rb:10:in `<module:Solve>' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/solve-1.2.1/lib/solve.rb:3:in `<top (required)>' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/berkshelf-3.1.5/lib/berkshelf.rb:8:in `require' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/berkshelf-3.1.5/lib/berkshelf.rb:8:in `<top (required)>' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/berkshelf-3.1.5/lib/berkshelf/cli.rb:1:in `require' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/berkshelf-3.1.5/lib/berkshelf/cli.rb:1:in `<top (required)>' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/berkshelf-3.1.5/bin/berks:3:in `require' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/berkshelf-3.1.5/bin/berks:3:in `<top (required)>' from C:/Ruby23-x64/bin/berks:22:in `load' from C:/Ruby23-x64/bin/berks:22:in `<main>'

###環境構築の過程
実行してきたコマンドや作成した設定ファイルを時系列に書いております。

./vagrantfile を作成

# -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" BOX_URL = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-16.04_chef-provisionerless.box" BOX_NAME = "opscode-ubuntu-16.04" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| if Vagrant.has_plugin?("vagrant-cachier") config.cache.scope = :box end # 1つめの仮想サーバ config.vm.define :develop do |develop| develop.omnibus.chef_version = :latest develop.vm.hostname = "develop" develop.vm.box = BOX_NAME develop.vm.box_url = BOX_URL develop.vm.network :private_network, ip: "192.168.33.10" # 以下を追加 # Vagrantfileがあるディレクトリと同じディレクトリのapplicationディレクトリをVagrantと共有します # 先にapplicationディレクトリを作成しておいてください develop.vm.synced_folder "application", "/var/www/application/current", id: "vagrant-root", :nfs => false, :owner => "vagrant", :group => "www-data", :mount_options => ["dmode=775,fmode=775"] end # 2つめの仮想サーバ config.vm.define :ci do |ci| ci.omnibus.chef_version = :latest ci.vm.hostname = "ci" ci.vm.box = BOX_NAME ci.vm.box_url = BOX_URL ci.vm.network :private_network, ip: "192.168.33.100" end # 3つめの仮想サーバ config.vm.define :deploy do |deploy| deploy.omnibus.chef_version = :latest deploy.vm.hostname = "deploy" deploy.vm.box = BOX_NAME deploy.vm.box_url = BOX_URL deploy.vm.network :private_network, ip: "192.168.33.200" end end

下記を実行

$ vagrant plugin install sahara $ vagrant plugin install vagrant-omnibus $ vagrant plugin install vagrant-cachier

./Gemfile を作成

# Gemfile source 'https://rubygems.org' gem 'chef' gem 'knife-solo' gem 'berkshelf', '~> 3.1.0'

下記を実行

$ bundle install $ bundle exec knife cookbook create phpenv -o site-cookbooks

字数オーバーの為、コメントにて続きを入れさせていただきます。ヘディングのテキスト

###補足情報(言語/FW/ツール等のバージョンなど)
実行OS:Windows10 pro 64bit
Vagrant 1.9.2
VirtualBOX 5.0.32
Ruby 2.3.3p222
devkit 4.7.2
Bundler 1.14.6
Chef 12.19.36
仮想OS:Ubuntu 16.04.1 LTS

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

環境構築の構築の続き

./site-cookbooks/phpenv/recipe/default.rm を作成

# # Cookbook Name:: phpenv # Recipe:: default # # Copyright 2017, YOUR_COMPANY_NAME # # All rights reserved - Do Not Redistribute # # 配列で列挙しているパッケージをインストールする %w{curl php5 php5-cli php5-fpm php5-mysql php-pear php5-curl php5-xsl php5-mcrypt mysql-server-5.5 nginx git}.each do |p| package p do action :install end end # mcryptモジュールを有効にする execute "php5enmod mcrypt" do action :run end # 今回はApacheは利用しないので、パッケージがインストール済の場合はサービスを停止し無効化する service "apache2" do action [:disable, :stop] only_if "dpkg -l | grep apache2" end # Nginx用の設定ファイルをテンプレートから作成する template "/etc/nginx/sites-available/test" do source "test.erb" owner "root" group "root" mode 0644 action :create only_if { node['nginx']['test']['available'] == true } end # シンボリックリンクを張って設定ファイルを有効化する link "/etc/nginx/sites-enabled/test" do to "/etc/nginx/sites-available/test" only_if { node['nginx']['test']['available'] == true } end # デフォルトのサイト設定を上書きする template "/etc/nginx/sites-available/default" do source "default.erb" owner "root" group "root" mode 0644 action :create end # Nginxのドキュメントルートを作成する directory node['nginx']['docroot']['path'] do owner node['nginx']['docroot']['owner'] group node['nginx']['docroot']['group'] mode 0755 action :create recursive true only_if { not File.exists?(node['nginx']['docroot']['path']) and node['nginx']['docroot']['force_create']} end # ダミーのphpスクリプトを作成する template "#{node['nginx']['docroot']['path']}/index.php" do source "index.php.erb" owner node['nginx']['docroot']['owner'] group node['nginx']['docroot']['group'] mode 0644 action :create only_if { not File.exists?("#{node['nginx']['docroot']['path']}/index.php") and node['nginx']['docroot']['force_create']} end # Nginxのサービスを有効化して起動する service "nginx" do action [:enable, :restart] end # MySQLのサービスを有効化して起動する service "mysql" do action [:enable, :restart] supports :status => true, :start => true, :stop => true, :restart => true not_if do File.exists?("/var/run/mysqld/mysqld.pid") end end # MySQLのrootアカウントのパスワードをセットする execute "set_mysql_root_password" do command "/usr/bin/mysqladmin -u root password \"#{node['mysql']['root_password']}\"" action :run only_if "/usr/bin/mysql -u root -e 'show databases;'" end

./site-cookbooks/phpenv/attributes/default.rb を作成

# Nginxのドキュメントルートのオーナー default['nginx']['docroot']['owner'] = 'root' # Nginxのドキュメントルートのグループ default['nginx']['docroot']['group'] = 'root' # Nginxのドキュメントルートのパス default['nginx']['docroot']['path'] = "/usr/share/nginx/html" # Nginxのドキュメントルートが存在しないときに作成するかどうか default['nginx']['docroot']['force_create'] = false # Nginxのdefaultサイト設定に引き渡すパラメータ default['nginx']['default']['fastcgi_params'] = [] # Nginxでテスト用のVirtualHostを使うかどうか default['nginx']['test']['available'] = false # Nginxのtestサイト設定に引き渡すパラメータ default['nginx']['test']['fastcgi_params'] = [] # MySQLのルートパスワード default['mysql']['root_password'] = 'password'

./site-cookbooks/phpenv/templates/default/default.erb を作成

server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root <%= node['nginx']['docroot']['path'] %>; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_intercept_errors on; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; <% node['nginx']['default']['fastcgi_params'].each do |key,value| -%> fastcgi_param <%= key %> <%= value %>; <% end %> } }

./site-cookbooks/phpenv/templates/default/test.erb を作成

server { listen 80; root <%= node['nginx']['docroot']['path'] %>; index index.php index.html index.htm; server_name test.localhost; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_intercept_errors on; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; <% node['nginx']['test']['fastcgi_params'].each do |key,value| -%> fastcgi_param <%= key %> <%= value %>; <% end %> } }

./Berksfile を作成

server { listen 80; root <%= node['nginx']['docroot']['path'] %>; index index.php index.html index.htm; server_name test.localhost; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_intercept_errors on; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; <% node['nginx']['test']['fastcgi_params'].each do |key,value| -%> fastcgi_param <%= key %> <%= value %>; <% end %> } }

下記を実行

$ rm -fr cookbooks $ bundle exec berks vendor ./cookbooks #このタイミングでエラーが発生

投稿2017/03/09 14:44

ockun423

総合スコア20

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問