Provision of aws windows image fails on chef-solo start

50 views
Skip to first unread message

Moshe Zuisman

unread,
Oct 20, 2015, 8:23:26 AM10/20/15
to Vagrant

Hi.
I am trying to run fairly simple vagrant bootstrup, that have to create aws windows machine and run their test chef_solo cookbook. Cookbook is "hello world" style (it simply performs touch of file - simply to give indication, that chef actually worked).

require File.expand_path('aws/aws_credentials.rb')
Vagrant.configure("2") do |config|
config.vm.guest = :windows
config.vm.communicator = :winrm
config.vm.synced_folder ".", "/vagrant", type: "winrm", :disabled => true
config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
config.vm.box = "dummy"
# Admin user name and password
config.winrm.username = "vagrant"
config.winrm.password = "maypass"
#config.winrm.password = "vagrant"
config.nfs.functional = false

config.vm.provider :aws do |aws, override|
    aws.user_data = File.read("aws/Setup.txt")
    aws.tags = {
      'Name' => @aws_machine_name,
    }
    aws.access_key_id=@access_key_id
    aws.secret_access_key=@secret_access_key
    aws.keypair_name=@keypair_name
    aws.ami=@ami
    aws.region=@region
    aws.instance_type=@instance_type
    #aws.security_groups= [ @security_groups ]
end

config.vm.provision :chef_solo do |chef| 
    chef.synced_folder_type = "winrm" 
    chef.add_recipe("Control-M::touch_file")
    #chef.add_recipe("vim-windows")
end 

end

Now - I face really ministerial mess.
First of all I had to create precooked base windows image at which I pre-installed chef client, since at windows vagrant function "chef_install simply do not works...

But after I did it began really strange mess.
When I run vagrant with those job from Linux machine (Redhat) - it works.
When I run same job with same vagrant file from windows machine(that means - I installed vagrant at my windows desktop and run it with those vagratfile from there) - I get:
==> default: Uploading with WinRM: C:/DevOps/cookbooks => C:/vagrant-chef/353b41
3e9c77f16b0448c1300d9ab1e0/cookbooks
==> default: Running provisioner: chef_solo...
==> default: Detected Chef (latest) is already installed
Generating chef JSON and uploading...
==> default: Running chef-solo...
==> default: Exception calling "Run" with "1" argument(s): "Element not found. (
Exception
==> default: from HRESULT: 0x80070490)"
==> default: At C:\tmp\vagrant-elevated-shell.ps1:61 char:1
==> default: + $registered_task.Run($null) | Out-Null
==> default: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==> default: + CategoryInfo : NotSpecified: (:) [], MethodInvocatio
nException
==> default: + FullyQualifiedErrorId : ComMethodTargetInvocation
==> default:
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

I have tried it number of times. From my local desctop and from windows virtual machine that intself runs at aws... Always same result!

Shawn Neal

unread,
Oct 21, 2015, 11:15:00 AM10/21/15
to Vagrant
vagrant-aws will work with Windows but you need to install the vagrant-winrm-syncedfolders plugin to allow Vagrant to be able to upload files to the instance over WinRM since rsync can't use the winrm transport.

Moshe Zuisman

unread,
Oct 25, 2015, 8:48:07 AM10/25/15
to Vagrant

Yes - I know about vagrant-winrm-syncedfolders plugin. and it is already installed at my comp:
C:\DevOps>vagrant plugin list
vagrant-aws (0.6.0)
vagrant-share (1.1.4, system)
vagrant-winrm-syncedfolders (1.0.0)

So - it is not a source of problem...

среда, 21 октября 2015 г., 18:15:00 UTC+3 пользователь Shawn Neal написал:
Reply all
Reply to author
Forward
0 new messages