Кухонные тесты от шеф-повара, как сдать несколько поваренных книг от шеф-повара AWS Opsworks? - PullRequest
0 голосов
/ 01 октября 2018

Я пытаюсь проверить поваренные книги Chef на ОС Centos 7.

Я следую https://learn.chef.io/modules/local-development/rhel/virtualbox/apply-a-cookbook#/

---
driver:
  # specifies the software that manages the machine. We're using the Vagrant Test Kitchen driver
  name: vagrant

provisioner:
  #  specifies how to run Chef. We use chef_zero because it enables you to mimic a Chef server environment on your local machine. This allows us to work with node attributes and other Chef server feature
  name: chef_zero
  chef_environment: dev # how to detect my JSON node config ?

verifier:
  # specifies which application to use when running automated tests. You'll learn more about automated testing in a future module.
  name: inspec

platforms:
  - name: centos-7

suites:
  - name: default
    run_list:
      # list of cookbooks
      - recipe[learn_chef_httpd::default]
    attributes:

Как заменить recipe[learn_chef_httpd::default] полным каталогом поваренных книг?Что-то вроде режим opsworks :

Config
Gemfile
LICENSE
README.md
Rakefile
foobar_app_drupal/
foobar_app_joomla/
foobar_app_magento/
foobar_app_magento2/
foobar_app_marello/
foobar_app_nginxconfig/
foobar_app_orocommerce/
foobar_app_orocrm/
foobar_app_phpapp/
foobar_app_prestashop/
foobar_app_satis/
foobar_app_symfony/
foobar_app_symfony3/
foobar_app_typo/
foobar_app_wordpress/
foobar_composer/
foobar_crontab/
foobar_efs/
foobar_htpasswd/
foobar_logs/
foobar_quanta/
foobar_sftp_users/
foobar_varnish/
dependencies/
deploy/
ebs/
gem_support/
haproxy/
memcached/
mod_php5_apache2/
mysql/
nginx/
opsworks_agent_monit/
opsworks_aws_flow_ruby/
opsworks_berkshelf/
opsworks_bundler/
opsworks_cleanup/
opsworks_commons/
opsworks_custom_cookbooks/
opsworks_ecs/
opsworks_ganglia/
opsworks_initial_setup/
opsworks_java/
opsworks_nodejs/
opsworks_postgresql/
opsworks_rubygems/
opsworks_shutdown/
opsworks_stack_state_sync/
packages/
passenger_apache2/

Файл recipes/default.rb:

package 'httpd'

service 'httpd' do
  action [:enable, :start]
end

template '/var/www/html/index.html' do # ~FC033
  source 'index.html.erb'
end

Может быть, я могу заменить все строки, включая все поваренные книги?Пожалуйста, покажите мне, как это возможно

Может быть что-то вроде:

include_recipe 'opsworks_initial_setup/recipes/default.rb'
include_recipe 'foobar/recipes/setup.rb'

?

Мне тоже нужно использовать конфигурацию JSON узла.

Каквключить этот конфиг?

Редактировать : мои файлы изменены, как вы объясняете, но теперь у меня есть следующая ошибка на kitchen converge:

       System Info:
       ------------
       chef_version=14.5.33
       platform=centos
       platform_version=7.5.1804
       ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
       program_name=/opt/chef/bin/chef-client
       executable=/opt/chef/bin/chef-client


       Running handlers:
       [2018-10-02T14:22:32+00:00] ERROR: Running exception handlers
       Running handlers complete
       [2018-10-02T14:22:32+00:00] ERROR: Exception handlers complete
       Chef Client failed. 0 resources updated in 01 seconds
       [2018-10-02T14:22:32+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2018-10-02T14:22:32+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2018-10-02T14:22:32+00:00] FATAL: Chef::Exceptions::CookbookNotFound: Cookbook opsworks_initial_setup not found. If you're loading opsworks_initial_setup from another cookbook, make sure you configure the dependency in your metadata
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Converge failed on instance <default-centos-7>.  Please see .kitchen/logs/default-centos-7.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

sshк экземпляру Centos:

[root@default-centos-7 kitchen]# cat /tmp/kitchen/cache/chef-stacktrace.out 
Generated at 2018-10-02 14:22:32 +0000
Chef::Exceptions::CookbookNotFound: Cookbook opsworks_initial_setup not found. If you're loading opsworks_initial_setup from another cookbook, make sure you configure the dependency in your metadata
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/cookbook/cookbook_collection.rb:39:in `block in initialize'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/ohai-14.5.4/lib/ohai/mash.rb:72:in `default'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/ohai-14.5.4/lib/ohai/mash.rb:72:in `default'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/run_context.rb:349:in `[]'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/run_context.rb:349:in `load_recipe'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/run_context.rb:306:in `block in include_recipe'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/run_context.rb:305:in `each'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/run_context.rb:305:in `include_recipe'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/dsl/include_recipe.rb:26:in `include_recipe'
/tmp/kitchen/cache/cookbooks/learn_chef_httpd/recipes/default.rb:20:in `from_file'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/mixin/from_file.rb:34:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/mixin/from_file.rb:34:in `from_file'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/cookbook_version.rb:199:in `load_recipe'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/run_context.rb:350:in `load_recipe'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/run_context/cookbook_compiler.rb:166:in `block in compile_recipes'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/run_context/cookbook_compiler.rb:163:in `each'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/run_context/cookbook_compiler.rb:163:in `compile_recipes'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/run_context/cookbook_compiler.rb:79:in `compile'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/run_context.rb:199:in `load'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/policy_builder/expand_node_object.rb:97:in `setup_run_context'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/client.rb:515:in `setup_run_context'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/client.rb:281:in `run'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/application.rb:303:in `run_with_graceful_exit_option'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/application.rb:279:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/application.rb:261:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/application/client.rb:440:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/lib/chef/application.rb:66:in `run'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.5.33/bin/chef-client:25:in `<top (required)>'
/opt/chef/bin/chef-client:75:in `load'

1 Ответ

0 голосов
/ 02 октября 2018

Вы должны указать cookbook_path для своего провайдера, , например, .

Что касается включения, один из подходящих форматов:

<cookbook name>::<recipe name>

Так что вваш случай:

include_recipe 'opsworks_initial_setup::default'
include_recipe 'foobar::setup'

Конфигурация JSON может быть передана файлом среды :

provisioner:
  name: chef_zero
  environments_path: 'path/to/environments/directory'
  client_rb:
    environment: staging

Необходимо создать файл staging.json со структурой, описанной в документации.

...