Giter Site home page Giter Site logo

knife-google's Introduction

knife-google

Gem Version Build status

Umbrella Project: Knife

Project State: Active

Issues Response Time Maximum: 14 days

Pull Request Response Time Maximum: 14 days

Overview

This is the official Chef Knife plugin for Google Compute Engine. This plugin gives knife the ability to create, bootstrap, and manage Google Compute Engine (GCE) instances.

Compatibility

This plugin has been tested with Chef 17 and uses the Google API Ruby Client.

Getting Started

Install the gem

Install the gem with:

gem install knife-google

If you're using Bundler, simply add it to your Gemfile:

gem "knife-google", "~> 2.0"

... and then run bundle install.

Create a Google Cloud Platform project

Before getting started with this plugin, you must first create a Google Cloud Platform (GCP) "project" and add the Google Compute Engine service to your project. While GCP has many other services, such as App Engine and Cloud Storage, this plugin only provides an integration with Google Compute Engine (GCE).

Authentication and Authorization

The underlying API this plugin uses relies on the Google Auth Library to handle authentication to the Google Cloud API. The auth library expects that there is a JSON credentials file located at:

~/.config/gcloud/application_default_credentials.json

The easiest way to create this is to download and install the Google Cloud SDK and run the gcloud auth login command which will create the credentials file for you.

Update: gcloud auth login no longer writes application default credentials. Please run gcloud auth application-default login for appropriate application credentials file.

If you already have a file you'd like to use that is in a different location, set the GOOGLE_APPLICATION_CREDENTIALS environment variable with the full path to that file.

Configuration

All knife-google commands require a project name, and most commands require zone name to be supplied. You can supply these on the command line:

knife google server list --gce-project my-test-project --gce-zone us-east1-b

... or you can set them in your knife.rb file:

knife[:gce_project] = 'my-test-project'
knife[:gce_zone]    = 'us-east1-b'

SSH Keys

In order to Linux bootstrap nodes, you will first need to ensure your SSH keys are set up correctly. Ensure your SSH public key is properly entered into your project's Metadata tab in the GCP Console. GCE will add your key to the appropriate user's ~/.ssh/authorized_keys file when Chef first connects to perform the bootstrap process.

  • If you don't have one, create a key using ssh-keygen
  • Log in to the GCP console, select your project, go to Compute Engine, and go to the Metadata tab.
  • Select the "SSH Keys" tab.
  • Add a new item, and paste in your public key.
    • Note: to change the username automatically detected for the key, prefix your key with the username you plan to use as the --ssh-user when creating a server. For example, if you plan to connect as "chefuser", your key should look like: chefuser:ssh-rsa AAAAB3N...
  • Click "Save".

You can find more information on configuring SSH keys in the Google Compute Engine documentation.

Usage

To see all knife-google commands, run: knife google

All commands have additional help output. Simply append --help to any command. For example, to see additional help and flags available for the knife google disk create command, run: knife google disk create --help

knife google disk create DISKNAME

Create a disk in GCE.

Parameters

  • DISKNAME: required. The name of the disk to create.
  • gce-disk-size: optional. The size of the disk, in GB, to create. Valid options are between 10 and 10,000. The default is 10.
  • gce-disk-type: optional. The type of GCE disk to create, such as pd-ssd. Default is pd-standard.
  • gce-disk-source: optional. Image to use when creating a disk. By default, the disk will be created blank.

Example

knife google disk create my-test-disk --gce-disk-type pd-ssd --gce-disk-size 50

knife google disk delete DISKNAME [DISKNAME]

Deletes one or more disks from GCE.

Parameters

  • DISKNAME: required. The name of the disk to delete. You can specify more than one disk to delete at a time.

Example

knife google disk delete my-test-disk1 my-test-disk2

knife google disk list

List all disks in the currently-configured GCE project and zone.

Parameters

None.

knife google project quotas

Display all project resources and quotas for the currently-configured project, such as the number of snapshots allowed and currently consumed.

Parameters

None.

knife google region list

Display all regions available to the currently-configured project, what each region's status is, and what zones exist in each region.

Regions are collections of zones. For additional information on regions, please refer to the GCE documentation.

Parameters

None.

knife google region quotas

Display all resources and quotas for all regions in the currently-configured project, such as how many instances are allowed and currently configured in a given region.

Parameters

None.

knife google server create INSTANCE_NAME

Create a GCE server instance and bootstrap it with Chef. You must supply an instance name, a machine type, and an image to use.

For a Linux instance, Chef will connect to the instance over SSH based on the --ssh-user parameter. This user must have SSH keys configured properly in the project's metadata. See the SSH Keys section for more information.

Parameters

  • INSTANCE_NAME: required. The name to use when creating the instance.
  • --gce-machine-type: required. The machine type to use when creating the server, such as n1-standard-2 or n1-highcpu-2-d.
  • --gce-network: The name of the network to which your instance will be attached. Defaults to "default".
  • --gce-subnet: The name of the subnet to which your instance will be attached. Only applies to custom networks.
  • --gce-image: required. The name of the disk image to use when creating the server. knife-google will search your current project for this disk image. If the image cannot be found but looks like a common public image, the public image project will be searched as well. Additionally, this parameter supports the same image aliases that gcloud compute instances create supports. See the output of gcloud compute instances create --help for a full list of aliases.
    • Example: if you supply a gce-image of centos-7-v20160219, knife-google will first look for an image with that name in your currently-configured project. If it cannot be found, it will look in the centos-cloud project.
    • This behavior can be overridden with the --gce-image-project parameter.
  • --gce-image-project: optional. The name of the GCP project that contains the image specified with the --gce-image flag. If this is specified, knife-google will not search any known public projects for your image.
  • --gce-boot-disk-name: The name to use when creating the instance's boot disk. Defaults to the instance name.
  • --gce-boot-disk-size: The size of the boot disk to create, in GB. Defaults to 10.
  • --[no-]gce-boot-disk-ssd: If true, the boot disk will be created as a pd-ssd disk type. By default, this is false, and the boot disk will be created as a pd-standard disk type.
  • --[no-]gce-boot-disk-autodelete: If true, the boot disk will be automatically deleted whenever the instance is deleted. Defaults to true.
  • --additional_disks: A comma-separated list of disk names to attach to the instance when creating it. The disks must already exist.
  • --[no-]gce-auto-server-restart: If true, the instance will be automatically restarted if it was terminated for non-user-initiated actions, such as host maintenance. Defaults to true.
  • --[no-]gce-auto-server-migrate: If true, the instance will be automatically migrated to another host if maintenance would require the instance to be terminated. Defaults to true.
  • --[no-]gce-can-ip-forward: If true, the instance will be allowed to perform network forwarding. Defaults to false.
  • --gce-tags: A comma-separated list of tag values to add to the instance.
  • --gce-metadata: A comma-separated list of key=value pairs to be added to the instance metadata. Example: --gce-metadata mykey=myvalue,yourkey=yourvalue
  • --gce-service-account-scopes: A comma-separated list of account scopes for this instance. View a list of scoped by running gcloud compute instances create --help and searching for the documentation for the --scopes parameter. You must supply the full URI (i.e. "https://www.googleapis.com/auth/devstorage.full_control"), the final part of the URI (i.e. "devstorage.full_control"), or the gcloud alias name (i.e. "storage-rw"). See the output of gcloud compute instances create --help for a full list of scopes.
  • --gce-service-account-name: the service account name to use when adding service account scopes. This usually looks like an email address and can be created in the Permissions tab of the Google Cloud Console. Defaults to "default"
  • --gce-use-private-ip: If true, Chef will attempt to bootstrap the device using the private IP rather than the public IP. Defaulst to false.
  • --gce-public-ip: The type of public IP to associate with this instance. If "ephemeral", an ephemeral IP will be assigned. If "none", no public IP will be assigned. If a specific IP address is provided, knife-google will attempt to attach that specific IP address to the instance. Default is "ephemeral".
  • --gce-email: required when creating and bootstrapping Microsoft Windows instances. The email address of the currently-logged-in Google Cloud user. This is required when resetting the Windows instance's password.

Additionally, all the normal knife bootstrap flags are supported. See the output of knife bootstrap --help and knife google server create --help for additional information.

Example

knife google server create test-instance-1 --gce-image centos-7-v20160219 --gce-machine-type n1-standard-2 --gce-public-ip ephemeral --ssh-user myuser --identity-file /Users/myuser/.ssh/google_compute_engine

knife google server delete INSTANCE_NAME [INSTANCE_NAME]

Deletes one or more GCE server instance. Additionally, if requested, the client and node object for the given instance will be deleted off of the Chef Server as well.

The boot disk will be deleted as well unless --no-gce-boot-disk-autodelete was specified during the server creation.

Parameters

  • INSTANCE_NAME: required. The name of the GCE instance to delete. You may provide more than one instance to delete.
  • --purge: optional. If provided, the instances' client and node objects will be deleted off the Chef Server. Default is NOT to delete the objects.

Example

knife google server delete my-instance-1 my-instance-2 --purge

knife google server list

Display the instances in the currently-configured project and zone, their statuses, machine types, IP addresses, and network.

This command will display all instances in the project/zone, even if they weren't created with knife-google.

Parameters

None.

knife google server show INSTANCE_NAME

Display information about a single GCE instance, including its status, machine type, IP addresses, and network. Only one server may be displayed at a time.

Parameters

  • INSTANCE_NAME: required. The name of the instance to show.

knife google zone list

List all available zones in the currently-configured project and what each zone's status is. A zone is an isolated location within a region that is independent of other zones in the same region. For additional information on zones, please refer to the GCE documentation.

Parameters

None.

Bootstrapping Windows Nodes

WinRM is used by Chef to bootstrap Windows nodes. The default settings of the GCE Windows images and GCP projects are not conducive to successful bootstrapping. Therefore, you will likely need to make some changes to your project settings and create your own image based on your company's policies. Some settings you will likely have to change include:

  • inbound firewall rule in the GCP console to allow inbound WinRM (such as port 5985/tcp)
  • inbound firewall rule in Windows Firewall to allow the inbound WinRM connections
  • enable the appropriate WinRM transports

Development Documentation

All documentation is written using YARD. You can generate a by running:

yard

