Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

doesn't invoke test while using ec2 driver #37

Closed
JigarJoshi opened this issue Feb 20, 2014 · 9 comments
Closed

doesn't invoke test while using ec2 driver #37

JigarJoshi opened this issue Feb 20, 2014 · 9 comments

Comments

@JigarJoshi
Copy link
Contributor

This is my .kitchen.yml looks like, if I switch driver back to vagrant it is able to create virtual box instance and invoke the tests on it


---
driver:
name: ec2
aws_access_key_id: SOME_KEY
aws_secret_access_key: SOME_KEY
aws_ssh_key_id: id_rsa-aws
ssh_key: /path/to/jigaraws.pem
security_group_ids: ["SOME_GROUP"]
region: us-west-2
availability_zone: us-west-2c
require_chef_omnibus: true
subnet_id: SOME_SUBNET

provisioner:
  name: chef_solo

platforms:
  - name: centos-6.4

suites:
  - name: default
    run_list:
      - recipe[ci-somerecipe::default]
    attributes:

but if I use ec2 driver it just exists with exit code 0 in less than a second and with following output

-----> Starting Kitchen (v1.2.1)
-----> Cleaning up any prior instances of <default-centos-64>
-----> Destroying <default-centos-64>...
       [Dummy] Destroy on instance=#<Kitchen::Instance:0x000001018bf248> with state={}
       Finished destroying <default-centos-64> (0m0.00s).
-----> Testing <default-centos-64>
-----> Creating <default-centos-64>...
       [Dummy] Create on instance=#<Kitchen::Instance:0x000001018bf248> with state={:my_id=>"default-centos-64-1392858588"}
       Finished creating <default-centos-64> (0m0.00s).
-----> Converging <default-centos-64>...
       [Dummy] Converge on instance=#<Kitchen::Instance:0x000001018bf248> with state={:my_id=>"default-centos-64-1392858588", :last_action=>"create"}
       Finished converging <default-centos-64> (0m0.00s).
-----> Setting up <default-centos-64>...
       [Dummy] Setup on instance=#<Kitchen::Instance:0x000001018bf248> with state={:my_id=>"default-centos-64-1392858588", :last_action=>"converge"}
       Finished setting up <default-centos-64> (0m0.00s).
-----> Verifying <default-centos-64>...
       [Dummy] Verify on instance=#<Kitchen::Instance:0x000001018bf248> with state={:my_id=>"default-centos-64-1392858588", :last_action=>"setup"}
       Finished verifying <default-centos-64> (0m0.00s).
-----> Destroying <default-centos-64>...
       [Dummy] Destroy on instance=#<Kitchen::Instance:0x000001018bf248> with state={:my_id=>"default-centos-64-1392858588", :last_action=>"verify"}
       Finished destroying <default-centos-64> (0m0.00s).
       Finished testing <default-centos-64> (0m0.01s).
-----> Kitchen is finished. (0m0.80s)

Did I miss something in configuration ? I am expecting it to spin up an instance on ec2 and execute bats test against it

@fnichol
Copy link
Contributor

fnichol commented Feb 21, 2014

Yes that is strange and looks like the built in dummy (no-op) driver is getting selected.

Could you post the result of kitchen diagnose --all to see what might be happening? Just be sure to scan & scrub the output for secrets before posting. Thanks!

@JigarJoshi
Copy link
Contributor Author

Here is the output

kitchen diagnose --all
---
timestamp: 2014-02-21 02:35:01.487773000 Z
kitchen_version: 1.2.1
loader:
  process_erb: true
  process_local: true
  process_global: true
  global_config: 
  project_config:
    filename: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic/.kitchen.yml"
    raw_data:
      driver: 
      name: ec2
      aws_access_key_id: SOME_KEY
      aws_secret_access_key: SOME_OTHER_KEY
      aws_ssh_key_id: id_rsa-aws
      ssh_key: "/path/to/some_key.pem"
      security_group_ids:
      - SOME_GROUP
      region: us-west-2
      availability_zone: us-west-2c
      require_chef_omnibus: true
      subnet_id: SOME_SUBNET
      provisioner:
        name: chef_solo
      platforms:
      - name: ubuntu-12.04
      - name: centos-6.4
      suites:
      - name: default
        run_list:
        - recipe[ci-foodcritic::default]
        attributes: 
  local_config: 
  combined_config:
    filename: 
    raw_data:
      driver: {}
      name: ec2
      aws_access_key_id: SOME_KEY
      aws_secret_access_key: SOME_OTHER_KEY
      aws_ssh_key_id: id_rsa-aws
      ssh_key: "/path/to/key.pem"
      security_group_ids:
      - SOME_GROUP
      region: us-west-2
      availability_zone: us-west-2c
      require_chef_omnibus: true
      subnet_id: SOME_SUBNET
      provisioner:
        name: chef_solo
      platforms:
      - name: ubuntu-12.04
      - name: centos-6.4
      suites:
      - name: default
        run_list:
        - recipe[ci-foodcritic::default]
        attributes: 
