chef-boneyard/chef-dk

chef exec breaks kitchen ec2 driver

voroniys opened this issue · 2 comments

Description

When I do

chef exec kitchen create

it is broken, while just

kitchen create

works fine.

ChefDK Version

3.6.57-1

Platform Version

Ubuntu 18.04 on EC2

Replication Case

I have the following configuration for kitchen driver:

driver:
  name: ec2
  aws_ssh_key_id: Kitchen-key
  security_group_filter:
    tag:   'Name'
    value: 'shared-kitchen'
  region: eu-west-1
  availability_zone: b
  require_chef_omnibus: true
  subnet_filter:
    tag:   'Name'
    value: 'app-eu-west-1b'
  instance_type: t3.micro
  tags:
    Name: 'test-kitchen'
  associate_public_ip: false
  interface: private_dns

transport:
  ssh_key: ~/.chef/kitchen-rsa
  connection_timeout: 10
  connection_retries: 5


provisioner:
  name: chef_zero
  # You may wish to disable always updating cookbooks in CI or other testing environments.
  # For example:
  #   always_update_cookbooks: <%= !ENV['CI'] %>
  always_update_cookbooks: true

verifier:
  name: inspec

platforms:
  - name: ubuntu-18.04
    driver:
      image_search:
        owner-id: "099720109477"
        name: ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*
    transport:
      username: ubuntu
  - name: amazon2-2018
    driver:
      image_search:
        owner-id: "137112412989"
        name: amzn2-ami-hvm-*-x86_64-gp2
    transport:
      username: ec2-user

Now, if I run chef exec kitchen create it fails. while just kitchen create succeeded:

chef exec kitchen create
-----> Starting Kitchen (v1.24.0)
-----> Creating <default-ubuntu-1804>...
       Detected platform: ubuntu version 18.04 on x86_64. Instance Type: t3.micro. Default username: ubuntu (default).
       If you are not using an account that qualifies under the AWS
free-tier, you may be charged to run these suites. The charge
should be minimal, but neither Test Kitchen nor its maintainers
are responsible for your incurred costs.

-----> Creating <default-amazon2-2018>...
       Detected platform: amazon2 version 2017.12. on x86_64. Instance Type: t3.micro. Default username: ec2-user (default).
       If you are not using an account that qualifies under the AWS
free-tier, you may be charged to run these suites. The charge
should be minimal, but neither Test Kitchen nor its maintainers
are responsible for your incurred costs.

>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 2 actions failed.
>>>>>>     Failed to complete #create action: [undefined method `subnet_id' for nil:NilClass] on default-ubuntu-1804
>>>>>>     Failed to complete #create action: [undefined method `subnet_id' for nil:NilClass] on default-amazon2-2018
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

while

kitchen create -c 2
-----> Starting Kitchen (v1.24.0)
-----> Creating <default-ubuntu-1804>...
-----> Creating <default-amazon2-2018>...
       Detected platform: amazon2 version 2017.12. on x86_64. Instance Type: t3.micro. Default username: ec2-user (default).
       If you are not using an account that qualifies under the AWS
free-tier, you may be charged to run these suites. The charge
should be minimal, but neither Test Kitchen nor its maintainers
are responsible for your incurred costs.

       Detected platform: ubuntu version 18.04 on x86_64. Instance Type: t3.micro. Default username: ubuntu (default).
       If you are not using an account that qualifies under the AWS
free-tier, you may be charged to run these suites. The charge
should be minimal, but neither Test Kitchen nor its maintainers
are responsible for your incurred costs.

       Instance <i-0b188609c1dc9dc12> requested.
       Polling AWS for existence, attempt 0...
       Instance <i-02fd89632fd7c8da6> requested.
       Polling AWS for existence, attempt 0...
       Attempting to tag the instance, 0 retries
       Attempting to tag the instance, 0 retries
       EC2 instance <i-0b188609c1dc9dc12> created.
       Waited 0/300s for instance <i-0b188609c1dc9dc12> volumes to be ready.
       EC2 instance <i-02fd89632fd7c8da6> created.
       Waited 0/300s for instance <i-02fd89632fd7c8da6> volumes to be ready.
       Waited 0/300s for instance <i-0b188609c1dc9dc12> to become ready.
       Waited 0/300s for instance <i-02fd89632fd7c8da6> to become ready.
       Waited 5/300s for instance <i-0b188609c1dc9dc12> to become ready.
       Waited 5/300s for instance <i-02fd89632fd7c8da6> to become ready.
       Waited 10/300s for instance <i-0b188609c1dc9dc12> to become ready.
       Waited 10/300s for instance <i-02fd89632fd7c8da6> to become ready.
       Waited 15/300s for instance <i-0b188609c1dc9dc12> to become ready.
       EC2 instance <i-0b188609c1dc9dc12> ready (hostname: ip-172-17-5-235.eu-west-1.compute.internal).
       Waited 15/300s for instance <i-02fd89632fd7c8da6> to become ready.
       EC2 instance <i-02fd89632fd7c8da6> ready (hostname: ip-172-17-5-202.eu-west-1.compute.internal).
       Waiting for SSH service on ip-172-17-5-202.eu-west-1.compute.internal:22, retrying in 3 seconds
       [SSH] Established
       Finished creating <default-amazon2-2018> (0m26.69s).
       [SSH] Established
       Finished creating <default-ubuntu-1804> (0m30.37s).