Contributing

For information on contributing to this project please see our Contributing Documentation

License & Copyright

Version 3.0.0 of knife-google was rewritten by Chef Partner Engineering but is largely inspired by initial versions of knife-google, thanks to the work of the great folks at Google.

  • Copyright:: Chef Software, Inc.
  • License:: Apache License, Version 2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

knife-google's People

Contributors

abhishekkr avatar acsrujan avatar adamleff avatar brentchapman avatar btm avatar cblecker avatar chef-ci avatar dependabot-preview[bot] avatar dheerajd-msys avatar erjohnso avatar josephrdsmith avatar juliandunn avatar l337ch avatar lamont-granquist avatar luisbosque avatar mbrukman avatar mohitsethi avatar nashwini avatar nelsonjr avatar nikhil2611 avatar paulrossman avatar prabhu-das avatar siddheshwar-more avatar sinisterlight avatar skeshari12 avatar snapsam avatar srleo avatar tas50 avatar tduffield avatar vkarve-chef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

knife-google's Issues

knife google command not working

I'm using windows and I'm receiving following error on running any command of knife google

ERROR: knife encountered an unexpected error
This may be a bug in the 'google server create' knife command or plugin
Please collect the output of this command with the -VV option before filing a bug report.
Exception: NoMethodError: undefined method `snake_case' for "Zone":String

Also when I try to check all commands of knife google it gives me following error

FATAL: Cannot find subcommand for: 'google'
Available google subcommands: (for details, knife SUB-COMMAND --help)

No support for GCE image family

When provisioning a new server, you have to specify the full image name, rather than specifying the image family and letting GCE select the most up to date image from that family.

knife google server create is having an error boostraping

This is with the knife-google gem built from master. The user has the ability to ssh but bootstrap is failing. Am I missing something?

ubuntu@chef:~$ knife google server create tester003-qa -m f1-micro -I ubuntu-base-image -Z us-central1-a -r 'role[_default]' -n porch --gce-public-ip NONE --gce-tags mgmt                                   
Looking for Image 'ubuntu-base-image' in Project 'astute-yolo-90017'
Found Image 'ubuntu-base-image' in Project 'astute-yolo-90017'
Waiting for the boot disk insert operation to complete
Name: tester003-qa
Zone: us-central1-a
Type: pd-standard
Size: 10 gb
Image: ubuntu-base-image
.
.
Waiting for the create server operation to complete
.
.
Waiting for the servers to be in running state
Instance Name: tester003-qa
Machine Type: f1-micro
Image: ubuntu-base-image
Zone: us-central1-a
Tags: mgmt
Private IP Address: ["10.253.208.210"]

Waiting for server

Waiting for sshd
done
ERROR: Must pass an FQDN or ip to bootstrap

but

ubuntu@chef:~$ ssh 10.253.208.210
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.16.0-31-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Fri Apr  3 17:47:58 UTC 2015

  System load:  0.45              Processes:           78
  Usage of /:   13.0% of 9.81GB   Users logged in:     0
  Memory usage: 16%               IP address for eth0: 10.253.208.210
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

6 packages can be updated.
6 updates are security updates.


Last login: Fri Apr  3 17:48:04 2015 from 10.254.157.90
ubuntu@tester003-qa:~$ 

Custom Metadata

According to the help for the create server actions, we can add custom metadata to the servers.

I've tried this options:

``--gce-metadata startup-script-url=http://storage.googleapis.com/ps_startup_scripts/startup.sh
`

Which looks ok, but nothing's added to the VM. The tests actually look like this should be just 'metadata'.

Maybe I'm wrong, could someone suggest the correct syntax for this.

GCP Service Accounts

Is there any plan to allow service account authentication for knife-google? The current implementation of using OAuth 2.0 Client ID's doesn't work for us because on a shared server, it would require knife-google to be authenticated using someone's @google.com email address. Service accounts are designed specifically to be used by servers and not require personal @google.com access.

If no one is working on this, I can try to take a look in the code to see how easy or difficult this would be to implement.

support multiple --local-ssd interfaces

Such as

gcloud compute instances create $MACHINE \
    --machine-type n1-highmem-32 \
    --local-ssd interface=nvme \
    --local-ssd interface=nvme \
    --local-ssd interface=nvme \
    --local-ssd interface=nvme \
    ...

knife google server create fails while bootstrap to centos node

Version:

knife-google v3.3.7 and chef v15.0.238 on workstation

Environment:

centos-7

Scenario:

knife google server create ash-instance-3 --gce-image centos-7-v20160219 --gce-machine-type n1-standard-1 --gce-public-ip ephemeral --ssh-user msys --identity-file C:\Users\msys\.ssh\id_rsa --gce_project "ash-account-project" --gce_zone "us-east1-c" -c "D:\chef-repo\.chef\knife.rb" --image-os-type linux --bootstrap-protocol ssh -VV

Steps to Reproduce:

Please run above command to create the node from workstation.

Expected Result:

It should create the instance in google account and bootstrap the node.

Actual Result:

It create the instance in google account but fails to bootstrap the node by below error:
FATAL: Check if --bootstrap-protocol and --image-os-type is correct. uninitialized constant Chef::Knife::Bootstrap::ClientBuilder Did you mean? Chef::Knife::ClientBulkDelete

Stacktrace

Traceback (most recent call last):
        16: from C:/opscode/chef/embedded/bin/knife:23:in `<main>'
        15: from C:/opscode/chef/embedded/bin/knife:23:in `load'
        14: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.238-universal-mingw32/bin/knife:24:in `<top (required)>'
        13: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.238-universal-mingw32/lib/chef/application/knife.rb:162:in `run'
        12: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.238-universal-mingw32/lib/chef/knife.rb:221:in `run'
        11: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.238-universal-mingw32/lib/chef/knife.rb:459:in `run_with_pretty_exceptions'
        10: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.238-universal-mingw32/lib/chef/local_mode.rb:41:in `with_server_connectivity'
         9: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.238-universal-mingw32/lib/chef/knife.rb:460:in `block in run_with_pretty_exceptions'
         8: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/command.rb:53:in `run'
         7: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/server/create_command.rb:79:in `after_exec_command'
         6: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/server/create_command.rb:104:in `bootstrap'
         5: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/chefbootstrap/bootstrapper.rb:39:in `bootstrap'
         4: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/chefbootstrap/bootstrapper.rb:51:in `create_bootstrap_protocol'
         3: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/chefbootstrap/bootstrapper.rb:51:in `new'
         2: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/chefbootstrap/ssh_bootstrap_protocol.rb:30:in `initialize'
         1: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/chefbootstrap/ssh_bootstrap_protocol.rb:30:in `new'
C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.238-universal-mingw32/lib/chef/knife/bootstrap.rb:401:in `initialize': uninitialized constant Chef::Knife::Bootstrap::ClientBuilder (NameError)
Did you mean?  Chef::Knife::ClientBulkDelete
        10: from C:/opscode/chef/embedded/bin/knife:23:in `<main>'
         9: from C:/opscode/chef/embedded/bin/knife:23:in `load'
         8: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.238-universal-mingw32/bin/knife:24:in `<top (required)>'
         7: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.238-universal-mingw32/lib/chef/application/knife.rb:162:in `run'
         6: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.238-universal-mingw32/lib/chef/knife.rb:221:in `run'
         5: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.238-universal-mingw32/lib/chef/knife.rb:459:in `run_with_pretty_exceptions'
         4: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.238-universal-mingw32/lib/chef/local_mode.rb:41:in `with_server_connectivity'
         3: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.238-universal-mingw32/lib/chef/knife.rb:460:in `block in run_with_pretty_exceptions'
         2: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/command.rb:53:in `run'
         1: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/server/create_command.rb:77:in `after_exec_command'
C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/server/create_command.rb:88:in `rescue in after_exec_command': Check if --bootstrap-protocol and --image-os-type is correct. uninitialized constant Chef::Knife::Bootstrap::ClientBuilder (NameError)
Did you mean?  Chef::Knife::ClientBulkDelete 

Spinning up a GCP instance from an EC2 instance results in an error

Whenever I issue the following command to try and create a GCP instance

knife google server create test-01-production-chs -m n1-standard-2 -I ubuntu-1404-trusty-v20150909a --gce-image-project-id ubuntu-os-cloud -n um-subnet-chs-1b-public-admin -N 01.test.production.chs -E production -Z us-east1-b --gce-boot-disk-size 40G -i ec2_keys/um_vn_key_chs.pem -x ubuntu --gce-server-connect-ip PUBLIC -VV

I get the following output

Instance Name: test-01-production-chs
Machine Type: n1-standard-2
Image: ubuntu-1404-trusty-v20150909a
Zone: us-east1-b
Tags: None
Public IP Address: ["104.196.13.69"]
Private IP Address: ["10.4.0.3"]

Waiting for server

Waiting for sshd
DEBUG: sshd accepting connections on 104.196.13.69, banner is SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3

