修復了前段時間這樣的問題,但不知何故又陷入了一種困境 - 與我的腦袋混亂。使用Travis for E2廚師食譜配置實例創建實例後等待SSH服務掛起
對Sudo使用簡單的包裝烹飪書來演示使用EC2進行實例配置,配置和測試的Travis CI作業。
雖然兩者的默認佣金(以無業遊民測試)和CI版本成功地從本地機器運行 - 一個特拉維斯在運行時也將提供新的實例,並在無限循環再一次可等待...
Waiting for SSH service on ec2-xx-xx-xx-xx.compute-1.amazonaws.com:22, retrying in 3 seconds
Waiting for SSH service on ec2-xx-xx-xx-xx.compute-1.amazonaws.com:22, retrying in 3 seconds
Waiting for SSH service on ec2-xx-xx-xx-xx.compute-1.amazonaws.com:22, retrying in 3 seconds
關於如何糾正的任何想法?看起來Kitchen在Travis上運行時實際上並沒有拿起.pem。我試圖將其作爲在私有數據中心服務器上運行的Jenkins作業來嘗試複製Travis容器(例如,不是開發盒)上的條件,但實際上已經工作。所以這是關於Travis配置我缺少的東西。和設置在運輸connection_timeout似乎並沒有得到認可......
下面是相關的文件:
.kitchen.ec2.yml
provisioner:
name: chef_zero
platforms:
- name: cloud
driver_plugin: ec2
driver_config:
aws_access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %>
aws_secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
aws_ssh_key_id: <%= ENV['AWS_SSH_KEY_ID'] %>
aws_ssh_key_path: <%= ENV['AWS_SSH_KEY_PATH'] %>
image_id: ami-6d1c2007
require_chef_omnibus: true
instance_type: t2.nano
associate_public_ip: true
block_device_mappings:
- ebs_device_name: /dev/sda1
ebs_volume_size: 8
ebs_delete_on_termination: true
tags:
Name: ci
transport:
username: centos
ssh_key: 'org_aws_ci.pem'
connection_timeout: 10
connection_retries: 8
suites:
- name: default
run_list:
- recipe[org-sudo::default]
attributes:
的before_install解壓縮特拉維斯加密文件將org_aws_ci.pem放入本地文件夾 - 如上面的傳輸路徑所示,也是ENV密鑰路徑所在的位置。安全密鑰是所有必需的ENV變量。
.travis.yml
language: ruby
rvm:
- 2.2.0
before_install:
- openssl aes-256-cbc -K $encrypted_844f1325c8ef_key -iv $encrypted_844f1325c8ef_iv -in org_aws_ci.pem.enc -out org_aws_ci.pem -d
install:
- bundle install --without vagrant
- bundle exec berks install
script:
- bundle exec rake ci
env:
global:
- secure: <travis encrypted key>
- secure: <travis encrypted key>
- secure: <travis encrypted key>
- secure: <travis encrypted key>
Rake文件
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'foodcritic'
require 'kitchen'
namespace :style do
desc 'Run Ruby style checks'
RuboCop::RakeTask.new(:ruby)
desc 'Run Chef style checks'
FoodCritic::Rake::LintTask.new(:chef)
end
desc 'Run all style checks'
task style: %w(style:chef style:ruby)
namespace :integration do
desc 'Run Test Kitchen with Vagrant'
task :vagrant do
Kitchen.logger = Kitchen.default_file_logger
instance = Kitchen::Config.new.instances.get('default-local')
instance.test
end
desc 'Run Test Kitchen in EC2'
task :ec2 do
Kitchen.logger = Kitchen.default_file_logger
@loader = Kitchen::Loader::YAML.new(project_config: './.kitchen.ec2.yml')
config = Kitchen::Config.new(loader: @loader)
config.instances.each do |instance|
instance.test(:always)
end
end
end
desc 'Run ChefSpec examples'
RSpec::Core::RakeTask.new(:spec)
desc 'Validate .travis.yml format'
task :validatetravis do
sh 'travis lint --skip-completion-check'
end
task ci: %w(validatetravis style spec integration:ec2)
task default: %w(style spec integration:vagrant)