instances:
  default-ubuntu-1204:
    state_file: {}
    driver:
      kitchen_root: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic"
      log_level: :info
      name: dummy
      random_failure: false
      sleep: 0
      test_base_path: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic/test/integration"
    provisioner:
      attributes: {}
      chef_omnibus_url: https://www.getchef.com/chef/install.sh
      clients_path: 
      cookbook_files_glob: README.*,metadata.{json,rb},attributes/**/*,definitions/**/*,files/**/*,libraries/**/*,providers/**/*,recipes/**/*,resources/**/*,templates/**/*
      data_bags_path: 
      data_path: 
      encrypted_data_bag_secret_key_path: 
      environments_path: 
      kitchen_root: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic"
      log_level: :info
      name: chef_solo
      nodes_path: 
      require_chef_omnibus: true
      roles_path: 
      root_path: "/tmp/kitchen"
      run_list:
      - recipe[ci-foodcritic::default]
      solo_rb: {}
      sudo: true
      test_base_path: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic/test/integration"
    busser:
      busser_bin: "/tmp/busser/bin/busser"
      kitchen_root: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic"
      root_path: "/tmp/busser"
      ruby_bindir: "/opt/chef/embedded/bin"
      sudo: true
      suite_name: default
      test_base_path: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic/test/integration"
      version: busser
  default-centos-64:
    state_file: {}
    driver:
      kitchen_root: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic"
      log_level: :info
      name: dummy
      random_failure: false
      sleep: 0
      test_base_path: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic/test/integration"
    provisioner:
      attributes: {}
      chef_omnibus_url: https://www.getchef.com/chef/install.sh
      clients_path: 
      cookbook_files_glob: README.*,metadata.{json,rb},attributes/**/*,definitions/**/*,files/**/*,libraries/**/*,providers/**/*,recipes/**/*,resources/**/*,templates/**/*
      data_bags_path: 
      data_path: 
      encrypted_data_bag_secret_key_path: 
      environments_path: 
      kitchen_root: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic"
      log_level: :info
      name: chef_solo
      nodes_path: 
      require_chef_omnibus: true
      roles_path: 
      root_path: "/tmp/kitchen"
      run_list:
      - recipe[ci-foodcritic::default]
      solo_rb: {}
      sudo: true
      test_base_path: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic/test/integration"
    busser:
      busser_bin: "/tmp/busser/bin/busser"
      kitchen_root: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic"
      root_path: "/tmp/busser"
      ruby_bindir: "/opt/chef/embedded/bin"
      sudo: true
      suite_name: default
      test_base_path: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic/test/integration"
      version: busser
      global_config: 
      project_config:
        filename: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic/.kitchen.yml"
        raw_data:
          driver:
            name: vagrant
          provisioner:
            name: chef_solo
          platforms:
          - name: ubuntu-12.04
          - name: centos-6.4
          suites:
          - name: default
            run_list:
            - recipe[ci-foodcritic::default]
            attributes: 
      local_config: 
      combined_config:
        filename: 
        raw_data:
          driver:
            name: vagrant
          provisioner:
            name: chef_solo
          platforms:
          - name: ubuntu-12.04
          - name: centos-6.4
          suites:
          - name: default
            run_list:
            - recipe[ci-foodcritic::default]
            attributes: 
    instances:
      default-ubuntu-1204:
        state_file: {}
        driver:
          box: opscode-ubuntu-12.04
          box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04_chef-provisionerless.box
          customize:
            memory: '256'
          kitchen_root: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic"
          log_level: :info
          name: vagrant
          network: []
          port: 22
          pre_create_command: 
          provider: virtualbox
          sudo: true
          synced_folders: []
          test_base_path: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic/test/integration"
          vagrantfile_erb: "/Users/jigar.joshi/.rvm/gems/ruby-2.1.0/gems/kitchen-vagrant-0.14.0/templates/Vagrantfile.erb"
          vm_hostname: default-ubuntu-1204.vagrantup.com
        provisioner:
          attributes: {}
          chef_omnibus_url: https://www.getchef.com/chef/install.sh
          clients_path: 
          cookbook_files_glob: README.*,metadata.{json,rb},attributes/**/*,definitions/**/*,files/**/*,libraries/**/*,providers/**/*,recipes/**/*,resources/**/*,templates/**/*
          data_bags_path: 
          data_path: 
          encrypted_data_bag_secret_key_path: 
          environments_path: 
          kitchen_root: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic"
          log_level: :info
          name: chef_solo
          nodes_path: 
          require_chef_omnibus: true
          roles_path: 
          root_path: "/tmp/kitchen"
          run_list:
          - recipe[ci-foodcritic::default]
          solo_rb: {}
          sudo: true
          test_base_path: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic/test/integration"
        busser:
          busser_bin: "/tmp/busser/bin/busser"
          kitchen_root: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic"
          root_path: "/tmp/busser"
          ruby_bindir: "/opt/chef/embedded/bin"
          sudo: true
          suite_name: default
          test_base_path: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic/test/integration"
          version: busser
      default-centos-64:
        state_file: {}
        driver:
          box: opscode-centos-6.4
          box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.4_chef-provisionerless.box
          customize:
            memory: '256'
          kitchen_root: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic"
          log_level: :info
          name: vagrant
          network: []
          port: 22
          pre_create_command: 
          provider: virtualbox
          sudo: true
          synced_folders: []
          test_base_path: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic/test/integration"
          vagrantfile_erb: "/Users/jigar.joshi/.rvm/gems/ruby-2.1.0/gems/kitchen-vagrant-0.14.0/templates/Vagrantfile.erb"
          vm_hostname: default-centos-64.vagrantup.com
        provisioner:
          attributes: {}
          chef_omnibus_url: https://www.getchef.com/chef/install.sh
          clients_path: 
          cookbook_files_glob: README.*,metadata.{json,rb},attributes/**/*,definitions/**/*,files/**/*,libraries/**/*,providers/**/*,recipes/**/*,resources/**/*,templates/**/*
          data_bags_path: 
          data_path: 
          encrypted_data_bag_secret_key_path: 
          environments_path: 
          kitchen_root: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic"
          log_level: :info
          name: chef_solo
          nodes_path: 
          require_chef_omnibus: true
          roles_path: 
          root_path: "/tmp/kitchen"
          run_list:
          - recipe[ci-foodcritic::default]
          solo_rb: {}
          sudo: true
          test_base_path: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic/test/integration"
        busser:
          busser_bin: "/tmp/busser/bin/busser"
          kitchen_root: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic"
          root_path: "/tmp/busser"
          ruby_bindir: "/opt/chef/embedded/bin"
          sudo: true
          suite_name: default
          test_base_path: "/Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic/test/integration"
          version: busser