-----> Kitchen is finished. (0m35.93s)

Stacktrace

I, [2019-02-05T09:13:37.948391 #28760]  INFO -- Kitchen: -----> Starting Kitchen (v1.24.0)
I, [2019-02-05T09:13:43.609119 #28760]  INFO -- Kitchen: -----> Creating <default-ubuntu-1804>...
I, [2019-02-05T09:13:44.838151 #28760]  INFO -- Kitchen: -----> Creating <default-amazon2-2018>...
E, [2019-02-05T09:13:45.755227 #28760] ERROR -- Kitchen: ------Exception-------
E, [2019-02-05T09:13:45.755273 #28760] ERROR -- Kitchen: Class: Kitchen::ActionFailed
E, [2019-02-05T09:13:45.755285 #28760] ERROR -- Kitchen: Message: 2 actions failed.
>>>>>>     Failed to complete #create action: [undefined method `subnet_id' for nil:NilClass] on default-ubuntu-1804
>>>>>>     Failed to complete #create action: [undefined method `subnet_id' for nil:NilClass] on default-amazon2-2018
E, [2019-02-05T09:13:45.755297 #28760] ERROR -- Kitchen: ----------------------
E, [2019-02-05T09:13:45.755310 #28760] ERROR -- Kitchen: ------Backtrace-------
E, [2019-02-05T09:13:45.755319 #28760] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.24.0/lib/kitchen/command.rb:183:in `report_errors'
E, [2019-02-05T09:13:45.755330 #28760] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.24.0/lib/kitchen/command.rb:174:in `run_action'
E, [2019-02-05T09:13:45.755340 #28760] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.24.0/lib/kitchen/command/action.rb:36:in `block in call'
E, [2019-02-05T09:13:45.755350 #28760] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/2.5.0/benchmark.rb:293:in `measure'
E, [2019-02-05T09:13:45.755361 #28760] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.24.0/lib/kitchen/command/action.rb:34:in `call'
E, [2019-02-05T09:13:45.755371 #28760] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.24.0/lib/kitchen/cli.rb:52:in `perform'
E, [2019-02-05T09:13:45.755381 #28760] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.24.0/lib/kitchen/cli.rb:193:in `block (2 levels) in <class:CLI>'
E, [2019-02-05T09:13:45.755391 #28760] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
E, [2019-02-05T09:13:45.755400 #28760] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
E, [2019-02-05T09:13:45.755410 #28760] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
E, [2019-02-05T09:13:45.755420 #28760] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
E, [2019-02-05T09:13:45.755429 #28760] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.24.0/bin/kitchen:13:in `block in <top (required)>'
E, [2019-02-05T09:13:45.755440 #28760] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.24.0/lib/kitchen/errors.rb:171:in `with_friendly_errors'
E, [2019-02-05T09:13:45.755454 #28760] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.24.0/bin/kitchen:13:in `<top (required)>'
E, [2019-02-05T09:13:45.755464 #28760] ERROR -- Kitchen: /opt/chefdk/bin/kitchen:306:in `load'
E, [2019-02-05T09:13:45.755474 #28760] ERROR -- Kitchen: /opt/chefdk/bin/kitchen:306:in `<main>'
E, [2019-02-05T09:13:45.755483 #28760] ERROR -- Kitchen: ----End Backtrace-----

NOTE: CHEFDK BUGS ONLY

This issue tracker is for the code contained within this repo -- chefdk.

The issue is caused by difference in environment (AWS assume role profile not set when running via chef exec)

lock commented

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.