Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

kitchen converge fails on AWS ec2 windows instances with undefined method `version' for nil:NilClass (NoMethodError) #336

Closed
pinterl opened this issue Sep 1, 2017 · 4 comments
Assignees
Labels

Comments

@pinterl
Copy link

pinterl commented Sep 1, 2017

I have upgraded my Chef DK from version 1.0.3 to 2.1.11 and Ruby from 2.0.0 to ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]

Since that the Windows EC2 instance launch fails with
Failed to complete #create action: [undefined method `version' for nil:NilClass] on default-windows-2012r2

I can successfully launch RHEL7 EC2 instance with the same .kitchen.yml.

I suspect this is the line that fails:
if actual_platform.version =~ /2016/
The actual_platform is nil when the code is executed.

The kitchen diagnose --all output is

/Users/USER/.chefdk/gem/ruby/2.4.0/gems/kitchen-ec2-1.3.2/lib/kitchen/driver/ec2.rb:558:in `default_windows_user_data': undefined method `version' for nil:NilClass (NoMethodError)
	from /Users/pinterl/.chefdk/gem/ruby/2.4.0/gems/kitchen-ec2-1.3.2/lib/kitchen/driver/ec2.rb:62:in `block in <class:Ec2>'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/lazy_hash.rb:135:in `proc_or_val'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/lazy_hash.rb:76:in `[]'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/configurable.rb:119:in `block in diagnose'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/configurable.rb:119:in `each'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/configurable.rb:119:in `diagnose'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/instance.rb:245:in `block in diagnose'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/instance.rb:243:in `each'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/instance.rb:243:in `diagnose'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/diagnostic.rb:125:in `block in prepare_instances'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/diagnostic.rb:125:in `each'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/diagnostic.rb:125:in `prepare_instances'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/diagnostic.rb:52:in `read'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/command/diagnose.rb:38:in `call'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/cli.rb:53:in `perform'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/cli.rb:143:in `diagnose'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/cli.rb:334:in `invoke_task'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/bin/kitchen:13:in `block in <top (required)>'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/lib/kitchen/errors.rb:171:in `with_friendly_errors'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/test-kitchen-1.17.0/bin/kitchen:13:in `<top (required)>'
	from /usr/local/bin/kitchen:263:in `load'
	from /usr/local/bin/kitchen:263:in `<main>'

My Chef version is

chef --version
Chef Development Kit Version: 2.1.11
chef-client version: 13.2.20
delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
berks version: 6.3.0
kitchen version: 1.17.0
inspec version: 1.33.1

Ruby version

ruby --version
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]

My .kitchen.yml file is

driver:
  name: ec2
  region: us-east-1
  availability_zone: c
  subnet_id: MY_SUBNET
  aws_ssh_key_id: MY_KEY
  require_chef_omnibus: true
  associate_public_ip: false
  retryable_tries: 120
  retryable_sleep: 5
  tags:
    Name: TK_instance-utils_cookbook

provisioner:
  name: chef_zero

verifier:
  name: inspec

platforms:
  - name: windows-2012r2
    driver:
      image_id: "ami-c8d56fde"  #This value will be specific to dev or CI environment
      instance_type: m3.medium  #Can be changed to any AWS instance size
      security_group_ids: ['MY_SG']
      tags:
        Application-Role: MSW12R2|App
    transport:
      name: winrm
      elevated: true            # Required for the installation of some Windows features
      connection_timeout: 60
      connection_retries: 10
      username: MY_USER  #This value will be specific to dev or CI environment
      password: MY_PASSWORD #This value will be specific to dev or CI environment

  - name: rhel7
    driver:
      image_id: "ami-9534ad82"  #This value will be specific to dev or CI environment
      instance_type: m3.medium  #Can be changed to any AWS instance size
      block_device_mappings:
        - device_name: /dev/sda1
          ebs:
            volume_type: standard
            volume_size: 100
            delete_on_termination: true
      security_group_ids: [ 'MY_SG' ]  #This value will be specific to dev or CI area
      tags:
        Application-Role: RHL7|App
    transport:
      ssh_key: ~/.aws/MY_KEY.pem  #This value will be specific to dev or CI environment
      connection_timeout: 60
      connection_retries: 10
      username: ec2-user

