{"action":"created","issue":{"url":"https://api.github.com/repos/chef/chef-provisioning/issues/404","labels_url":"https://api.github.com/repos/chef/chef-provisioning/issues/404/labels{/name}","comments_url":"https://api.github.com/repos/chef/chef-provisioning/issues/404/comments","events_url":"https://api.github.com/repos/chef/chef-provisioning/issues/404/events","html_url":"https://github.com/chef/chef-provisioning/pull/404","id":99022578,"number":404,"title":"Zz/policy support","user":{"login":"double-z","id":935280,"avatar_url":"https://avatars.githubusercontent.com/u/935280?v=3","gravatar_id":"","url":"https://api.github.com/users/double-z","html_url":"https://github.com/double-z","followers_url":"https://api.github.com/users/double-z/followers","following_url":"https://api.github.com/users/double-z/following{/other_user}","gists_url":"https://api.github.com/users/double-z/gists{/gist_id}","starred_url":"https://api.github.com/users/double-z/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/double-z/subscriptions","organizations_url":"https://api.github.com/users/double-z/orgs","repos_url":"https://api.github.com/users/double-z/repos","events_url":"https://api.github.com/users/double-z/events{/privacy}","received_events_url":"https://api.github.com/users/double-z/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/chef/chef-provisioning/labels/Developing","name":"Developing","color":"ededed"},{"url":"https://api.github.com/repos/chef/chef-provisioning/labels/Feedback%20Requested","name":"Feedback Requested","color":"d4c5f9"},{"url":"https://api.github.com/repos/chef/chef-provisioning/labels/Improvement","name":"Improvement","color":"009800"},{"url":"https://api.github.com/repos/chef/chef-provisioning/labels/Signed%20CLA","name":"Signed CLA","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/chef/chef-provisioning/milestones/8","html_url":"https://github.com/chef/chef-provisioning/milestones/1.5.0","labels_url":"https://api.github.com/repos/chef/chef-provisioning/milestones/8/labels","id":1300136,"number":8,"title":"1.5.0","description":"","creator":{"login":"tyler-ball","id":2481463,"avatar_url":"https://avatars.githubusercontent.com/u/2481463?v=3","gravatar_id":"","url":"https://api.github.com/users/tyler-ball","html_url":"https://github.com/tyler-ball","followers_url":"https://api.github.com/users/tyler-ball/followers","following_url":"https://api.github.com/users/tyler-ball/following{/other_user}","gists_url":"https://api.github.com/users/tyler-ball/gists{/gist_id}","starred_url":"https://api.github.com/users/tyler-ball/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tyler-ball/subscriptions","organizations_url":"https://api.github.com/users/tyler-ball/orgs","repos_url":"https://api.github.com/users/tyler-ball/repos","events_url":"https://api.github.com/users/tyler-ball/events{/privacy}","received_events_url":"https://api.github.com/users/tyler-ball/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":0,"state":"open","created_at":"2015-09-10T21:38:01Z","updated_at":"2015-09-16T21:37:18Z","due_on":null,"closed_at":null},"comments":8,"created_at":"2015-08-04T17:49:59Z","updated_at":"2015-09-18T05:46:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/chef/chef-provisioning/pulls/404","html_url":"https://github.com/chef/chef-provisioning/pull/404","diff_url":"https://github.com/chef/chef-provisioning/pull/404.diff","patch_url":"https://github.com/chef/chef-provisioning/pull/404.patch"},"body":"This pull request adds policyfile support - beyond passing it in in the chef_config convergence options - to  the machine resource/provider vi the use of `policy_name` and `policy_group` machine resource attributes, which are then handled within the convergence_strategy `precreate_chef_objects.rb` during the client_rb_content method.\r\n\r\nNot sure if this is something we want to introduce at this point, with policyfiles still being experimental, so this is at minimum a way to begin the discussion. \r\n\r\nThis strikes me as how to go about it, for now at least, but thoughts on other approaches in the comments here would be great.\r\n\r\nThe usage is as follows:\r\n\r\n```\r\nmachine \"sshone\" do\r\n  action :converge\r\n  machine_options 'transport_options' => {\r\n    'ip_address' => '192.168.33.22',\r\n    'username' => 'vagrant',\r\n    'ssh_options' => {\r\n      'password' => 'vagrant'\r\n    }\r\n  }\r\n  policy_name 'machine_test'\r\n  policy_group 'policymachine'\r\nend\r\n```\r\n\r\nIt requires native policyfile support so 12.1+ server or hosted is required, i.e the `with_local_chef_server` option isn't supported at this time, because  `policy_document_native_api` and `policy_group` along with the `-z` option for chef-client are all not supported in zero.\r\n\r\nSome features include:\r\n\r\n- sanity check that checks if running provisioning in local mode.\r\n- sanity check to ensure `convergence_strategy[:chef_config]` does not contain any conflicting policy settings\r\n- sanity check to ensure both `policy_group` and `policy_name` have been passed.\r\n\r\nAll of the above have been tested against all possible relative situations and behave as expected. Not using `policy_name` and `policy_group` has no affect on overall behavior and are silently ignored in the same way as other undefined convergence_options... It is only injected into the convergence_strategy if it is defined and properly defined."},"comment":{"url":"https://api.github.com/repos/chef/chef-provisioning/issues/comments/141352134","html_url":"https://github.com/chef/chef-provisioning/pull/404#issuecomment-141352134","issue_url":"https://api.github.com/repos/chef/chef-provisioning/issues/404","id":141352134,"user":{"login":"jtimberman","id":12483,"avatar_url":"https://avatars.githubusercontent.com/u/12483?v=3","gravatar_id":"","url":"https://api.github.com/users/jtimberman","html_url":"https://github.com/jtimberman","followers_url":"https://api.github.com/users/jtimberman/followers","following_url":"https://api.github.com/users/jtimberman/following{/other_user}","gists_url":"https://api.github.com/users/jtimberman/gists{/gist_id}","starred_url":"https://api.github.com/users/jtimberman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtimberman/subscriptions","organizations_url":"https://api.github.com/users/jtimberman/orgs","repos_url":"https://api.github.com/users/jtimberman/repos","events_url":"https://api.github.com/users/jtimberman/events{/privacy}","received_events_url":"https://api.github.com/users/jtimberman/received_events","type":"User","site_admin":false},"created_at":"2015-09-18T05:46:16Z","updated_at":"2015-09-18T05:46:16Z","body":"Rather than checking the version of Chef, why not ask `Chef::Node` if it knows about `policy_name` and `policy_group`?\r\n\r\n```ruby\r\nChef::Node.instance_methods.include?(:policy_name) && Chef::Node.instance_methods.include?(:policy_group)\r\n```"}}