{"action":"created","issue":{"url":"https://api.github.com/repos/chef/chef-provisioning/issues/390","labels_url":"https://api.github.com/repos/chef/chef-provisioning/issues/390/labels{/name}","comments_url":"https://api.github.com/repos/chef/chef-provisioning/issues/390/comments","events_url":"https://api.github.com/repos/chef/chef-provisioning/issues/390/events","html_url":"https://github.com/chef/chef-provisioning/issues/390","id":95108581,"number":390,"title":"machine_file resource does not work properly using with_machine_options","user":{"login":"poliva83","id":3772510,"avatar_url":"https://avatars.githubusercontent.com/u/3772510?v=3","gravatar_id":"","url":"https://api.github.com/users/poliva83","html_url":"https://github.com/poliva83","followers_url":"https://api.github.com/users/poliva83/followers","following_url":"https://api.github.com/users/poliva83/following{/other_user}","gists_url":"https://api.github.com/users/poliva83/gists{/gist_id}","starred_url":"https://api.github.com/users/poliva83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poliva83/subscriptions","organizations_url":"https://api.github.com/users/poliva83/orgs","repos_url":"https://api.github.com/users/poliva83/repos","events_url":"https://api.github.com/users/poliva83/events{/privacy}","received_events_url":"https://api.github.com/users/poliva83/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/chef/chef-provisioning/labels/Bug","name":"Bug","color":"fc2929"},{"url":"https://api.github.com/repos/chef/chef-provisioning/labels/Waiting","name":"Waiting","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-07-15T05:17:08Z","updated_at":"2015-08-18T22:15:52Z","closed_at":null,"body":"The recipe below will provision the machine resource properly and converge recipe but fail when trying to download files afterwards using machine_file resource. However when you move remove the with_machine_options block and put driver_options & machine_options into a profile it actually works.\r\n\r\nMaybe has something to do with how machine resource picks up with_machine_options through calls to new_machine_options or current_machine_options.\r\nhttps://github.com/chef/chef-provisioning/blob/master/lib/chef/provider/machine.rb#L30\r\nhttps://github.com/chef/chef-provisioning/blob/master/lib/chef/provider/machine.rb#L38\r\nhttps://github.com/chef/chef-provisioning/blob/master/lib/chef/provider/machine.rb#L130\r\n\r\nmachine_file resource doesn't appear to have such methods and ends up with Chef::Config object without the correct machine options instead of Cheffish::MergedConfig object. \r\nhttps://github.com/chef/chef-provisioning/blob/master/lib/chef/provider/machine_file.rb#L24\r\nhttps://github.com/chef/chef-provisioning/blob/master/lib/chef/provider/machine_file.rb#L19\r\nhttps://github.com/chef/chef-provisioning/blob/master/lib/chef/provisioning/chef_run_data.rb#L93\r\n\r\nExcept in case you put machine options inside your profile and then machine_file will end up getting a Cheffish::MergedConfig object with the options defined.\r\n\r\nchef-client -c ~/.chef/knife.rb ./provision.rb\r\n* provision.rb\r\n```\r\ndirectory '/tmp/stash' do\r\n  recursive true\r\nend\r\n\r\none_endpoint     = \"http://10.10.10.10/fake\"\r\none_credentials  = \"Account:fake\"\r\n\r\nwith_driver \"opennebula:#{one_endpoint}\",\r\n  :credentials => \"#{one_credentials}\"\r\n\r\nbase_image_name  = \"ubuntu-14.04.1-pre-prod-20150305-40G\"\r\nbase_image_uname = \"chef\"\r\n\r\nwith_machine_options :bootstrap_options => {\r\n  :template => {\r\n    \"HTTPBASE\" => \"http://fake-cli.fake.net/~chef/context\",\r\n    \"HTTPBASE2\" => \"http://fake-cli.fake.net/~Mandolin/chef-client-package\",\r\n    \"MEMORY\" => \"2048\",\r\n    \"CPU\" => \"2\",\r\n    \"VCPU\" => \"2\",\r\n    \"OS\" => {\r\n      \"ARCH\" => \"x86_64\"\r\n    },\r\n    \"DISK\" => {\r\n      \"IMAGE\" => base_image_name,\r\n      \"IMAGE_UNAME\" => base_image_uname,\r\n      \"DRIVER\" => \"qcow2\"\r\n    },\r\n    \"NIC\" => {\r\n      \"NETWORK\" => \"chef12backend\",\r\n      \"NETWORK_UNAME\" => \"Mandolin\"\r\n    },\r\n    \"GRAPHICS\" => {\r\n      \"LISTEN\" => \"0.0.0.0\",\r\n      \"TYPE\" => \"vnc\"\r\n    },\r\n    \"CONTEXT\" => {\r\n      \"DOMAIN\" => \"chef.fake.net\",\r\n      \"NETWORK\" => \"YES\",\r\n      \"TEST_KITCHEN\" => \"YES\",\r\n      \"HOSTNAME\" => \"$NAME\",\r\n      \"INSTALL_CHEF_CLIENT_COMMAND\" => \"dpkg -E -i /mnt/chef_12.4.1-1_amd64.deb\",\r\n      \"SSH_USER\" => 'local',\r\n      \"SSH_PUBLIC_KEY\" => ::File.read(\"#{ENV['HOME']}/.ssh/id_rsa.pub\"),\r\n      \"FILES\" => \"$HTTPBASE/01_chef $HTTPBASE2/chef_12.4.1-1_amd64.deb\"\r\n    }\r\n  }\r\n},\r\n:ssh_user => 'local',\r\n:ssh_options => {\r\n  :keys_only => false,\r\n  :forward_agent => true,\r\n  :use_agent => true,\r\n  :user_known_hosts_file => '/dev/null'\r\n},\r\n:ssh_execute_options => {\r\n  :prefix => 'sudo '\r\n},\r\n:cached_installer => true\r\n\r\nmachine 'bootstrap-backend' do\r\n  tag ''\r\n  recipe 'bb-chef-server-cluster'\r\n  recipe 'chef-server-cluster::bootstrap'\r\n  action :converge\r\n\r\n  files ({\r\n    '/etc/environment' => { :content => <<END_CLIENT_RB\r\nEND_CLIENT_RB\r\n    }\r\n  })\r\nend\r\n\r\n%w{ actions-source.json webui_priv.pem }.each do |analytics_file|\r\n  machine_file \"/etc/opscode-analytics/#{analytics_file}\" do\r\n    local_path \"/tmp/stash/#{analytics_file}\"\r\n    machine 'bootstrap-backend'\r\n    action :download\r\n  end\r\nend\r\n\r\n%w{ pivotal.pem webui_pub.pem }.each do |opscode_file|\r\n  machine_file \"/etc/opscode/#{opscode_file}\" do\r\n    local_path \"/tmp/stash/#{opscode_file}\"\r\n    machine 'bootstrap-backend'\r\n    action :download\r\n  end\r\nend\r\n```\r\n\r\nCHEF_PROFILE=default chef-client -c ~/.chef/knife.rb ./provision.rb\r\n* ~/.chef/knife.rb\r\n```\r\nprofiles({\r\n  'default' => {\r\n    :driver => \"opennebula:http://10.10.10.10/fake\",\r\n    :driver_options => {:credentials => \"Account:fake\"},\r\n    :machine_options => { :bootstrap_options => {\r\n        :template => {\r\n            \"HTTPBASE\" => \"http://fake-cli.fake.net/~chef/context\",\r\n            \"HTTPBASE2\" => \"http://fake-cli.fake.net/~Mandolin/chef-client-package\",\r\n            \"MEMORY\" => \"2048\",\r\n            \"CPU\" => \"2\",\r\n            \"VCPU\" => \"2\",\r\n            \"OS\" => {\r\n              \"ARCH\" => \"x86_64\"\r\n            },\r\n            \"DISK\" => {\r\n              \"IMAGE\" => base_image_name,\r\n              \"IMAGE_UNAME\" => base_image_uname,\r\n              \"DRIVER\" => \"qcow2\"\r\n            },\r\n            \"NIC\" => {\r\n              \"NETWORK\" => \"chef12backend\",\r\n              \"NETWORK_UNAME\" => \"Mandolin\"\r\n            },\r\n            \"GRAPHICS\" => {\r\n              \"LISTEN\" => \"0.0.0.0\",\r\n              \"TYPE\" => \"vnc\"\r\n            },\r\n            \"CONTEXT\" => {\r\n              \"DOMAIN\" => \"chef.fake.net\",\r\n              \"NETWORK\" => \"YES\",\r\n              \"TEST_KITCHEN\" => \"YES\",\r\n              \"HOSTNAME\" => \"$NAME\",\r\n              \"INSTALL_CHEF_CLIENT_COMMAND\" => \"dpkg -E -i /mnt/chef_12.4.1-1_amd64.deb\",\r\n              \"SSH_USER\" => 'local',\r\n              \"SSH_PUBLIC_KEY\" => ::File.read(\"#{ENV['HOME']}/.ssh/id_rsa.pub\"),\r\n              \"FILES\" => \"$HTTPBASE/01_chef $HTTPBASE2/chef_12.4.1-1_amd64.deb\"\r\n            }\r\n          },\r\n      :ssh_user => 'local',\r\n      :ssh_options => {\r\n        :keys_only => false,\r\n        :forward_agent => true,\r\n        :use_agent => true,\r\n        :user_known_hosts_file => '/dev/null'\r\n      },\r\n      :ssh_execute_options => {\r\n        :prefix => 'sudo '\r\n      },\r\n      :cached_installer => true\r\n    }}\r\n  }\r\n})\r\n```"},"comment":{"url":"https://api.github.com/repos/chef/chef-provisioning/issues/comments/132372160","html_url":"https://github.com/chef/chef-provisioning/issues/390#issuecomment-132372160","issue_url":"https://api.github.com/repos/chef/chef-provisioning/issues/390","id":132372160,"user":{"login":"poliva83","id":3772510,"avatar_url":"https://avatars.githubusercontent.com/u/3772510?v=3","gravatar_id":"","url":"https://api.github.com/users/poliva83","html_url":"https://github.com/poliva83","followers_url":"https://api.github.com/users/poliva83/followers","following_url":"https://api.github.com/users/poliva83/following{/other_user}","gists_url":"https://api.github.com/users/poliva83/gists{/gist_id}","starred_url":"https://api.github.com/users/poliva83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poliva83/subscriptions","organizations_url":"https://api.github.com/users/poliva83/orgs","repos_url":"https://api.github.com/users/poliva83/repos","events_url":"https://api.github.com/users/poliva83/events{/privacy}","received_events_url":"https://api.github.com/users/poliva83/received_events","type":"User","site_admin":false},"created_at":"2015-08-18T22:15:52Z","updated_at":"2015-08-18T22:15:52Z","body":"@tyler-ball @pburkholder I've logged issue internally and will update our driver soon to follow the newer conventions. We are planning on opensourcing driver but there are still some features/issues we need to address (this being one of them) before we feel comfortable to release. "}}