We use vagrant and chef for create local developing environment.
As you know, both are nasty developer helping tool,
Today I encountered this nasty error.
Vagrantとchefというツールを使っている現在のプロジェクト。正直こういう便利そうなツールほど落とし穴が多いものです。
今日もchefでのMySQLのインストールと起動に失敗してます。
==> develop: Recipe: yum-mysql-community::mysql56
==> develop: * yum_repository[mysql56-community] action create
==> develop: * template[/etc/yum.repos.d/mysql56-community.repo] action create (up to date)
==> develop: * execute[yum clean metadata mysql56-community] action nothing (skipped due to action :nothing)
==> develop: * execute[yum-makecache-mysql56-community] action nothing (skipped due to action :nothing)
==> develop: * ruby_block[yum-cache-reload-mysql56-community] action nothing (skipped due to action :nothing)
==> develop: (up to date)
==> develop: Recipe: trl-lamp::mysql-server
==> develop: * mysql_client_installation_package[server] action create
==> develop: * yum_package[mysql-community-client, mysql-community-devel] action install
==> develop:
==> develop:
==> develop: ================================================================================
==> develop: Error executing action `install` on resource 'yum_package[mysql-community-client, mysql-community-devel]'
==> develop: ================================================================================
==> develop:
==> develop: Chef::Exceptions::Exec
==> develop: ----------------------
==> develop: yum -d0 -e0 -y install mysql-community-client-5.6.39-2.el7 mysql-community-devel-5.6.39-2.el7 returned 1:
==> develop: STDOUT:
==> develop: STDERR: warning: /var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.39-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
==> develop:
==> develop:
==> develop: GPG key retrieval failed: [Errno 14] HTTPS Error 404 - Not Found
==> develop:
==> develop: Resource Declaration:
==> develop: ---------------------
==> develop: # In /var/chef/cache/cookbooks/mysql/libraries/mysql_client_installation_package.rb
==> develop:
==> develop: 18: package new_resource.package_name do
==> develop: 19: version new_resource.package_version if new_resource.package_version
==> develop: 20: options new_resource.package_options if new_resource.package_options
==> develop: 21: action :install
==> develop: 22: end
==> develop: 23: end
==> develop:
==> develop: Compiled Resource:
==> develop: ------------------
==> develop: # Declared in /var/chef/cache/cookbooks/mysql/libraries/mysql_client_installation_package.rb:18:in `block in '
==> develop:
==> develop: yum_package("mysql-community-client, mysql-community-devel") do
==> develop: package_name ["mysql-community-client", "mysql-community-devel"]
==> develop: action [:install]
==> develop: retries 0
==> develop: retry_delay 2
==> develop: default_guard_interpreter :default
==> develop: declared_type :package
==> develop: cookbook_name "trl-lamp"
==> develop: flush_cache {:before=>false, :after=>false}
==> develop: arch [nil, nil]
==> develop: end
==> develop:
==> develop: System Info:
==> develop: ------------
==> develop: chef_version=12.21.26
==> develop: platform=centos
==> develop: platform_version=7.4.1708
==> develop: ruby=ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-linux]
==> develop: program_name=chef-client worker: ppid=4766;start=01:51:29;
==> develop: executable=/opt/chefdk/bin/chef-client
==> develop:
==> develop:
==> develop: ================================================================================
==> develop: Error executing action `create` on resource 'mysql_client_installation_package[server]'
==> develop: ================================================================================
==> develop:
==> develop: Chef::Exceptions::Exec
==> develop: ----------------------
==> develop: yum_package[mysql-community-client, mysql-community-devel] (/var/chef/cache/cookbooks/mysql/libraries/mysql_client_installation_package.rb line 18) had an error: Chef::Exceptions::Exec: yum -d0 -e0 -y install mysql-community-client-5.6.39-2.el7 mysql-community-devel-5.6.39-2.el7 returned 1:
==> develop: STDOUT:
==> develop: STDERR: warning: /var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.39-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
==> develop:
==> develop:
==> develop:
==> develop: GPG key retrieval failed: [Errno 14] HTTPS Error 404 - Not Found
==> develop:
==> develop: Resource Declaration:
==> develop: ---------------------
==> develop: # In /var/chef/cache/cookbooks/trl-lamp/recipes/mysql-server.rb
==> develop:
==> develop: 20: mysql_client "#{instance_name}" do
==> develop: 21: version "#{node['trl-lamp']['mysqld']['version']}"
==> develop: 22: action [:create]
==> develop: 23: end
==> develop: 24: # cli縺ァ蜈・繧九→縺阪�ッmysql -S /var/run/mysql-server/mysqld.sock -u root -pMyPa¥$¥$wordHasSpecialChars!
==> develop:
==> develop: Compiled Resource:
==> develop: ------------------
==> develop: # Declared in /var/chef/cache/cookbooks/trl-lamp/recipes/mysql-server.rb:20:in `from_file'
==> develop:
==> develop: mysql_client_installation_package("server") do
==> develop: action [:create]
==> develop: retries 0
==> develop: retry_delay 2
==> develop: default_guard_interpreter :default
==> develop: declared_type :mysql_client
==> develop: cookbook_name "trl-lamp"
==> develop: recipe_name "mysql-server"
==> develop: version "5.6"
==> develop: major_version "5.6"
==> develop: package_name ["mysql-community-client", "mysql-community-devel"]
==> develop: end
==> develop:
==> develop: System Info:
==> develop: ------------
==> develop: chef_version=12.21.26
==> develop: platform=centos
==> develop: platform_version=7.4.1708
==> develop: ruby=ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-linux]
==> develop: program_name=chef-client worker: ppid=4766;start=01:51:29;
==> develop: executable=/opt/chefdk/bin/chef-client
==> develop:
==> develop:
==> develop: Running handlers:
==> develop: [2018-03-11T01:52:17+00:00] ERROR: Running exception handlers
==> develop: Running handlers complete
==> develop: [2018-03-11T01:52:17+00:00] ERROR: Exception handlers complete
==> develop: Chef Client failed. 1 resources updated in 48 seconds
After the research in internet, I found out that problem is in chef's .
The error occurred because of wrong GPG-Key URL in below file.
/etc/yum.repos.d/mysql56-community.repo
結局、/etc/yum.repos.d/mysql56-community.repoのgpgkeyのURLが間違っているとわかりましたが、このファイルはもとはchefのcookbookから作成されていますので元のファイルを修正する必要があります。
# This file was generated by Chef
# Do NOT modify this file by hand.
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/$releasever/$basearch/
enabled=1
failovermethod=priority
fastestmirror_enabled=0
gpgcheck=1
gpgkey=https://raw.githubusercontent.com/chef-cookbooks/yum-mysql-community/master/files/default/mysql_pubkey.asc
‾
And above repo file is generated from below file
cookbooks/yum-mysql-community/attributes/mysql56-community.rb
こちらがcookbookのrbファイル。
efault['yum']['mysql56-community']['repositoryid'] = 'mysql56-community'
default['yum']['mysql56-community']['gpgkey'] = 'http://raw.githubusercontent.com/chef-cookbooks/yum-mysql-community/master/files/default/mysql_pubkey.asc'
default['yum']['mysql56-community']['description'] = 'MySQL 5.6 Community Server'
default['yum']['mysql56-community']['failovermethod'] = 'priority'
default['yum']['mysql56-community']['gpgcheck'] = true
default['yum']['mysql56-community']['enabled'] = true
First I thought it is as simple as just overwrite URL.
But every time I run the vagrant provisioning, this .rb file is downloaded and overwritten with wrong URL.
単純に上書きすればそれで解決というわけではなく、chefがmysqlをインストールする前にファイルをサーバからダウンロードしてこちらの修正を上書きしてしまいます。
So I decided to cheat little bit.
This nasty chef downloads cookbook files when console shows below message.
==> develop: Starting Chef Client, version 12.21.26
==> develop: resolving cookbooks for run list: ["trl-lamp::selinux-disable", "trl-lamp::build-essential", "trl-lamp::sqlite", "trl-lamp::nodejs", "trl-lamp::mysql-server", "trl-lamp::mysql-database", "trl-lamp::redisio", "trl-lamp::memcached", "trl-lamp::php", "trl-lamp::httpd-web", "trl-lamp::httpd-php", "trl-lamp::minio", "trl-lamp::httpd-vagrant", "trl-lamp::sftp-user"]
==> develop: Synchronizing Cookbooks:
==> develop: - trl-lamp (0.1.12)
==> develop: - selinux (2.1.0)
==> develop: - imagemagick (0.2.3)
==> develop: - build-essential (8.0.4)
==> develop: - nodejs (5.0.0)
==> develop: - httpd (0.6.1)
==> develop: - php (4.5.0)
==> develop: - composer (2.6.1)
==> develop: - mysql (8.5.1)
==> develop: - mysql2_chef_gem (2.1.0)
==> develop: - database (6.1.1)
==> develop: - yum-epel (2.1.2)
==> develop: - redisio (2.6.1)
==> develop: - seven_zip (2.0.2)
==> develop: - memcached (5.0.0)
==> develop: - mingw (2.0.1)
==> develop: - yum-remi-chef (2.2.2)
==> develop: - yum-mysql-community (2.1.0)
==> develop: - ark (3.1.0)
==> develop: - windows (3.4.3)
==> develop: - apt (6.1.4)
==> develop: - ulimit (0.4.0)
==> develop: - selinux_policy (2.0.1)
==> develop: - postgresql (6.1.1)
==> develop: - compat_resource (12.19.0)
==> develop: - runit (4.0.4)
==> develop: - yum (5.1.0)
==> develop: - ohai (5.2.0)
==> develop: - openssl (8.1.0)
==> develop: - mariadb (1.5.3)
==> develop: - yum-scl (0.2.0)
==> develop: - inifile_chef_gem (0.1.0)
==> develop: - packagecloud (0.3.0)
==> develop: Installing Cookbook Gems:
==> develop: Compiling Cookbooks...
==> develop: Converging 138 resources
While console output this message, I over wrote the cookbook mysql file as below.
default['yum']['mysql56-community']['repositoryid'] = 'mysql56-community'
default['yum']['mysql56-community']['gpgkey'] = 'http://raw.githubusercontent.com/chef-cookbooks/yum-mysql-community/master/files/mysql_pubkey.asc'
default['yum']['mysql56-community']['description'] = 'MySQL 5.6 Community Server'
default['yum']['mysql56-community']['failovermethod'] = 'priority'
default['yum']['mysql56-community']['gpgcheck'] = true
default['yum']['mysql56-community']['enabled'] = true
Everything went OK.
Now I could start virtual machine on my local.