@fnichol
Copy link
Contributor

fnichol commented Feb 21, 2014

@JigarJoshi ok, I think I see here; you'll need to indent the configuration under the driver: line, typically with 2 spaces like so:

---
driver:
  name: ec2
  aws_access_key_id: SOME_KEY
  aws_secret_access_key: SOME_KEY
  aws_ssh_key_id: id_rsa-aws
  ssh_key: /path/to/jigaraws.pem
  security_group_ids: ["SOME_GROUP"]
  region: us-west-2
  availability_zone: us-west-2c
  require_chef_omnibus: true
  subnet_id: SOME_SUBNET

What the kitchen diagnose output showed was and empty hash value for driver in the loader section.

@JigarJoshi
Copy link
Contributor Author

Thanks @fnichol it got further!

Now the config is like

---
driver:
  name: ec2
  aws_access_key_id: SOME_KEY
  aws_secret_access_key: SOME_OTHER_KEY
  aws_ssh_key_id: id_rsa-aws
  ssh_key: /path/to/key.pem
  region: us-west-2
  availability_zone: us-west-2c
  require_chef_omnibus: true
  subnet_id: SOME_SUBNET
  security_group_ids: ["SOME_SEC_GROUP"]
  vpc_mode: true
  vpc: SOME_VPC_ID
provisioner:
  name: chef_solo

platforms:
  - name: centos-6.4

suites:
  - name: default
    run_list:
      - recipe[ci-foodcritic::default]
    attributes:

and error message is

>>>>>> Create failed on instance <default-centos-64>.
>>>>>> Please see .kitchen/logs/default-centos-64.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: InvalidParameterCombination => The parameter groupName cannot be used with the parameter subnet
>>>>>> ----------------------

Googling around, looks like this is common issue with confusing error message, I will update more

@JigarJoshi
Copy link
Contributor Author

this is very common error it seems, with lots of forum results, all suggesting change from security_group_name to security_group_ids, this configuration and code both uses later field, if I remove subnet_id from config it fails with Message: VPCIdNotSpecified => No default VPC for this user in this case can we pass vpc from configuration ? or in the first case if there is any workaround/fix

$ kitchen test --log-level=DEBUG
-----> Starting Kitchen (v1.2.1)
D      Berksfile found at /Users/jigar.joshi/dev-chef/dev-chef/cookbooks/ci-foodcritic/Berksfile, loading Berkshelf
D      Berkshelf 2.0.14 library loaded
-----> Cleaning up any prior instances of <default-centos-64>
-----> Destroying <default-centos-64>...
       Finished destroying <default-centos-64> (0m0.00s).