done
ERROR: knife encountered an unexpected error
This may be a bug in the 'google server create' knife command or plugin
Please collect the output of this command with the -VV option before filing a bug report.
Exception: NoMethodError: undefined method `empty?' for nil:NilClass

Any insight would be very helpful.

no implicit conversion of nil into String on knife google server create

I've whacked at this issue for a couple hours now and I can't make sense of it. I'm guessing Google is returning a nil and we're trying to print it.

knife google server create -VV -I centos-6-v20150309 -m f1-micro -Z us-central1-c f7c827-test
INFO: Using configuration from /Users/cscott/knife.rb
Looking for Image 'centos-6-v20150309' in Project 'dulcet-order-87921'
Looking for Image 'centos-6-v20150309' in Project 'centos-cloud'
Found Image 'centos-6-v20150309' in Project 'centos-cloud'
Waiting for the disk insert operation to complete
/opt/chefdk/embedded/lib/ruby/2.1.0/time.rb:325:in `_parse': no implicit conversion of nil into String (TypeError)
    from /opt/chefdk/embedded/lib/ruby/2.1.0/time.rb:325:in `parse'
    from /Users/cscott/.chefdk/gem/ruby/2.1.0/gems/knife-google-1.3.1/lib/google/compute/zone_operation.rb:42:in `from_hash'
    from /Users/cscott/.chefdk/gem/ruby/2.1.0/gems/knife-google-1.3.1/lib/google/compute/resource.rb:28:in `initialize'
    from /Users/cscott/.chefdk/gem/ruby/2.1.0/gems/knife-google-1.3.1/lib/google/compute/creatable_resource_collection.rb:35:in `new'
    from /Users/cscott/.chefdk/gem/ruby/2.1.0/gems/knife-google-1.3.1/lib/google/compute/creatable_resource_collection.rb:35:in `create'
    from /Users/cscott/.chefdk/gem/ruby/2.1.0/gems/knife-google-1.3.1/lib/google/compute/creatable_resource_collection.rb:45:in `insert'
    from /Users/cscott/.chefdk/gem/ruby/2.1.0/gems/knife-google-1.3.1/lib/chef/knife/google_server_create.rb:427:in `run'
    from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:417:in `block in run_with_pretty_exceptions'
    from /opt/chefdk/embedded/apps/chef/lib/chef/local_mode.rb:38:in `with_server_connectivity'
    from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:416:in `run_with_pretty_exceptions'
    from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:213:in `run'
    from /opt/chefdk/embedded/apps/chef/lib/chef/application/knife.rb:139:in `run'
    from /opt/chefdk/embedded/apps/chef/bin/knife:25:in `<top (required)>'
    from /usr/bin/knife:40:in `load'
    from /usr/bin/knife:40:in `<main>'

Need to Enter Zone to View Zones

Version:

knife-google (3.2.0)

Environment:

Chef Development Kit Version: 2.5.3
Ubuntu 16.04

Scenario:

In order to view zones, you must enter your zone. That sort of defeats the purpose of viewing all zones.

Steps to Reproduce:

  1. knife google zone list --gce-project ${GCP_PROJECT}

Expected Result:

List of Zones.

Zone                       Status
asia-east1-a               up    
asia-east1-b               up    
asia-east1-c               up    
asia-northeast1-a          up    
asia-northeast1-b          up    
asia-northeast1-c          up    
asia-south1-a              up    
asia-south1-b              up    
asia-south1-c              up    
asia-southeast1-a          up    
asia-southeast1-b          up    
australia-southeast1-a     up    
australia-southeast1-b     up    
australia-southeast1-c     up    
europe-west1-b             up    
europe-west1-c             up    
europe-west1-d             up    
europe-west2-a             up    
europe-west2-b             up    
europe-west2-c             up    
europe-west3-a             up    
europe-west3-b             up    
europe-west3-c             up    
europe-west4-a             up    
europe-west4-b             up    
europe-west4-c             up    
northamerica-northeast1-a  up    
northamerica-northeast1-b  up    
northamerica-northeast1-c  up    
southamerica-east1-a       up    
southamerica-east1-b       up    
southamerica-east1-c       up    
us-central1-a              up    
us-central1-b              up    
us-central1-c              up    
us-central1-f              up    
us-east1-b                 up    
us-east1-c                 up    
us-east1-d                 up    
us-east4-a                 up    
us-east4-b                 up    
us-east4-c                 up    
us-west1-a                 up    
us-west1-b                 up    
us-west1-c                 up    

Actual Result:

ERROR: The following required parameters are missing: gce_zone
ERROR: RuntimeError: The following required parameters are missing: gce_zone

400 Error from Google During 'knife google setup'

When I run the knife google setup command and proceed with the prompts, I am able to successfully enter and follow the steps until it asks to

"Copy and paste the following url in your brower and allow access. Enter the resulting authorization code below."

At this point, I navigate to the URL, but Google gives me that broken down robot HTTP error page with a 400 status code that reads as follows:

400. That’s an error.

Error: redirect_uri_mismatch

The redirect URI in the request: urn:ietf:wg:oauth:2.0:oob did not match a registered redirect URI.

Here are the detailed prompts (with sensitive information removed redacted by **REDACTED**):

$ knife google setup
Enter Project ID (ex: my-gce-project): **REDACTED**
Enter Client ID (ex: 123abc4.apps.googleusercontent.com): **REDACTED**
Enter Client secret: **REDACTED**
Copy and paste the following url in your brower and allow access. Enter the resulting authorization code below.

https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=**REDACTED**&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/compute%20https://www.googleapis.com/auth/compute.readonly%20https://www.googleapis.com/auth/devstorage.full_control%20https://www.googleapis.com/auth/devstorage.read_only%20https://www.googleapis.com/auth/devstorage.read_write%20https://www.googleapis.com/auth/devstorage.write_only%20https://www.googleapis.com/auth/userinfo.email


Authorization code: 

Since the URL above returns that HTTP 400 redirect_uri_mismatch I cannot get any farther.

New Functionality: knife-google unable to spinup servers in subnets

I'm not sure if everyone is aware or not but google has beta'd the release of subnets in virtual networks. The current version of this gem that I build (2.0.0) doesn't account for spin up in subnets. I'd like to start the development on getting the ability to spinup servers in subnets going. Can anyone help in the process of doing this?

knife-google fails with google-api-client >0.8

knife google zone list -VV
/Users/zenitram/.chefdk/gem/ruby/2.1.0/gems/google-api-client-0.8.2/lib/google/api_client/environment.rb:26: warning: Insecure world writable dir /usr/local in PATH, mode 040777
/Users/zenitram/.chefdk/gem/ruby/2.1.0/gems/knife-google-1.3.1/lib/google/compute/resource_collection.rb:69:in `api_resource': undefined method `snake_case' for "Zone":String (NoMethodError)
    from /Users/zenitram/.chefdk/gem/ruby/2.1.0/gems/knife-google-1.3.1/lib/google/compute/listable_resource_collection.rb:22:in `list'
    from /Users/zenitram/.chefdk/gem/ruby/2.1.0/gems/knife-google-1.3.1/lib/chef/knife/google_zone_list.rb:37:in `run'
    from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:493:in `run_with_pretty_exceptions'
    from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:174:in `run'
    from /opt/chefdk/embedded/apps/chef/lib/chef/application/knife.rb:139:in `run'
    from /opt/chefdk/embedded/apps/chef/bin/knife:25:in `<top (required)>'
    from /usr/bin/knife:33:in `load'
    from /usr/bin/knife:33:in `<main>'

Using chef-dk with latest knife-google gem. Downgrading to google-api-client 0.7.1 made everything work again..

Server create command returns error

I had the exact same issue as described in #84

Took the solution that was provided by developer and applied it to my own fork of this repo. This enabled me to perform other commands which I wasn't able before like listing zones etc.

So I tried to provision an instance, this is command execution and the relevant log part (removed bunch of dots):

knife google server create www1 -m n1-standard-1 -I centos-7-v20150127 -Z us-east1-c
Looking for Image 'centos-7-v20150127' in Project 'xxxxxx-project-114123'
Looking for Image 'centos-7-v20150127' in Project 'centos-cloud'
Found Image 'centos-7-v20150127' in Project 'centos-cloud'
Waiting for the boot disk insert operation to complete
Name: www1
Zone: us-east1-c
Type: pd-standard
Size: 10 gb
Image: centos-7-v20150127
.
Waiting for the create server operation to complete
.
.
.
Waiting for the servers to be in running state
Instance Name: www1
Machine Type: n1-standard-1
Image: centos-7-v20150127
Zone: us-east1-c
Tags: None
Public IP Address: ["104.1xx.xx.xxx"]
Private IP Address: ["10.240.0.8"]

Waiting for server

Waiting for sshd
done
ERROR: knife encountered an unexpected error
This may be a bug in the 'google server create' knife command or plugin
Please collect the output of this command with the `-VV` option before filing a bug report.
Exception: NoMethodError: undefined method `empty?' for nil:NilClass

Despite this error it created an instance for me. But wanting to be useful and this time I re-ran the command to create a different instance only with the -VV flag so I can post more info here, this is the output:

nife google server create -VV www2 -m n1-standard-1 -I centos-7-v20150127 -Z us-east1-c
INFO: Using configuration from /RDX/chef/chef-repo/.chef/knife.rb
Looking for Image 'centos-7-v20150127' in Project 'xxxxxx-project-114123'
Looking for Image 'centos-7-v20150127' in Project 'centos-cloud'
Found Image 'centos-7-v20150127' in Project 'centos-cloud'
Waiting for the boot disk insert operation to complete
Name: www2
Zone: us-east1-c
Type: pd-standard
Size: 10 gb
Image: centos-7-v20150127
.
.
Waiting for the create server operation to complete
.
.
.
.
Waiting for the servers to be in running state
/Library/Ruby/Gems/2.0.0/gems/knife-google-2.0.0/lib/google/compute/client.rb:200:in `dispatch': { (Google::Compute::ResourceNotFound)
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "The resource 'projects/xxxxxx-project-114123/zones/us-east1-c/instances/www2' was not found"
   }
  ],
  "code": 404,
  "message": "The resource 'projects/divine-precinct-114123/zones/us-east1-c/instances/www2' was not found"
 }
}
    from /Library/Ruby/Gems/2.0.0/gems/knife-google-2.0.0/lib/google/compute/resource_collection.rb:47:in `get'
    from /Library/Ruby/Gems/2.0.0/gems/knife-google-2.0.0/lib/chef/knife/google_server_create.rb:616:in `run'
    from /Library/Ruby/Gems/2.0.0/gems/chef-12.5.1/lib/chef/knife.rb:405:in `block in run_with_pretty_exceptions'
    from /Library/Ruby/Gems/2.0.0/gems/chef-12.5.1/lib/chef/local_mode.rb:44:in `with_server_connectivity'
    from /Library/Ruby/Gems/2.0.0/gems/chef-12.5.1/lib/chef/knife.rb:404:in `run_with_pretty_exceptions'
    from /Library/Ruby/Gems/2.0.0/gems/chef-12.5.1/lib/chef/knife.rb:203:in `run'
    from /Library/Ruby/Gems/2.0.0/gems/chef-12.5.1/lib/chef/application/knife.rb:142:in `run'
    from /Library/Ruby/Gems/2.0.0/gems/chef-12.5.1/bin/knife:25:in `<top (required)>'
    from /usr/local/bin/knife:23:in `load'
    from /usr/local/bin/knife:23:in `<main>'

This is completely different error and my instance wasn't created this time.

knife google server create fails for option --bootstrap-protocol and --image-os-type

Version:

knife-google v3.3.7 and chef v15.0.266 on workstation

Environment:

centos-7

Scenario:

knife google server create ash-instance-3 --gce-image centos-7-v20160219 --gce-machine-type n1-standard-1 --gce-public-ip ephemeral --ssh-user msys --identity-file C:\Users\msys\.ssh\id_rsa --gce_project "ash-account-project" --gce_zone "us-east1-c" -c "D:\chef-repo\.chef\knife.rb" --image-os-type linux --bootstrap-protocol ssh -VV

Steps to Reproduce:

Please run above command to create the node from workstation.

Expected Result:

It should create the instance in google account and bootstrap the node.

Actual Result:

It create the instance in google account but fails to bootstrap the node by below error:
FATAL: Check if --bootstrap-protocol and --image-os-type is correct. undefined method `include?' for nil:NilClass

Stacktrace

FATAL: Check if --bootstrap-protocol and --image-os-type is correct. undefined method `include?' for nil:NilClass
Traceback (most recent call last):
        17: from C:/opscode/chef/embedded/bin/knife:23:in `<main>'
        16: from C:/opscode/chef/embedded/bin/knife:23:in `load'
        15: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/bin/knife:24:in `<top (required)>'
        14: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/lib/chef/application/knife.rb:162:in `run'
        13: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/lib/chef/knife.rb:221:in `run'
        12: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/lib/chef/knife.rb:466:in `run_with_pretty_exceptions'
        11: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/lib/chef/local_mode.rb:41:in `with_server_connectivity'
        10: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/lib/chef/knife.rb:467:in `block in run_with_pretty_exceptions'
         9: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/command.rb:53:in `run'
         8: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/server/create_command.rb:81:in `after_exec_command'
         7: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/server/create_command.rb:106:in `bootstrap'
         6: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/chefbootstrap/bootstrapper.rb:42:in `bootstrap'
         5: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb:44:in `send_bootstrap_command'
         4: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/lib/chef/knife/bootstrap.rb:526:in `run'
         3: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/lib/chef/knife/bootstrap.rb:660:in `verify_deprecated_flags!'
         2: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/lib/chef/knife/bootstrap.rb:660:in `each'
         1: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/lib/chef/knife/bootstrap.rb:662:in `block in verify_deprecated_flags!'
C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/lib/chef/knife.rb:378:in `config_source': undefined method `include?' for nil:NilClass (NoMethodError)
        10: from C:/opscode/chef/embedded/bin/knife:23:in `<main>'
         9: from C:/opscode/chef/embedded/bin/knife:23:in `load'
         8: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/bin/knife:24:in `<top (required)>'
         7: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/lib/chef/application/knife.rb:162:in `run'
         6: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/lib/chef/knife.rb:221:in `run'
         5: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/lib/chef/knife.rb:466:in `run_with_pretty_exceptions'
         4: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/lib/chef/local_mode.rb:41:in `with_server_connectivity'
         3: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.266-universal-mingw32/lib/chef/knife.rb:467:in `block in run_with_pretty_exceptions'
         2: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/command.rb:53:in `run'
         1: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/server/create_command.rb:79:in `after_exec_command'
C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/server/create_command.rb:90:in `rescue in after_exec_command': Check if --bootstrap-protocol and --image-os-type is correct. undefined method `include?' for nil:NilClass (NoMethodError)

Dependency conflict building from master

Fresh install of chefdk on ubuntu 14.04 gives me this error:

chef@chef00-mgmt:~/knife-google⟫ /opt/chefdk/embedded/bin/gem install knife-google-1.4.3.gem
WARNING:  You don't have /home/chef/.chefdk/gem/ruby/2.1.0/bin in your PATH,
          gem executables will not run.
Successfully installed knife-google-1.4.3
1 gem installed
chef@chef00-mgmt:~/knife-google⟫ knife google
/opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:2104:in `raise_if_conflicts': Unable to activate googleauth-0.4.1, because logging-1.8.2 conflicts with logging (~> 2.0) (Gem::ConflictError)
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1282:in `activate'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1316:in `block in activate_dependencies'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1302:in `each'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1302:in `activate_dependencies'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1284:in `activate'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1316:in `block in activate_dependencies'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1302:in `each'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1302:in `activate_dependencies'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1284:in `activate'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems.rb:198:in `rescue in try_activate'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems.rb:195:in `try_activate'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:126:in `rescue in require'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:39:in `require'
        from /home/chef/.chefdk/gem/ruby/2.1.0/gems/knife-google-1.4.3/lib/chef/knife/google_base.rb:16:in `<top (required)>'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife/core/subcommand_loader.rb:44:in `load'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife/core/subcommand_loader.rb:44:in `block in load_commands'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife/core/subcommand_loader.rb:44:in `each'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife/core/subcommand_loader.rb:44:in `load_commands'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:127:in `load_commands'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:208:in `run'
        from /opt/chefdk/embedded/apps/chef/lib/chef/application/knife.rb:142:in `run'
        from /opt/chefdk/embedded/apps/chef/bin/knife:25:in `<top (required)>'
        from /usr/bin/knife:51:in `load'
        from /usr/bin/knife:51:in `<main>'

Thanks for any help you can provide!

Knife google failing to setup

Hi,

I've tried to install knife-google a few times and keep failing at the first hurdle.

Is there anything obvious here? I think this ties into the beta version of retriable.

My system is Darwin LONM1KWDKQ4L.local 12.5.0 Darwin Kernel Version 12.5.0: Sun Sep 29 13:33:47 PDT 2013; root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64

Ruby is ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.5.0]

knife google setup -VV
/Users/daniel.mitchell/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:73:in require': /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/retriable-2.0.0.beta2/lib/retriable.rb:16: syntax error, unexpected tLABEL, expecting ')' (SyntaxError) max_tries: config.max_tries, ^ /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/retriable-2.0.0.beta2/lib/retriable.rb:17: syntax error, unexpected tLABEL, expecting '=' base_interval: config.base_interval, ^ /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/retriable-2.0.0.beta2/lib/retriable.rb:18: syntax error, unexpected tLABEL, expecting '=' max_interval: config.max_interval, ^ /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/retriable-2.0.0.beta2/lib/retriable.rb:19: syntax error, unexpected tLABEL, expecting '=' rand_factor: config.rand_factor, ^ /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/retriable-2.0.0.beta2/lib/retriable.rb:20: syntax error, unexpected tLABEL, expecting '=' multiplier: config.multiplier, ^ /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/retriable-2.0.0.beta2/lib/retriable.rb:21: syntax error, unexpected tLABEL, expecting '=' max_elapsed_time: config.max_elapsed_time, ^ /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/retriable-2.0.0.beta2/lib/retriable.rb:22: syntax error, unexpected tLABEL, expecting '=' timeout: config.timeout, ^ /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/retriable-2.0.0.beta2/lib/retriable.rb:23: syntax error, unexpected tLABEL, expecting '=' on: config.on, ^ /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/retriable-2.0.0.beta2/lib/retriable.rb:24: syntax error, unexpected tLABEL, expecting '=' on_retry: config.on_retry, ^ /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/retriable-2.0.0.beta2/lib/retriable.rb:25: syntax error, unexpected tAMPER, expecting '=' &block) ^ /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/retriable-2.0.0.beta2/lib/retriable.rb:70: syntax error, unexpected keyword_end, expecting $end from /Users/daniel.mitchell/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:73:inrequire'
from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/google-api-client-0.7.1/lib/google/api_client.rb:20:in <top (required)>' from /Users/daniel.mitchell/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:73:inrequire'
from /Users/daniel.mitchell/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:73:in require' from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/knife-google-1.3.1/lib/google/compute/client.rb:17:in<top (required)>'
from /Users/daniel.mitchell/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:73:in require' from /Users/daniel.mitchell/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:73:inrequire'
from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/knife-google-1.3.1/lib/google/compute.rb:29:in <top (required)>' from /Users/daniel.mitchell/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:135:inrequire'
from /Users/daniel.mitchell/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:135:in rescue in require' from /Users/daniel.mitchell/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:144:inrequire'
from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/knife-google-1.3.1/lib/chef/knife/google_base.rb:16:in <top (required)>' from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/chef-11.16.4/lib/chef/knife/core/subcommand_loader.rb:34:inload'
from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/chef-11.16.4/lib/chef/knife/core/subcommand_loader.rb:34:in block in load_commands' from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/chef-11.16.4/lib/chef/knife/core/subcommand_loader.rb:34:ineach'
from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/chef-11.16.4/lib/chef/knife/core/subcommand_loader.rb:34:in load_commands' from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/chef-11.16.4/lib/chef/knife.rb:120:inload_commands'
from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/chef-11.16.4/lib/chef/knife.rb:168:in run' from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/chef-11.16.4/lib/chef/application/knife.rb:139:inrun'
from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/gems/chef-11.16.4/bin/knife:25:in <top (required)>' from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/bin/knife:23:inload'
from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/bin/knife:23:in <main>' from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/bin/ruby_executable_hooks:15:ineval'
from /Users/daniel.mitchell/.rvm/gems/ruby-1.9.3-p448/bin/ruby_executable_hooks:15:in `

'

server create bug

Version:

knife-google (3.2.0)

Environment:

Centos-7

Scenario:

Create multiple servers and bootstrap it using knife-google.

$ knife google server create node-1 --gce-image centos-7 --gce-machine-type f1-micro \
--gce-public-ip ephemeral --ssh-user chef-server --identity-file ~/.ssh/google-chef

Steps to Reproduce:

Create a workstation within google cloud.
Configure according to knife-google documentation
Run:

$ knife google server create node-1 --gce-image centos-7 --gce-machine-type f1-micro \
--gce-public-ip ephemeral --ssh-user chef-server --identity-file ~/.ssh/google

Then Repeat for another server:

$ knife google server create node-2 --gce-image centos-7 --gce-machine-type f1-micro \
--gce-public-ip ephemeral --ssh-user chef-server --identity-file ~/.ssh/google

Expected Result:

Two servers are created and bootstrapped.

Actual Result:

[matthew@google-workstation cloud-chef]$ knife google server create node-2 --gce-image centos-7 --gce-machine-type f1-micro --gce-public-ip ephemeral --ssh-user chef-server --identity-file ~/.ssh/google-chef
image centos-7 is a known alias - using image URL: https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-7-v20180227
Creating instance...

Current status: PENDING.
Current status: RUNNING..

Instance created!
Instance Name: node-2
Status: RUNNING
Machine Type: f1-micro
Project: signia-cloud-project
Zone: us-east1-b
Network: default
Private IP: 10.142.0.6
Public IP: 35.196.224.250
Bootstrapping the server by using bootstrap_protocol: ssh and image_os_type: linux

Waiting for sshd to host (35.196.224.250).done
Creating new client for node-2
Creating new node for node-2
Connecting to 35.196.224.250
35.196.224.250 -----> Installing Chef Omnibus (-v 13)
35.196.224.250 downloading https://omnitruck-direct.chef.io/chef/install.sh
35.196.224.250   to file /tmp/install.sh.1249/install.sh
35.196.224.250 trying curl...
35.196.224.250 el 7 x86_64
35.196.224.250 Getting information for chef stable 13 for el...
35.196.224.250 downloading https://omnitruck-direct.chef.io/stable/chef/metadata?v=13&p=el&pv=7&m=x86_64
35.196.224.250   to file /tmp/install.sh.1255/metadata.txt
35.196.224.250 trying curl...
35.196.224.250 sha1     f69e475eb3bcdeefe761462f05cbf7c7281270ae
35.196.224.250 sha256   39227d13e5ca2ae023627ad63c56a073b7fecf1a68030915b11ce55e9692c214
35.196.224.250 url      https://packages.chef.io/files/stable/chef/13.8.5/el/7/chef-13.8.5-1.el7.x86_64.rpm
35.196.224.250 version  13.8.5
35.196.224.250 downloaded metadata file looks valid...
35.196.224.250 downloading https://packages.chef.io/files/stable/chef/13.8.5/el/7/chef-13.8.5-1.el7.x86_64.rpm
35.196.224.250   to file /tmp/install.sh.1255/chef-13.8.5-1.el7.x86_64.rpm
35.196.224.250 trying curl...
35.196.224.250 Comparing checksum with sha256sum...
35.196.224.250 Installing chef 13
35.196.224.250 installing with rpm...
35.196.224.250 warning: /tmp/install.sh.1255/chef-13.8.5-1.el7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY
35.196.224.250 Preparing...                          ################################# [100%]
35.196.224.250 Updating / installing...
35.196.224.250    1:chef-13.8.5-1.el7                ################################# [100%]
35.196.224.250 Thank you for installing Chef!
35.196.224.250 Starting the first Chef Client run...
35.196.224.250 Starting Chef Client, version 13.8.5
35.196.224.250 resolving cookbooks for run list: []
35.196.224.250 Synchronizing Cookbooks:
35.196.224.250 Installing Cookbook Gems:
35.196.224.250 Compiling Cookbooks...
35.196.224.250 [2018-03-13T14:09:24+00:00] WARN: Node node-2 has an empty run list.
35.196.224.250 Converging 0 resources
35.196.224.250 
35.196.224.250 Running handlers:
35.196.224.250 Running handlers complete
35.196.224.250 Chef Client finished, 0/0 resources updated in 05 seconds
Instance Name: node-2
Status: RUNNING
Machine Type: f1-micro
Project: signia-cloud-project
Zone: us-east1-b
Network: default
Private IP: 10.142.0.6
Public IP: 35.196.224.250

Now for the exact same command:
[matthew@google-workstation cloud-chef]$ knife google server create node-2 --gce-image centos-7 --gce-machine-type f1-micro --gce-public-ip ephemeral --ssh-user chef-server --identity-file ~/.ssh/google-chef

image centos-7 is a known alias - using image URL: https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-7-v20180227
Creating instance...

Current status: PENDING.
Current status: RUNNING..

Instance created!
Instance Name: node-2
Status: RUNNING
Machine Type: f1-micro
Project: signia-cloud-project
Zone: us-east1-b
Network: default
Private IP: 10.142.0.7
Public IP: 35.185.44.210
Bootstrapping the server by using bootstrap_protocol: ssh and image_os_type: linux

Waiting for sshd to host (35.185.44.210).done
Creating new client for node-2
Creating new node for node-2
Connecting to 35.185.44.210
FATAL: Check if --bootstrap-protocol and --image-os-type is correct. fingerprint 16:11:c9:06:48:c7:97:ae:db:e8:b4:2a:83:3a:6e:2a does not match for "35.185.44.210"
ERROR: Net::SSH::HostKeyMismatch: Check if --bootstrap-protocol and --image-os-type is correct. fingerprint 16:11:c9:06:48:c7:97:ae:db:e8:b4:2a:83:3a:6e:2a does not match for "35.185.44.210"

How to fix bug

  1. where ssh keys are stored delete known_hosts
$ rm ~/.ssh/known_hosts
  1. Create a config file (~/.ssh/config)
StrictHostKeyChecking no

Warnings: This will loose ssh configurations for applications like git and will have to be reset.

Please see: https://issuetracker.google.com/issues/74588064

Doesn't Detect Default Project

Version:

  • knife-google (3.2.0)
  • chefdk 2.5.3

Scenario:

Utilize knife-google with my default configured project.

Steps to Reproduce:

  1. sudo dpkg -i ${HOME}/Downloads/chefdk_2.5.3-1_amd64.deb
  2. chef exec gem install knife-google
  3. knife google server list --gce-zone us-east1-c

Expected Result:

Get list of systems in default project. Expected that tooling could read local configuration environment.

Actual Result:

$ knife google server list --gce-zone us-east1-c
ERROR: The following required parameters are missing: gce_project
ERROR: RuntimeError: The following required parameters are missing: gce_project

Workaround

knife google server list \
  --gce-zone us-east1-c \
  --gce-project "$(gcloud config list --format 'value(core.project)' 2>/dev/null)"

knife google server create fails while bootstrap to windows node

Version:

knife-google v3.3.7 and chef v15.0.238 on workstation

Environment:

Windows-2012-r2

Scenario:

knife google server create kpl-w-9 --gce_project "kapil-project" --gce_zone "us-east1-b" --connection-user kapil_chouhan -P "abc123456" --gce-image kpl-w-image --image-os-type windows --gce-machine-type n1-standard-2 --gce-boot-disk-size 60 --bootstrap_protocol winrm --gce-email [email protected] --gce-public-ip ephemeral -c /.chef/knife.rb -VV

Steps to Reproduce:

Please run above command to create the node from the workstation.

Expected Result:

It should create the instance in google account and bootstrap the node.

Actual Result:

FATAL: Check if --bootstrap-protocol and --image-os-type is correct. Timeout while waiting for password agent to perform password reset

For any command "ERROR: ArgumentError: unknown keyword: interval"

$ knife google -VV server list -Z europe-west1-b
/usr/local/rvm/gems/ruby-2.1.2/gems/google-api-client-0.7.1/lib/google/api_client.rb:595:in execute!': unknown keyword: interval (ArgumentError) from /usr/local/rvm/gems/ruby-2.1.2/gems/google-api-client-0.7.1/lib/google/api_client.rb:330:indiscovery_document'
from /usr/local/rvm/gems/ruby-2.1.2/gems/google-api-client-0.7.1/lib/google/api_client.rb:375:in discovered_api' from /usr/local/rvm/gems/ruby-2.1.2/gems/knife-google-1.3.1/lib/google/compute/client.rb:179:incompute'
from /usr/local/rvm/gems/ruby-2.1.2/gems/knife-google-1.3.1/lib/google/compute/resource_collection.rb:73:in api_resource' from /usr/local/rvm/gems/ruby-2.1.2/gems/knife-google-1.3.1/lib/google/compute/resource_collection.rb:47:inget'
from /usr/local/rvm/gems/ruby-2.1.2/gems/knife-google-1.3.1/lib/chef/knife/google_server_list.rb:34:in run' from /usr/local/rvm/gems/ruby-2.1.2/gems/chef-11.12.8/lib/chef/knife.rb:492:inrun_with_pretty_exceptions'
from /usr/local/rvm/gems/ruby-2.1.2/gems/chef-11.12.8/lib/chef/knife.rb:174:in run' from /usr/local/rvm/gems/ruby-2.1.2/gems/chef-11.12.8/lib/chef/application/knife.rb:135:inrun'
from /usr/local/rvm/gems/ruby-2.1.2/gems/chef-11.12.8/bin/knife:25:in <top (required)>' from /usr/local/rvm/gems/ruby-2.1.2/bin/knife:23:inload'
from /usr/local/rvm/gems/ruby-2.1.2/bin/knife:23:in <main>' from /usr/local/rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:ineval'
from /usr/local/rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `

'

Support an alias for latest public image

It would be super-handy if a user could specify "centos" and automatically get the latest CentOS image from the centos-cloud project. Supporting the known public image projects in this manner would make for a better user experience.

knife server create fails if no --gce-public-ip option is supplied

⚡ ~$ which knife
/Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/bin/knife
⚡ ~$ ruby --version
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
⚡ ~$ knife --version
Chef: 12.16.42

⚡ ~$ knife google server create $hostname -Z $zone -i ~/.ssh/google_compute_engine [... other arguments ...] --gce-service-account-scopes 'https://www.googleapis.com/auth/devstorage.read_write' -VV
INFO: Using configuration from /Users/nikolay.botev/.chef/knife.rb
/Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/gems/knife-google-3.1.0/lib/chef/knife/cloud/google_service.rb:248:in downcase!': can't modify frozen String (RuntimeError) from /Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/gems/knife-google-3.1.0/lib/chef/knife/cloud/google_service.rb:248:in valid_public_ip_setting?'
from /Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/gems/knife-google-3.1.0/lib/chef/knife/cloud/google_service.rb:216:in validate_server_create_options!' from /Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/gems/knife-google-3.1.0/lib/chef/knife/cloud/google_service.rb:113:in create_server'
from /Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/gems/knife-cloud-1.2.1/lib/chef/knife/cloud/server/create_command.rb:68:in execute_command' from /Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/gems/knife-cloud-1.2.1/lib/chef/knife/cloud/command.rb:51:in run'
from /Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/gems/chef-12.16.42/lib/chef/knife.rb:443:in block in run_with_pretty_exceptions' from /Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/gems/chef-12.16.42/lib/chef/local_mode.rb:44:in with_server_connectivity'
from /Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/gems/chef-12.16.42/lib/chef/knife.rb:442:in run_with_pretty_exceptions' from /Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/gems/chef-12.16.42/lib/chef/knife.rb:219:in run'
from /Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/gems/chef-12.16.42/lib/chef/application/knife.rb:156:in run' from /Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/gems/chef-12.16.42/bin/knife:25:in <top (required)>'
from /Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/bin/knife:22:in load' from /Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/bin/knife:22:in

'
from /Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/bin/ruby_executable_hooks:15:in eval' from /Users/nikolay.botev/.rvm/gems/ruby-2.3.3@chef/bin/ruby_executable_hooks:15:in '

ssh-agent no key added issue while node bootstra.

Version:

knife-google v3.3.7 and chef v15.0.266 on workstation

Environment:

centos-7

Scenario:

knife google server create ash-instance-3 --gce-image centos-7-v20160219 --gce-machine-type n1-standard-1 --gce-public-ip ephemeral --ssh-user msys --identity-file C:\Users\msys\.ssh\id_rsa --gce_project "ash-account-project" --gce_zone "us-east1-c" -c "D:\chef-repo\.chef\knife.rb" --image-os-type linux --bootstrap-protocol ssh -VV

Steps to Reproduce:

Please run above command to create the node from workstation.

Expected Result:

It should create the instance in google account and bootstrap the node.

Actual Result:

It create the instance in google account but fails to bootstrap the node by below error: command.rb:79:in `after_exec_command' C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/knife-cloud-1.2.3/lib/chef/knife/cloud/server/create_command.rb:90:in `rescue in after_exec_command': Check if --bootstrap-protocol and --image-os-type is correct. Your SSH Agent has no keys added, and you have not specified a password or a key file (Train::ClientError)

knife google hides quota errors from GCE

I've been using knife-google for months without error, and today I ran into a strange bug. I had always been able to do things like bundle exec knife google server create SERVER_NAME .... But today, I got an error after running that command.

Waiting for the create server operation to complete
.
.
Waiting for the servers to be in running state
ERROR: Google::Compute::ResourceNotFound: {
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "The resource 'projects/PROJECT_NAME/zones/us-central1-c/instances/mtse-test-xxx' was not found"
   }
  ],
  "code": 404,
  "message": "The resource 'projects/PROJECT_NAME/zones/us-central1-c/instances/mtse-test-xxx' was not found"
 }
}

I looked through knife-google's readme, and I was led to the suggestion that I typed in the incorrect "Project ID", or used the "Project ID Number" instead of the Project ID. After rerunning knife google setup multiple times, and recreating multiple new Client ID's, I was getting nowhere. I finally figured out the issue by trying to create a server through another method.

mtse@mtse-ubiquity-1:~$ gcloud compute instances create mtse-test-gcloud
...
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
ERROR: (gcloud.compute.instances.create) Some requests did not succeed:
 - Quota 'IN_USE_ADDRESSES' exceeded.  Limit: 23.0

So the reason knife-google failed was due to a GCE quota issue, which was totally swallowed up. It would have been really helpful for knife-google to output that.

`--bootstrap-version` flag isn't working

I'm using this knife plugin to set up GCE servers using chef. I require that a specific version (12.3.0) of chef-client is installed on the server nodes, because the latest version (12.4.0) breaks my cookbooks. So I attempted to add the --bootstrap-version 12.3.0 flag to the knife google server create command, but it doesn't work. The latest chef-client version (12.4.0) gets installed regardless of what I pass in. Here's the relevant console output:

mtse@XXXXXXXXXXXX chef-gce]$ bundle exec knife google server create mtse-base-vanilla-5 -m n1-standard-1 -I centos-7-vXXXXXX --gce-zone XXXXXX -r "role[base-vanilla]" -E staging-gce --bootstrap-version 12.3.0
Looking for Image 'centos-7-vXXXXXX' in Project 'XXXXXXXX
Looking for Image 'centos-7-vXXXXXX' in Project 'centos-cloud'
Found Image 'centos-7-vXXXXX' in Project 'centos-cloud'
Waiting for the boot disk insert operation to complete
Name: mtse-base-vanilla-5
Zone: XXXXXXX
Type: pd-standard
Size: 10 gb
Image: centos-7-XXXXXXX
.
Waiting for the create server operation to complete
.
Waiting for the servers to be in running state
Instance Name: mtse-base-vanilla-5
Machine Type: n1-standard-1
Image: centos-7-vXXXXXXXX
Zone: XXXXXXXXX
Tags: None
Public IP Address: ["XXXXXXXXXX"]
Private IP Address: ["XXXXXXXXXX"]
Waiting for server
Waiting for sshd
..done
Doing old-style registration with the validation key at /home/mtse/.chef/keys/XXXXXXXXXX...
Delete your validation key in order to use your user credentials instead

Connecting to XXXXXXXXXX
XXXXXXXXXX Installing Chef Client...
XXXXXXXXXX   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

▽
end
XXXXXXXXXX                                  Dload  Upload   Total   Spent    Left  Speed
100 18736  100 18736    0     0  42715      0 --:--:-- --:--:-- --:--:-- 42776
XXXXXXXXXX Downloading Chef 12 for el...
XXXXXXXXXX downloading https://www.opscode.com/chef/metadata?v=12&prerelease=false&nightlies=false&p=el&pv=7&m=x86_64
XXXXXXXXXX   to file /tmp/install.sh.1336/metadata.txt
XXXXXXXXXX trying curl...
XXXXXXXXXX url  https://opscode-omnibus-packages.s3.amazonaws.com/el/7/x86_64/chef-12.4.0-1.el7.x86_64.rpm
XXXXXXXXXX md5  4827ffe781f3736c9e546d1bb462a540
XXXXXXXXXX sha256   4ef1136c0aef6aac052ffe87b46492cd7b1ea95cd221611457904efa0cbf0bba
XXXXXXXXXX downloaded metadata file looks valid...
XXXXXXXXXX downloading https://opscode-omnibus-packages.s3.amazonaws.com/el/7/x86_64/chef-12.4.0-1.el7.x86_64.rpm
XXXXXXXXXX   to file /tmp/install.sh.1336/chef-12.4.0-1.el7.x86_64.rpm
XXXXXXXXXX trying curl...
XXXXXXXXXX Comparing checksum with sha256sum...
XXXXXXXXXX Installing Chef 12
XXXXXXXXXX installing with rpm...
XXXXXXXXXX warning: /tmp/install.sh.1336/chef-12.4.0-1.el7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY
XXXXXXXXXX Preparing...                          ################################# [100%]
XXXXXXXXXX Updating / installing...
XXXXXXXXXX    1:chef-12.4.0-1.el7                ################################# [100%]

Notice how the 12.4.0 version of chef-client gets installed even though I specify --bootstrap-version 12.3.0

SSH Authentication failed for root user which should be the user passed in --ssh-user.

Version:

knife-google v3.3.7 and chef v15.0.293 on workstation

Environment:

centos-7

Scenario:

 knife google server create ash-instance-55 --gce-image centos-7-v20160219 --gce-machine-type n1-standard-1 --gce-public-ip ephemeral --ssh-user msys --ssh-identity-file C:\Users\msys\.ssh\id_rsa --gce_project "ash-account-project" --gce_zone "us-east1-c" -c "D:\chef-repo\.chef\knife.rb"  -VV 

Steps to Reproduce:

Please run above command to create the node from workstation.

Expected Result:

It should create the instance in google account and bootstrap the node.

Actual Result:

It create the instance in google account but fails during ssh by below error:

