{"action":"created","comment":{"url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/pulls/comments/31773059","id":31773059,"diff_hunk":"@@ -382,9 +425,57 @@ def hostname(server, interface_type = nil)\n       end\n \n       def create_ec2_json(state)\n-        instance.transport.connection(state).execute(\n-          \"sudo mkdir -p /etc/chef/ohai/hints;sudo touch /etc/chef/ohai/hints/ec2.json\"\n-        )\n+        if windows_os?\n+          cmd = \"mkdir c:\\\\chef\\\\ohai\\\\hints; echo $null >> c:\\\\chef\\\\ohai\\\\hints\\\\ec2.json\"\n+        else\n+          cmd = \"sudo mkdir -p /etc/chef/ohai/hints;sudo touch /etc/chef/ohai/hints/ec2.json\"\n+        end\n+        instance.transport.connection(state).execute(cmd)\n+      end\n+\n+      def default_windows_user_data\n+        #Preparing custom static admin user if we defined something other than Administrator\n+        customAdminScript = ''\n+        if !(instance.transport[:username] =~ /administrator/i) && instance.transport[:password]\n+          customAdminScript = Kitchen::Util.outdent!(<<-EOH)\n+          \"Disabling Complex Passwords\" >> $logfile\n+          $seccfg = [IO.Path]::GetTempFileName()\n+          & secedit.exe /export /cfg $seccfg >> $logfile\n+          (Get-Content $seccfg) | Foreach-Object {$_ -replace \"PasswordComplexity\\\\s*=\\\\s*1\", \"PasswordComplexity = 0\"} | Set-Content $seccfg\n+          & secedit.exe /configure /db $env:windir\\\\security\\\\new.sdb /cfg $seccfg /areas SECURITYPOLICY >> $logfile\n+          & cp $seccfg \"c:\\\\\"\n+          & del $seccfg\n+          $username=\"#{instance.transport[:username]}\"\n+          $password=\"#{instance.transport[:password]}\"\n+          \"Creating static user: $username\" >> $logfile\n+          & net.exe user /y /add $username $password >> $logfile","path":"lib/kitchen/driver/ec2.rb","position":139,"original_position":139,"commit_id":"ca4951756b5e37a0ac0c84e36f3e266d0c65427d","original_commit_id":"ca4951756b5e37a0ac0c84e36f3e266d0c65427d","user":{"login":"zl4bv","id":2031949,"avatar_url":"https://avatars.githubusercontent.com/u/2031949?v=3","gravatar_id":"","url":"https://api.github.com/users/zl4bv","html_url":"https://github.com/zl4bv","followers_url":"https://api.github.com/users/zl4bv/followers","following_url":"https://api.github.com/users/zl4bv/following{/other_user}","gists_url":"https://api.github.com/users/zl4bv/gists{/gist_id}","starred_url":"https://api.github.com/users/zl4bv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zl4bv/subscriptions","organizations_url":"https://api.github.com/users/zl4bv/orgs","repos_url":"https://api.github.com/users/zl4bv/repos","events_url":"https://api.github.com/users/zl4bv/events{/privacy}","received_events_url":"https://api.github.com/users/zl4bv/received_events","type":"User","site_admin":false},"body":"Will this silently fail if the user already exists? Thinking about baked AMIs, etc.","created_at":"2015-06-04T22:37:35Z","updated_at":"2015-06-04T22:37:35Z","html_url":"https://github.com/test-kitchen/kitchen-ec2/pull/150#discussion_r31773059","pull_request_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/pulls/150","_links":{"self":{"href":"https://api.github.com/repos/test-kitchen/kitchen-ec2/pulls/comments/31773059"},"html":{"href":"https://github.com/test-kitchen/kitchen-ec2/pull/150#discussion_r31773059"},"pull_request":{"href":"https://api.github.com/repos/test-kitchen/kitchen-ec2/pulls/150"}}},"pull_request":{"url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/pulls/150","id":36984442,"html_url":"https://github.com/test-kitchen/kitchen-ec2/pull/150","diff_url":"https://github.com/test-kitchen/kitchen-ec2/pull/150.diff","patch_url":"https://github.com/test-kitchen/kitchen-ec2/pull/150.patch","issue_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/issues/150","number":150,"state":"open","locked":false,"title":"Pulling together existing PRs for windows support","user":{"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},"body":"Checklist of items (copied from https://github.com/test-kitchen/kitchen-ec2/pull/133)\r\n\r\n- [x] WinRM not enabled by default on EC2 instances so have to manually enable it with user-data\r\n- [x] This issue - have to wait for WinRM to be enabled; WinRM transport currently too impatient\r\n- [x] Default username for WinRM transport doesn't work (issue test-kitchen/test-kitchen#688)\r\n- [x] Command to create EC2 JSON for Ohai doesn't work because the command is targeted at *NIX-based machines - which breaks the end of the kitchen 'create' phase\r\n- [x] WinRM enabled automatically by Kitchen-ec2 (could be salvaged from #96)\r\n- [x] EC2-generated Administrator password (#133)\r\n- [x] Windows AMIs in `amis.json`\r\n- [ ] Store generated admin password and pass it to RDP command when running `kitchen login`\r\n- [ ] Add test coverage for new methods and `create` method\r\n\r\nDepends on https://github.com/test-kitchen/test-kitchen/pull/736\r\nReplaces https://github.com/test-kitchen/kitchen-ec2/pull/96\r\nReplaces https://github.com/test-kitchen/kitchen-ec2/pull/133\r\nIncludes https://github.com/test-kitchen/kitchen-ec2/pull/134\r\n\r\n\\cc @fnichol @zl4bv","created_at":"2015-06-04T22:20:51Z","updated_at":"2015-06-04T22:37:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"df30d222a04eb8056556a0cac23d0207c4dcfceb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/pulls/150/commits","review_comments_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/pulls/150/comments","review_comment_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/issues/150/comments","statuses_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/statuses/ca4951756b5e37a0ac0c84e36f3e266d0c65427d","head":{"label":"test-kitchen:tball/windows","ref":"tball/windows","sha":"ca4951756b5e37a0ac0c84e36f3e266d0c65427d","user":{"login":"test-kitchen","id":5924439,"avatar_url":"https://avatars.githubusercontent.com/u/5924439?v=3","gravatar_id":"","url":"https://api.github.com/users/test-kitchen","html_url":"https://github.com/test-kitchen","followers_url":"https://api.github.com/users/test-kitchen/followers","following_url":"https://api.github.com/users/test-kitchen/following{/other_user}","gists_url":"https://api.github.com/users/test-kitchen/gists{/gist_id}","starred_url":"https://api.github.com/users/test-kitchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/test-kitchen/subscriptions","organizations_url":"https://api.github.com/users/test-kitchen/orgs","repos_url":"https://api.github.com/users/test-kitchen/repos","events_url":"https://api.github.com/users/test-kitchen/events{/privacy}","received_events_url":"https://api.github.com/users/test-kitchen/received_events","type":"Organization","site_admin":false},"repo":{"id":8042529,"name":"kitchen-ec2","full_name":"test-kitchen/kitchen-ec2","owner":{"login":"test-kitchen","id":5924439,"avatar_url":"https://avatars.githubusercontent.com/u/5924439?v=3","gravatar_id":"","url":"https://api.github.com/users/test-kitchen","html_url":"https://github.com/test-kitchen","followers_url":"https://api.github.com/users/test-kitchen/followers","following_url":"https://api.github.com/users/test-kitchen/following{/other_user}","gists_url":"https://api.github.com/users/test-kitchen/gists{/gist_id}","starred_url":"https://api.github.com/users/test-kitchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/test-kitchen/subscriptions","organizations_url":"https://api.github.com/users/test-kitchen/orgs","repos_url":"https://api.github.com/users/test-kitchen/repos","events_url":"https://api.github.com/users/test-kitchen/events{/privacy}","received_events_url":"https://api.github.com/users/test-kitchen/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/test-kitchen/kitchen-ec2","description":"A Test Kitchen Driver for Amazon EC2","fork":false,"url":"https://api.github.com/repos/test-kitchen/kitchen-ec2","forks_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/forks","keys_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/teams","hooks_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/hooks","issue_events_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/issues/events{/number}","events_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/events","assignees_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/assignees{/user}","branches_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/branches{/branch}","tags_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/tags","blobs_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/git/refs{/sha}","trees_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/statuses/{sha}","languages_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/languages","stargazers_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/stargazers","contributors_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/contributors","subscribers_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/subscribers","subscription_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/subscription","commits_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/commits{/sha}","git_commits_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/git/commits{/sha}","comments_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/comments{/number}","issue_comment_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/issues/comments{/number}","contents_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/contents/{+path}","compare_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/merges","archive_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/downloads","issues_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/issues{/number}","pulls_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/pulls{/number}","milestones_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/milestones{/number}","notifications_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/labels{/name}","releases_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/releases{/id}","created_at":"2013-02-06T01:52:02Z","updated_at":"2015-05-19T20:49:07Z","pushed_at":"2015-06-04T22:23:12Z","git_url":"git://github.com/test-kitchen/kitchen-ec2.git","ssh_url":"git@github.com:test-kitchen/kitchen-ec2.git","clone_url":"https://github.com/test-kitchen/kitchen-ec2.git","svn_url":"https://github.com/test-kitchen/kitchen-ec2","homepage":"","size":1826,"stargazers_count":69,"watchers_count":69,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":94,"mirror_url":null,"open_issues_count":24,"forks":94,"open_issues":24,"watchers":69,"default_branch":"master"}},"base":{"label":"test-kitchen:master","ref":"master","sha":"4206f9c03e8677a029f0277a96da947e7688ff17","user":{"login":"test-kitchen","id":5924439,"avatar_url":"https://avatars.githubusercontent.com/u/5924439?v=3","gravatar_id":"","url":"https://api.github.com/users/test-kitchen","html_url":"https://github.com/test-kitchen","followers_url":"https://api.github.com/users/test-kitchen/followers","following_url":"https://api.github.com/users/test-kitchen/following{/other_user}","gists_url":"https://api.github.com/users/test-kitchen/gists{/gist_id}","starred_url":"https://api.github.com/users/test-kitchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/test-kitchen/subscriptions","organizations_url":"https://api.github.com/users/test-kitchen/orgs","repos_url":"https://api.github.com/users/test-kitchen/repos","events_url":"https://api.github.com/users/test-kitchen/events{/privacy}","received_events_url":"https://api.github.com/users/test-kitchen/received_events","type":"Organization","site_admin":false},"repo":{"id":8042529,"name":"kitchen-ec2","full_name":"test-kitchen/kitchen-ec2","owner":{"login":"test-kitchen","id":5924439,"avatar_url":"https://avatars.githubusercontent.com/u/5924439?v=3","gravatar_id":"","url":"https://api.github.com/users/test-kitchen","html_url":"https://github.com/test-kitchen","followers_url":"https://api.github.com/users/test-kitchen/followers","following_url":"https://api.github.com/users/test-kitchen/following{/other_user}","gists_url":"https://api.github.com/users/test-kitchen/gists{/gist_id}","starred_url":"https://api.github.com/users/test-kitchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/test-kitchen/subscriptions","organizations_url":"https://api.github.com/users/test-kitchen/orgs","repos_url":"https://api.github.com/users/test-kitchen/repos","events_url":"https://api.github.com/users/test-kitchen/events{/privacy}","received_events_url":"https://api.github.com/users/test-kitchen/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/test-kitchen/kitchen-ec2","description":"A Test Kitchen Driver for Amazon EC2","fork":false,"url":"https://api.github.com/repos/test-kitchen/kitchen-ec2","forks_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/forks","keys_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/teams","hooks_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/hooks","issue_events_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/issues/events{/number}","events_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/events","assignees_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/assignees{/user}","branches_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/branches{/branch}","tags_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/tags","blobs_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/git/refs{/sha}","trees_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/statuses/{sha}","languages_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/languages","stargazers_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/stargazers","contributors_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/contributors","subscribers_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/subscribers","subscription_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/subscription","commits_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/commits{/sha}","git_commits_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/git/commits{/sha}","comments_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/comments{/number}","issue_comment_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/issues/comments{/number}","contents_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/contents/{+path}","compare_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/merges","archive_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/downloads","issues_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/issues{/number}","pulls_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/pulls{/number}","milestones_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/milestones{/number}","notifications_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/labels{/name}","releases_url":"https://api.github.com/repos/test-kitchen/kitchen-ec2/releases{/id}","created_at":"2013-02-06T01:52:02Z","updated_at":"2015-05-19T20:49:07Z","pushed_at":"2015-06-04T22:23:12Z","git_url":"git://github.com/test-kitchen/kitchen-ec2.git","ssh_url":"git@github.com:test-kitchen/kitchen-ec2.git","clone_url":"https://github.com/test-kitchen/kitchen-ec2.git","svn_url":"https://github.com/test-kitchen/kitchen-ec2","homepage":"","size":1826,"stargazers_count":69,"watchers_count":69,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":94,"mirror_url":null,"open_issues_count":24,"forks":94,"open_issues":24,"watchers":69,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/test-kitchen/kitchen-ec2/pulls/150"},"html":{"href":"https://github.com/test-kitchen/kitchen-ec2/pull/150"},"issue":{"href":"https://api.github.com/repos/test-kitchen/kitchen-ec2/issues/150"},"comments":{"href":"https://api.github.com/repos/test-kitchen/kitchen-ec2/issues/150/comments"},"review_comments":{"href":"https://api.github.com/repos/test-kitchen/kitchen-ec2/pulls/150/comments"},"review_comment":{"href":"https://api.github.com/repos/test-kitchen/kitchen-ec2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/test-kitchen/kitchen-ec2/pulls/150/commits"},"statuses":{"href":"https://api.github.com/repos/test-kitchen/kitchen-ec2/statuses/ca4951756b5e37a0ac0c84e36f3e266d0c65427d"}}}}