-----> Testing <default-centos-64>
-----> Creating <default-centos-64>...
D      ec2:region 'us-west-2'
D      ec2:availability_zone 'us-west-2c'
D      ec2:flavor_id 'm1.small'
D      ec2:ebs_optimized 'false'
D      ec2:image_id 'ami-b3bf2f83'
D      ec2:security_group_ids '["default"]'
D      ec2:tags '{"created-by"=>"test-kitchen"}'
D      ec2:key_name 'jigaraws'
D      ec2:subnet_id 'SOME_SUBNET_ID'
[fog][WARNING] Unable to load the 'unf' gem. Your AWS strings may not be properly encoded.
>>>>>> Create failed on instance <default-centos-64>.
>>>>>> Please see .kitchen/logs/default-centos-64.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: InvalidParameterCombination => The parameter groupName cannot be used with the parameter subnet
>>>>>> ----------------------
D      Create failed on instance <default-centos-64>.
D      ------Exception-------
D      Class: Kitchen::InstanceFailure
D      Message: Create failed on instance <default-centos-64>.  Please see .kitchen/logs/default-centos-64.log for more details
D      ---Nested Exception---
D      Class: Kitchen::ActionFailed
D      Message: InvalidParameterCombination => The parameter groupName cannot be used with the parameter subnet
D      ------Backtrace-------
D      /Users/jigar.joshi/.rvm/gems/ruby-2.1.0/gems/kitchen-ec2-0.8.0/lib/kitchen/driver/ec2.rb:80:in `rescue in create'
D      /Users/jigar.joshi/.rvm/gems/ruby-2.1.0/gems/kitchen-ec2-0.8.0/lib/kitchen/driver/ec2.rb:69:in `create'
D      /Users/jigar.joshi/.rvm/gems/ruby-2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/instance.rb:273:in `public_send'

@JigarJoshi
Copy link
Contributor Author

looks like fog/fog#713 security_group_ids & subnet_id cannot co-exists, if I comment out the line where it sets sec group in ec2.rb on method connection.servers.create it passes and goes ahead and starts the instance with default security group, since it is in vpc mode if I change the security group back test kitchen is able to go further and progresses, looks like we are out of sync with fog in parameter names

@JigarJoshi
Copy link
Contributor Author

I was using security_group_name instead of id, it works I can startup instance with specific security_group_id (associated vpc) and subnet_id

Thanks!

@esciara
Copy link

esciara commented Dec 30, 2014

Had the same problem and took me a while to find the solution. Thanks for the post, it helped a lot.

Final working configuration for me is:

driver:
  aws_access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %>
  aws_secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
  aws_ssh_key_id: <%= ENV['AWS_KEYPAIR_NAME'] %>
  region: <%= ENV['AWS_REGION'] %>
  availability_zone: <%= ENV['AWS_AVAILABILITY_ZONE'] %>

provisioner:
  name: chef_zero
  require_chef_omnibus: latest

platforms:
- name: ubuntu-12.04
  driver:
    name: ec2
    image_id: ami-60a10117
    flavor_id: t2.micro
    security_group_ids: SOME_SG_ID
    vpc_mode: true
    vpc: SOME_VPC_ID
    subnet_id: SOME_SUBNET_ID
    username: ubuntu
    ssh_key: <%= ENV['EC2_SSH_KEY_PATH'] %>

@fnichol : Must admit it is making it quite difficult that the documentation on the configuration at this point in time is not mentioning at all some of the options cited here, including for instance vpc_mode and vpc. And this issue is dated 10 months+ now.

This, IMHO, actually is a more widespread problem with Chef related tools and work (for instance chef-boneyard/chef-provisioning-aws#58 or this comment on a Chef Provisioning issue chef-boneyard/chef-provisioning/issues/186). I have too often found it difficult to find reliable, just reasonably up-to-date information to help me out working not only on new stuff like Chef Provisioning, but also with Chef and offsprings. Things get mixed up and give different information on docs.chef.io , on github and the other dedicated websites (http://kitchen.ci/ is a good "lets start from nothing" tutorial, but is no reliable and fully informative doc as it feels it is presented as). Sounds like a clearer and stronger policy about doc needs to be put in place there.

Often I find that out-of-date documentation is worse than no documentation at all. And I have been too many times in that situation here.

Don't get me wrong: I love the thing. Hence the extra time I am spending trying to figure out how it works. But how many people out there are being deterred from using Chef because of this? I would bet a fair few. It certainly is a significant break to a widerspread use of the tool, and on my side it makes it much more difficult to sell Chef internally, at my company.

My 2 p.

@Jimflip
Copy link

Jimflip commented Jan 12, 2015

I completely agree with you @esciara it really is all a mess, which is a shame.

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

No branches or pull requests

4 participants