[SSH] connection failed, terminating (#<Net::SSH::AuthenticationFailed: Authentication failed for user [email protected]>)
FATAL: Check if --bootstrap-protocol and --image-os-type is correct. SSH session could not be established ```

rake install does not work

I am attempting to install knife-google-2.0.0 via rake install but I am getting the error

...
ln spec/support/spec_google_base.rb pkg/knife-google-2.0.0/spec/support/spec_google_base.rb
cd pkg/knife-google-2.0.0
  Successfully built RubyGem
  Name: knife-google
  Version: 2.0.0
  File: knife-google-2.0.0.gem
mv knife-google-2.0.0.gem ..
cd -
gem install pkg/knife-google-2.0.0 --no-rdoc --no-ri
ERROR:  Could not find a valid gem 'pkg/knife-google-2.0.0' (>= 0) in any repository

I looks like a issue with rake::install not containg the gem extension.

  sh %{gem install pkg/#{GEM_NAME}-#{Knife::Google::VERSION} --no-rdoc --no-ri}

Can't execute any command with knife

I've installed chef dk and then I did a bundle gem install knife-google inside my chef-repo folder which I downloaded and unpacked from my chef server starter kit.

I've started with this command :

knife google setup

And I followed the input necessary including client id/secret etc. And I wanted to test if this is working by just trying to list the zones like this :

knife google zone list

And I get this error:

ERROR: TypeError: no implicit conversion of Time into String

Whichever command with knife google I execute I get this error, I'm running ruby-2.2.2. it's a ruby MRI.

google-knife and knife dependency versions

After I install google-knife, knife fails to run any commands, because of several gem conflict errors. What would you recommend to satisfy the dependency requirements of both knife and knife-google?

The following is a sequence of bash commands that reproduces the problem.

cat /etc/*-release

CentOS release 6.6 (Final)
CentOS release 6.6 (Final)
CentOS release 6.6 (Final)

wget https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chefdk-0.3.5-1.x86_64.rpm
rpm -Uvh chefdk-0.3.5-1.x86_64.rpm
knife help node
chef gem install knife-google

Fetching: retriable-1.4.1.gem (100%)
WARNING:  You don't have /root/.chefdk/gem/ruby/2.1.0/bin in your PATH,
          gem executables will not run.
Successfully installed retriable-1.4.1
Fetching: launchy-2.4.3.gem (100%)
Successfully installed launchy-2.4.3
Fetching: extlib-0.9.16.gem (100%)
Successfully installed extlib-0.9.16
Fetching: autoparse-0.3.3.gem (100%)
Successfully installed autoparse-0.3.3
Fetching: jwt-1.2.0.gem (100%)
Successfully installed jwt-1.2.0
Fetching: signet-0.6.0.gem (100%)
Successfully installed signet-0.6.0
Fetching: google-api-client-0.8.2.gem (100%)
Successfully installed google-api-client-0.8.2
Fetching: knife-google-1.3.1.gem (100%)
Successfully installed knife-google-1.3.1
Parsing documentation for retriable-1.4.1
Installing ri documentation for retriable-1.4.1
Parsing documentation for launchy-2.4.3
Installing ri documentation for launchy-2.4.3
Parsing documentation for extlib-0.9.16
Installing ri documentation for extlib-0.9.16
Parsing documentation for autoparse-0.3.3
Installing ri documentation for autoparse-0.3.3
Parsing documentation for jwt-1.2.0
Installing ri documentation for jwt-1.2.0
Parsing documentation for signet-0.6.0
Installing ri documentation for signet-0.6.0
Parsing documentation for google-api-client-0.8.2
Installing ri documentation for google-api-client-0.8.2
Parsing documentation for knife-google-1.3.1
Installing ri documentation for knife-google-1.3.1
Done installing documentation for retriable, launchy, extlib, autoparse, jwt, signet, google-api-client, knife-google afte
r 7 seconds
8 gems installed

knife help node

/opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:2099:in `raise_if_conflicts': Unable to activate chef-11.6.2, because mixlib-config-2.1.0 conflict
s with mixlib-config (>= 1.1.2, ~> 1.1), ohai-7.4.0 conflicts with ohai (< 7.0.0, >= 0.6.0), json-1.8.1 conflicts with json (<= 1.7.7, >= 1.4.4), net-ssh-multi-1.2.0 conf
licts with net-ssh-multi (~> 1.1.0) (Gem::ConflictError)
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1282:in `activate'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:90:in `block in require'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:89:in `each'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:89:in `require'
        from /root/.chefdk/gem/ruby/2.1.0/gems/google-api-client-0.8.2/lib/google/api_client/auth/storages/redis_store.rb:15:in `<top (required)>'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from /root/.chefdk/gem/ruby/2.1.0/gems/google-api-client-0.8.2/lib/google/api_client/service_account.rb:20:in `<top (required)>'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from /root/.chefdk/gem/ruby/2.1.0/gems/google-api-client-0.8.2/lib/google/api_client.rb:31:in `<top (required)>'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from /root/.chefdk/gem/ruby/2.1.0/gems/knife-google-1.3.1/lib/google/compute/client.rb:17:in `<top (required)>'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from /root/.chefdk/gem/ruby/2.1.0/gems/knife-google-1.3.1/lib/google/compute.rb:29:in `<top (required)>'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:128:in `require'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
        from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:39:in `require'
        from /root/.chefdk/gem/ruby/2.1.0/gems/knife-google-1.3.1/lib/chef/knife/google_base.rb:16:in `<top (required)>'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife/core/subcommand_loader.rb:37:in `load'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife/core/subcommand_loader.rb:37:in `block in load_commands'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife/core/subcommand_loader.rb:37:in `each'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife/core/subcommand_loader.rb:37:in `load_commands'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:120:in `load_commands'
        from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:168:in `run'
        from /opt/chefdk/embedded/apps/chef/lib/chef/application/knife.rb:139:in `run'
        from /opt/chefdk/embedded/apps/chef/bin/knife:25:in `<top (required)>'
        from /usr/bin/knife:33:in `load'
        from /usr/bin/knife:33:in `<main>'

chef gem uninstall knife-google

Successfully uninstalled knife-google-1.3.1

knife help node

Dependency Conflict on MacOS

Version:

knife-google 1.3.1

$ chef -v
Chef Development Kit Version: 2.3.4
chef-client version: 13.4.24
delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
berks version: 6.3.1
kitchen version: 1.18.0
inspec version: 1.40.0

Environment:

MacOS X 10.9.3

Scenario:

Installing from ChefDK, install is successful but dependency prevents knife from executing.
$ chef gem install knife-google
Fetching: knife-google-3.1.1.gem (100%)
WARNING: You don't have /Users/.chefdk/gem/ruby/2.4.0/bin in your PATH,
gem executables will not run.
Successfully installed knife-google-3.1.1

Steps to Reproduce:

Install knife-google from master on MacOS.

Expected Result:

knife should run commands

Actual Result:

$knife google
/opt/chefdk/embedded/lib/ruby/2.4.0/rubygems/specification.rb:2293:in raise_if_conflicts': Unable to activate knife-google-3.1.1, because chef-13.4.19 conflicts with chef (~> 12.0), google-api-client-0.8.7 conflicts with google-api-client (~> 0.9.0) (Gem::ConflictError) from /opt/chefdk/embedded/lib/ruby/2.4.0/rubygems/specification.rb:1413:in activate'
from /opt/chefdk/embedded/lib/ruby/2.4.0/rubygems.rb:220:in rescue in try_activate' from /opt/chefdk/embedded/lib/ruby/2.4.0/rubygems.rb:213:in try_activate'
from /opt/chefdk/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:126:in rescue in require' from /opt/chefdk/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:40:in require'
from /Users/echiu/.chefdk/gem/ruby/2.4.0/gems/knife-google-3.1.1/lib/chef/knife/google_disk_create.rb:22:in <top (required)>' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife/core/subcommand_loader.rb:85:in load'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife/core/subcommand_loader.rb:85:in block in load_commands' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife/core/subcommand_loader.rb:85:in each'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife/core/subcommand_loader.rb:85:in load_commands' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife/core/subcommand_loader.rb:95:in load_command'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife/core/subcommand_loader.rb:109:in command_class_from' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife.rb:153:in subcommand_class_from'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife.rb:214:in run' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/application/knife.rb:156:in run'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/bin/knife:25:in <top (required)>' from /usr/local/bin/knife:267:in load'
from /usr/local/bin/knife:267:in `

'
$ chef gem update google-knife

Failing to create a server with a custom image

I am trying to create a server with a custom image i have created and it fails.


knife google server create scraper-instance-test -m g1-small -I base-sraper -Z us-central1-a -i ~/.ssh/id_rsa -x root
Looking for Image 'base-sraper' in Project 'wondermall-dev'
ERROR: Image 'base-sraper' not found

There is clearly an image called 'base-scraper' in the wondermall-dev projects.

image

Set application_name and application_version

Sorry I missed this in the initial review.

Similar to the comment/request for kitchen-google, let's set the application_name to knife-google and pick up the version to set for application_version. The old version used this value, so let's carry this forward with the re-write.

Looks like the change needs to happen here:

@connection = Google::Apis::ComputeV1::ComputeService.new

Here's the pointer to setting client options: https://github.com/google/google-api-ruby-client/blob/e8481dd14dc2af0667866a319832dc9adc8d54bf/lib/google/apis/options.rb#L32

/cc @adamleff

Can't Modify Frozen String

Version:

$ chef gem list knife-google

*** LOCAL GEMS ***

knife-google (3.1.0)

Environment: [Details about the environment such as the Operating System, cookbook details, etc...]

Windows 7 Enterprise
ChefDK 1.1.16

Scenario:

knife google server create "chef-knife-test" --gce-project "project-name" --gce-zone "zone"  --gce-machine-type "n1-standard-1" --gce-subnet "compute-uswest" --gce-network "development" --gce-service-account-scopes “<LIST OF SCOPES>” --gce-tags "no-ip","webservices" --gce-image "compute-golden2" --gce-image-project "project-id" --gce-boot-disk-size "10" -x “username” -i “path-to-key” --sudo -r 'role[base_linux]'

Steps to Reproduce:

Run the above command

Expected Result:

A server should be created

Actual Result:

Output shows an error can't modify frozen string

Running with -VV shows an error on ../knife-google-3.1.0/lib/chef/knife/cloud/google_service:248:in downcase!: can't modify a frozen string

247:     def valid_public_ip_setting?(public_ip)
    248: require 'pry';binding.pry
=> 249:       public_ip.downcase! if public_ip.respond_to?(:downcase)
    250:
    251:       if public_ip.nil? || public_ip == "ephemeral" || public_ip == "none"
    252:         true
    253:       elsif valid_ip_address?(public_ip)
    254:         true
    255:       else
    256:         false
    257:       end
    258:     end
[1] pry(#<Chef::Knife::Cloud::GoogleService>)> public_ip
=> "EPHEMERAL"
[2] pry(#<Chef::Knife::Cloud::GoogleService>)> public_ip.downcase! if public_ip.respond_to?(:downcase)
RuntimeError: can't modify frozen String
from (pry):2:in `downcase!'
[3] pry(#<Chef::Knife::Cloud::GoogleService>)> public_ip.downcase if public_ip.respond_to?(:downcase)
=> "ephemeral"
[4] pry(#<Chef::Knife::Cloud::GoogleService>)>

knife-google not setting custom metadata

Suddenly knife-google is not setting the custom metadata on created instances.
It might be related to a recent update of the gcloud SDK, though I'm not sure.
Adding verbosity (-VVV) to the process doesn't seem to give any interesting clues.
Creating the instance via native gcloud command works.

Password prompt each time I run 'knife google server create' or 'knife bootstrap' with GCE instances

Hi

Each time I am creating a server with knife google server create I am prompted for a password when the process tries ssh into the machine.

Connecting to 108.59.84.220
Failed to authenticate kournjaev - trying password auth
Enter your password:
108.59.84.220 Starting first Chef Client run...
108.59.84.220 Starting Chef Client, version 11.10.4

The password can any string and the process would continue.
Also it is very strange that I can omit the -i option and not provide any ssh key and still.

Could you please explain :

  • how come can the chef client be installed without a ssh key on the machine.
  • Why i am prompted for a password each time ? Is there a way to set up an empty password in the arguments -P is not working.
  • Is the process authenticated by a default ssh key? If yes where is it stored ?

That question is open for 3 months on my desk and there are just not so many people that use chef on gce so i have no one to ask but you guys.

Thanks
Roman

Error in metadata parsing while creating a compute instance

I am trying to create a new instance, and passing sshKeys as metadata.
My ssh public key has "=" a character, due to which metadata was not getting updated properly

 --gce-metadata sshKeys="user:ssh-rsa blah,blah== me@example

But when instance is getting created it has

ssh-rsa blah,blah

as ssh key and drops "== me@example" at the end

Google::Apis::ClientError

I am using knife-google-2.2.0 gem, looks like some commands do not work anymore, such as google server list:

knife google server list --gce-project mytest-app --gce-zone asia-east1-c

Output:

ERROR: Google::Apis::ClientError: notFound: The resource 'projects/mytest-app' was not found

not honoring "--node-ssl-verify-mode none"

Version:

knife-google (3.1.1)

Environment:

Chef Development Kit Version: 1.6.1
chef-client version: 12.21.4
delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
berks version: 5.6.4
kitchen version: 1.16.0
inspec version: 1.25.1
Linux Mint 18.2

Scenario:

when trying to create a server in GCE and have it bootstrapped, the bootstrapping process fails at the chef-server's SSL check despite specifying --node-ssl-verify-mode none

Steps to Reproduce:

knife google server create testing-bootstrap-22 --gce-image centos-7-v20170816 --gce-machine-type f1-micro --gce-boot-disk-size 10 --ssh-user adam --identity-file ~/.ssh/google_compute_engine -E _default -r "recipe[chef-client]"  --sudo -x adam --node-ssl-verify-mode none 

Searching public image project centos-cloud for image centos-7-v20170816 
Creating instance...

Current status: PENDING.
Current status: RUNNING..

Instance created!
Instance Name: testing-bootstrap-22
Status: RUNNING
Machine Type: f1-micro
Project: spdc-175018
Zone: us-central1-c
Network: default
Private IP: 10.128.0.17
Public IP: 104.197.50.0
Bootstrapping the server by using bootstrap_protocol: ssh and image_os_type: linux

Waiting for sshd to host (104.197.50.0)done
Doing old-style registration with the validation key at /home/adam/.chef/<my_org>-validator.pem...
Delete your validation key in order to use your user credentials instead

Connecting to 104.197.50.0

...
[snip]
...

104.197.50.0 Creating a new client identity for testing-bootstrap-22 using the validator key.
104.197.50.0 [2017-08-29T16:41:38+00:00] INFO: Client key /etc/chef/client.pem is not present - registering
104.197.50.0 [2017-08-29T16:41:38+00:00] ERROR: SSL Validation failure connecting to host: 104.197.209.174 - SSL_connect returned=1 errno=0 state=error: certificate verify failed
104.197.50.0 
104.197.50.0 ================================================================================
104.197.50.0 Chef encountered an error attempting to create the client "testing-bootstrap-22"
104.197.50.0 ================================================================================
104.197.50.0 
104.197.50.0 System Info:
104.197.50.0 ------------
104.197.50.0 chef_version=12.21.4
104.197.50.0 ruby=ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-linux]
104.197.50.0 program_name=chef-client worker: ppid=1107;start=16:41:34;
104.197.50.0 executable=/opt/chef/bin/chef-client
104.197.50.0 
104.197.50.0 
104.197.50.0 Running handlers:
104.197.50.0 [2017-08-29T16:41:38+00:00] ERROR: Running exception handlers
104.197.50.0 Running handlers complete
104.197.50.0 [2017-08-29T16:41:38+00:00] ERROR: Exception handlers complete
104.197.50.0 Chef Client failed. 0 resources updated in 03 seconds
104.197.50.0 [2017-08-29T16:41:38+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
104.197.50.0 [2017-08-29T16:41:38+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
104.197.50.0 [2017-08-29T16:41:38+00:00] ERROR: SSL Error connecting to https://104.197.209.174/organizations/spdc-gcp/clients - SSL_connect returned=1 errno=0 state=error: certificate verify failed
104.197.50.0 [2017-08-29T16:41:38+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

I can turn around and immediately bootstrap this same node with the same bootstrap arg using the 'normal' boostrap procedure:

knife bootstrap 104.197.50.0 -E _default -r "recipe[chef-client]"  --sudo -x adam --node-ssl-verify-mode none
Doing old-style registration with the validation key at /home/adam/.chef/spdc-gcp-validator.pem...
Delete your validation key in order to use your user credentials instead

Connecting to 104.197.50.0
104.197.50.0 -----> Existing Chef installation detected
104.197.50.0 Starting the first Chef Client run...
104.197.50.0 [2017-08-29T16:46:24+00:00] INFO: Forking chef instance to converge...
104.197.50.0 Starting Chef Client, version 12.21.4
104.197.50.0 [2017-08-29T16:46:24+00:00] INFO: *** Chef 12.21.4 ***

...
[snip]
...


104.197.50.0     - restart service service[chef-client]
104.197.50.0 [2017-08-29T16:46:29+00:00] INFO: Chef Run complete in 3.018783552 seconds
104.197.50.0 
104.197.50.0 Running handlers:
104.197.50.0 [2017-08-29T16:46:29+00:00] INFO: Running report handlers
104.197.50.0 Running handlers complete
104.197.50.0 [2017-08-29T16:46:29+00:00] INFO: Report handlers complete
104.197.50.0 Chef Client finished, 9/10 resources updated in 04 seconds

Expected Result:

--node-ssl-verify-mode none should disable SSL check of remote chef-server

how do i mount a disk on an instance which i am creating

Version:

:ref => "800f000262f71a28e588308be4279a0c4140bca2"

Environment:

on mac OS sierra

Scenario:

I am trying to create instance with a separate partition with a disk mounted on top of it. I am able to create instances with just boot disk otherwise

Create an "image list" command

New command knife google image list should list the images available in the currently-configured project, and then the most recent project for each of the known public image projects and image aliases (i.e. the latest centos-6 image, centos-7 image, etc).

Unresolved Dependency Causes StackTrace

Version:

  • knife-google (3.2.0)
  • google-cloud-sdk: 197.0.0-0
  • Ubuntu 16.04 Xenial
  • ChefDK
    Chef Development Kit Version: 2.3.5
    chef-client version: 13.4.19
    delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
    berks version: 6.3.1
    kitchen version: 1.17.0
    inspec version: 1.39.1
    

Scenario:

I am trying to install and use knife google, just list servers.

Steps to Reproduce:

  1. chef gem install knife-google
  2. knife google server list

Expected Result:

List of servers, Not Crashing

Actual Result:

Crashing, stack trace. Looks like unresolved dependency that was expected to be there, but specified in Gemfile.

/opt/chefdk/embedded/lib/ruby/2.4.0/rubygems/specification.rb:2293:in `raise_if_conflicts': Unable to activate knife-google-3.2.0, because google-api-client-0.8.7 conflicts with google-api-client (~> 0.9.0) (Gem::ConflictError)
	from /opt/chefdk/embedded/lib/ruby/2.4.0/rubygems/specification.rb:1413:in `activate'
	from /opt/chefdk/embedded/lib/ruby/2.4.0/rubygems.rb:220:in `rescue in try_activate'
	from /opt/chefdk/embedded/lib/ruby/2.4.0/rubygems.rb:213:in `try_activate'
	from /opt/chefdk/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:126:in `rescue in require'
	from /opt/chefdk/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:40:in `require'
	from /home/joaquin/.chefdk/gem/ruby/2.4.0/gems/knife-google-3.2.0/lib/chef/knife/google_zone_list.rb:22:in `<top (required)>'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife/core/subcommand_loader.rb:85:in `load'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife/core/subcommand_loader.rb:85:in `block in load_commands'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife/core/subcommand_loader.rb:85:in `each'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife/core/subcommand_loader.rb:85:in `load_commands'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife/core/subcommand_loader.rb:95:in `load_command'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife/core/subcommand_loader.rb:109:in `command_class_from'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife.rb:153:in `subcommand_class_from'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/knife.rb:214:in `run'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/lib/chef/application/knife.rb:156:in `run'
	from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.4.19/bin/knife:25:in `<top (required)>'
	from /opt/chefdk/bin/knife:267:in `load'
	from /opt/chefdk/bin/knife:267:in `<main>'

Bootstrapping the node fails while running `sh /tmp/chef_7ObzwE/bootstrap.sh` for windows workstation

Version:

knife-google v3.3.7 and chef v15.0.298 on windows workstation

Environment:

ubuntu 16 and centos-7

Scenario:

PS C:\> knife google server create ash-instance-32 --gce-image ubuntu-1604-xenial-v20190514 --gce-machine-type n1-standard-1 --gce-public-ip ephemeral -i C:\Users\msys\.ssh\id_rsa --gce_project "ash-abacus-240907" --gce_zone "us-east1-b" -c "C:D\chef-repo\.chef\knife.rb"  -VV

Steps to Reproduce:

Please run above command to create the node from workstation.

Expected Result:

It should create the instance in google account and bootstrap the node.

Actual Result:

It create the instance in google account and ssh establish on it but fails during sh /tmp/chef_7ObzwE/bootstrap.sh by below error:

DEBUG: [SSH] [email protected]<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>30, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["C:\\Users\\msys\\.ssh\\id_rsa"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:accept_new}> (sh /tmp/chef_7ObzwE/bootstrap.sh)
 [34.73.45.171] sh: 1:
: not found171]
 [34.73.45.171]
 [34.73.45.171] sh: 2:
: not found171]
 [34.73.45.171]
 [34.73.45.171] sh: 3:
: not found171]
 [34.73.45.171]
 [34.73.45.171] sh: 4:
: not found171]
 [34.73.45.171]
 [34.73.45.171] sh: 234:
 [34.73.45.171] Syntax error: end of file unexpected (expecting "then")
 [34.73.45.171]
ERROR: The following error occurred on 34.73.45.171:
ERROR:

ERROR: Image 'ubuntu-1404-trusty-v20150316' not found

I'm trying to use knife google server create to launch a new instance with image ubuntu-1404-trusty-v20150316, which is listed as a valid image by gcloud:

$ gcloud compute images list | grep trusty
ubuntu-1404-trusty-v20150316 ubuntu-os-cloud ubuntu-14-04 READY

Is there any way to configure knife to have it look at the same list of images as gcloud?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.