suites:
  - name: default
    data_bags_path: "data_bags"
    encrypted_data_bag_secret_key_path: "../../data_bags/encrypted_data_bag_secret"
    verifier:
      inspec_tests:
        - test/recipes
    run_list:
      - recipe[utils::default]
    attributes:
      set_hostname: "TK_cookbook"

The Gem list is

gem list

*** LOCAL GEMS ***

activesupport (4.2.9)
addressable (2.5.2)
artifactory (2.8.2)
ast (2.3.0)
aws-partitions (1.17.0)
aws-sdk (3.0.1, 2.10.36)
aws-sdk-acm (1.0.0)
aws-sdk-apigateway (1.0.0)
aws-sdk-applicationautoscaling (1.1.0)
aws-sdk-applicationdiscoveryservice (1.0.0)
aws-sdk-appstream (1.0.0)
aws-sdk-athena (1.0.0)
aws-sdk-autoscaling (1.0.0)
aws-sdk-batch (1.0.0)
aws-sdk-budgets (1.0.0)
aws-sdk-clouddirectory (1.0.0)
aws-sdk-cloudformation (1.0.0)
aws-sdk-cloudfront (1.0.0)
aws-sdk-cloudhsm (1.1.0)
aws-sdk-cloudhsmv2 (1.0.0)
aws-sdk-cloudsearch (1.0.0)
aws-sdk-cloudsearchdomain (1.0.0)
aws-sdk-cloudtrail (1.0.0)
aws-sdk-cloudwatch (1.0.0)
aws-sdk-cloudwatchevents (1.0.0)
aws-sdk-cloudwatchlogs (1.0.0)
aws-sdk-codebuild (1.1.0)
aws-sdk-codecommit (1.0.0)
aws-sdk-codedeploy (1.0.0)
aws-sdk-codepipeline (1.0.0)
aws-sdk-codestar (1.0.0)
aws-sdk-cognitoidentity (1.0.0)
aws-sdk-cognitoidentityprovider (1.0.0)
aws-sdk-cognitosync (1.0.0)
aws-sdk-configservice (1.0.0)
aws-sdk-core (3.2.0, 2.10.36)
aws-sdk-costandusagereportservice (1.0.0)
aws-sdk-databasemigrationservice (1.0.0)
aws-sdk-datapipeline (1.0.0)
aws-sdk-dax (1.0.0)
aws-sdk-devicefarm (1.0.0)
aws-sdk-directconnect (1.0.0)
aws-sdk-directoryservice (1.0.0)
aws-sdk-dynamodb (1.0.0)
aws-sdk-dynamodbstreams (1.0.0)
aws-sdk-ec2 (1.1.0)
aws-sdk-ecr (1.0.0)
aws-sdk-ecs (1.0.0)
aws-sdk-efs (1.0.0)
aws-sdk-elasticache (1.0.0)
aws-sdk-elasticbeanstalk (1.0.0)
aws-sdk-elasticloadbalancing (1.0.0)
aws-sdk-elasticloadbalancingv2 (1.1.0)
aws-sdk-elasticsearchservice (1.0.0)
aws-sdk-elastictranscoder (1.0.0)
aws-sdk-emr (1.0.0)
aws-sdk-firehose (1.0.0)
aws-sdk-gamelift (1.0.0)
aws-sdk-glacier (1.0.0)
aws-sdk-glue (1.0.0)
aws-sdk-greengrass (1.0.0)
aws-sdk-health (1.0.0)
aws-sdk-iam (1.0.0)
aws-sdk-importexport (1.0.0)
aws-sdk-inspector (1.0.0)
aws-sdk-iot (1.0.0)
aws-sdk-iotdataplane (1.0.0)
aws-sdk-kinesis (1.0.0)
aws-sdk-kinesisanalytics (1.0.0)
aws-sdk-kms (1.0.0)
aws-sdk-lambda (1.0.0)
aws-sdk-lambdapreview (1.0.0)
aws-sdk-lex (1.0.0)
aws-sdk-lexmodelbuildingservice (1.1.0)
aws-sdk-lightsail (1.0.0)
aws-sdk-machinelearning (1.0.0)
aws-sdk-marketplacecommerceanalytics (1.0.0)
aws-sdk-marketplaceentitlementservice (1.0.0)
aws-sdk-marketplacemetering (1.0.0)
aws-sdk-migrationhub (1.0.0)
aws-sdk-mturk (1.0.0)
aws-sdk-opsworks (1.0.0)
aws-sdk-opsworkscm (1.0.0)
aws-sdk-organizations (1.1.0)
aws-sdk-pinpoint (1.0.0)
aws-sdk-polly (1.0.0)
aws-sdk-rds (1.0.0)
aws-sdk-redshift (1.0.0)
aws-sdk-rekognition (1.0.0)
aws-sdk-resourcegroupstaggingapi (1.0.0)
aws-sdk-resources (3.0.2, 2.10.36)
aws-sdk-route53 (1.0.0)
aws-sdk-route53domains (1.0.0)
aws-sdk-s3 (1.0.0)
aws-sdk-servicecatalog (1.0.0)
aws-sdk-ses (1.0.0)
aws-sdk-shield (1.0.0)
aws-sdk-simpledb (1.0.0)
aws-sdk-sms (1.0.0)
aws-sdk-snowball (1.0.0)
aws-sdk-sns (1.0.0)
aws-sdk-sqs (1.0.0)
aws-sdk-ssm (1.0.0)
aws-sdk-states (1.0.0)
aws-sdk-storagegateway (1.0.0)
aws-sdk-support (1.0.0)
aws-sdk-swf (1.0.0)
aws-sdk-waf (1.0.0)
aws-sdk-wafregional (1.0.0)
aws-sdk-workdocs (1.0.0)
aws-sdk-workspaces (1.0.0)
aws-sdk-xray (1.0.0)
aws-sigv2 (1.0.1)
aws-sigv4 (1.0.1)
berkshelf (6.3.1)
bigdecimal (default: 1.3.0)
blankslate (2.1.2.4)
buff-config (2.0.0)
buff-extensions (2.0.0)
buff-ignore (1.2.0)
buff-ruby_engine (1.0.0)
buff-shell_out (1.1.0)
builder (3.2.3)
bundler (1.15.4)
celluloid (0.16.0)
celluloid-io (0.16.2)
chef (13.3.42)
chef-config (13.3.42)
chef-zero (13.1.0)
chefstyle (0.5.0)
cleanroom (1.0.0)
climate_control (0.2.0)
coderay (1.1.1)
concurrent-ruby (1.0.5)
countloc (0.4.0)
did_you_mean (1.1.0)
diff-lcs (1.3)
docile (1.1.5)
docker-api (1.33.6)
erubis (2.7.0)
excon (0.58.0)
faraday (0.13.1)
faraday-http-cache (1.3.1)
ffi (1.9.18)
ffi-yajl (2.3.1)
fuzzyurl (0.9.0)
github_changelog_generator (1.14.3)
gssapi (1.2.0)
gyoku (1.3.1)
hashie (3.5.6)
highline (1.7.8)
hitimes (1.2.6)
htmlentities (4.3.4)
httpclient (2.8.3)
i18n (0.8.6)
iniparse (1.4.4)
inspec (1.34.1)
io-console (default: 0.4.6)
ipaddress (0.8.3)
iso8601 (0.9.1)
jmespath (1.3.1)
json (2.1.0, default: 2.0.2)
kitchen-ec2 (1.3.2)
kitchen-inspec (0.19.0)
libyajl2 (1.2.0)
little-plugger (1.1.4)
logging (2.2.2)
maruku (0.7.3)
method_source (0.8.2)
minitar (0.6.1)
minitest (5.10.3, 5.10.1)
mixlib-archive (0.4.1)
mixlib-authentication (1.4.2)
mixlib-cli (1.7.0)
mixlib-config (2.2.4)
mixlib-install (2.1.12)
mixlib-log (1.7.1)
mixlib-shellout (2.3.2)
mixlib-versioning (1.2.2)
molinillo (0.6.2)
multi_json (1.12.1)
multipart-post (2.0.0)
net-scp (1.2.1)
net-sftp (2.1.2)
net-ssh (4.1.0)
net-ssh-gateway (1.3.0)
net-ssh-multi (1.2.1)
net-telnet (0.1.1)
nio4r (2.1.0)
nori (2.6.0)
octokit (4.7.0)
ohai (13.3.0)
openssl (default: 2.0.3)
parallel (1.12.0)
parser (2.4.0.0)
parslet (1.5.0)
plist (3.3.0)
power_assert (0.4.1)
powerpack (0.1.1)
proxifier (1.0.3)
pry (0.10.4)
psych (default: 2.2.2)
public_suffix (3.0.0)
rack (2.0.3)
rainbow (2.2.2)
rake (12.0.0)
rdoc (default: 5.0.0)
retriable (2.1.0)
retryable (2.0.4)
ridley (5.1.1)
rspec (3.6.0)
rspec-core (3.6.0)
rspec-expectations (3.6.0)
rspec-its (1.2.0)
rspec-mocks (3.6.0)
rspec-support (3.6.0)
rspec_junit_formatter (0.2.3)
rubocop (0.47.1)
ruby-progressbar (1.8.1)
rubyntlm (0.6.2)
rubyzip (1.2.1)
safe_yaml (1.0.4)
sawyer (0.8.1)
semverse (2.0.0)
serverspec (2.40.0)
sfl (2.3)
simplecov (0.15.0)
simplecov-html (0.10.2)
slop (3.6.0)
solve (4.0.0)
specinfra (2.71.0)
sslshake (1.2.0)
syslog-logger (1.6.8)
systemu (2.6.5)
test-kitchen (1.17.0)
test-unit (3.2.3)
thor (0.19.1)
thread_safe (0.3.6)
timers (4.0.4)
toml (0.1.2)
train (0.26.1)
tzinfo (1.2.3)
unicode-display_width (1.3.0)
uuidtools (2.1.5)
varia_model (0.6.0)
winrm (2.2.3, 1.8.1)
winrm-elevated (1.1.0)
winrm-fs (1.0.1, 0.4.3)
winrm-transport (1.0.4)
wmi-lite (1.0.0)
xmlrpc (0.2.1)
yard (0.9.9)
@phillipbroberts
Copy link

I am actually seeing the same issue, upgraded my chefdk as well to be sure it wasn't something solved in an update. I have tried various combinations of the platform name as well.

@rlaveycal
Copy link
Contributor

Just had this as well trying to use a custom AMI. It was because the AMI name has to conform to a naming convention so that the OS version can be extracted ("Windows 2016"). #230 covers the requirement for a better error message.

@cheeseplus cheeseplus self-assigned this Oct 4, 2017
@dsahni
Copy link

dsahni commented Oct 26, 2017

Also ran into this issue with a custom Windows AMI, @rlaveycal is right. Had to copy the existing AMI into a new AMI, since "AMI Name" isn't editable. Specifying the new "AMI Name" as windows-2012r2 worked fine in Kitchen.

@cheeseplus
Copy link
Contributor

Closing this one as it isn't a bug per-say so much as non-informative error messages as covered by #230 - closing this one since it's not quite a bug and we're tracking the work to make this clearer in #230.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants