{"action":"created","issue":{"url":"https://api.github.com/repos/mitchellh/packer/issues/4245","repository_url":"https://api.github.com/repos/mitchellh/packer","labels_url":"https://api.github.com/repos/mitchellh/packer/issues/4245/labels{/name}","comments_url":"https://api.github.com/repos/mitchellh/packer/issues/4245/comments","events_url":"https://api.github.com/repos/mitchellh/packer/issues/4245/events","html_url":"https://github.com/mitchellh/packer/issues/4245","id":193272233,"number":4245,"title":"Provisioning on CoreOS with sudo access with Azure Builder","user":{"login":"luhkevin","id":342515,"avatar_url":"https://avatars.githubusercontent.com/u/342515?v=3","gravatar_id":"","url":"https://api.github.com/users/luhkevin","html_url":"https://github.com/luhkevin","followers_url":"https://api.github.com/users/luhkevin/followers","following_url":"https://api.github.com/users/luhkevin/following{/other_user}","gists_url":"https://api.github.com/users/luhkevin/gists{/gist_id}","starred_url":"https://api.github.com/users/luhkevin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luhkevin/subscriptions","organizations_url":"https://api.github.com/users/luhkevin/orgs","repos_url":"https://api.github.com/users/luhkevin/repos","events_url":"https://api.github.com/users/luhkevin/events{/privacy}","received_events_url":"https://api.github.com/users/luhkevin/received_events","type":"User","site_admin":false},"labels":[{"id":348325176,"url":"https://api.github.com/repos/mitchellh/packer/labels/builder/azure","name":"builder/azure","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":{"login":"boumenot","id":91112,"avatar_url":"https://avatars.githubusercontent.com/u/91112?v=3","gravatar_id":"","url":"https://api.github.com/users/boumenot","html_url":"https://github.com/boumenot","followers_url":"https://api.github.com/users/boumenot/followers","following_url":"https://api.github.com/users/boumenot/following{/other_user}","gists_url":"https://api.github.com/users/boumenot/gists{/gist_id}","starred_url":"https://api.github.com/users/boumenot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boumenot/subscriptions","organizations_url":"https://api.github.com/users/boumenot/orgs","repos_url":"https://api.github.com/users/boumenot/repos","events_url":"https://api.github.com/users/boumenot/events{/privacy}","received_events_url":"https://api.github.com/users/boumenot/received_events","type":"User","site_admin":false},"assignees":[{"login":"boumenot","id":91112,"avatar_url":"https://avatars.githubusercontent.com/u/91112?v=3","gravatar_id":"","url":"https://api.github.com/users/boumenot","html_url":"https://github.com/boumenot","followers_url":"https://api.github.com/users/boumenot/followers","following_url":"https://api.github.com/users/boumenot/following{/other_user}","gists_url":"https://api.github.com/users/boumenot/gists{/gist_id}","starred_url":"https://api.github.com/users/boumenot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boumenot/subscriptions","organizations_url":"https://api.github.com/users/boumenot/orgs","repos_url":"https://api.github.com/users/boumenot/repos","events_url":"https://api.github.com/users/boumenot/events{/privacy}","received_events_url":"https://api.github.com/users/boumenot/received_events","type":"User","site_admin":false}],"milestone":null,"comments":5,"created_at":"2016-12-03T07:27:25Z","updated_at":"2016-12-05T21:29:44Z","closed_at":null,"body":"packer version: 0.10.1\r\nHost platform: Ubuntu 16.04\r\nDebug log output: https://gist.github.com/luhkevin/2db9d6940160d3ac91f199fe031918d3\r\nExample template and scripts:\r\n```\r\n{\r\n  \"builders\": [\r\n    {\r\n      \"type\": \"azure-arm\",\r\n      \"tenant_id\": \"[REMOVED]\",\r\n      \"subscription_id\": \"[REMOVED\",\r\n      \"client_id\": \"[REMOVED]\",\r\n      \"client_secret\": \"[REMOVED]\",\r\n      \"resource_group_name\": \"netsil-builder\",\r\n      \"storage_account\": \"netsilimages\",\r\n      \"capture_container_name\": \"myimages\",\r\n      \"capture_name_prefix\": \"NETSIL\",\r\n      \"image_publisher\": \"CoreOS\",\r\n      \"image_offer\": \"CoreOS\",\r\n      \"image_sku\": \"Stable\",\r\n      \"location\": \"westus2\",\r\n      \"os_type\": \"Linux\",\r\n      \"ssh_username\": \"core\"\r\n    }\r\n  ],\r\n  \"provisioners\": [\r\n    {\r\n      \"inline\":[\"whoami\"],\r\n      \"type\": \"shell\"\r\n    },\r\n    {\r\n      \"inline\":[\"cat /etc/*release\"],\r\n      \"type\": \"shell\"\r\n    },\r\n    {\r\n      \"inline\":[\"env\"],\r\n      \"type\": \"shell\"\r\n    },\r\n    {\r\n      \"execute_command\": \"chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'\",\r\n      \"inline\":[\"/usr/share/oem/python/bin/python -u /usr/share/oem/bin/waagent -force -deprovision+user && export HISTSIZE=0 && sync\"],\r\n      \"inline_shebang\": \"/bin/sh -x\",\r\n      \"type\": \"shell\"\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\nI'm trying out the packer azure builder with CoreOS, but the provisioner isn't working regarding sudo access. The details are in the log output, but essentially I'm seeing the message:\r\n\r\n```\r\n2016/12/03 07:01:07 ui:     azure-arm:\r\n2016/12/03 07:01:07 packer: 2016/12/03 07:01:07 [INFO] 0 bytes written for 'stdout'\r\n2016/12/03 07:01:07 packer: 2016/12/03 07:01:07 [INFO] 307 bytes written for 'stderr'\r\n2016/12/03 07:01:07 packer: 2016/12/03 07:01:07 [INFO] RPC client: Communicator ended with: 1\r\n2016/12/03 07:01:07 ui:     azure-arm: We trust you have received the usual lecture from the local System\r\n2016/12/03 07:01:07 ui:     azure-arm: Administrator. It usually boils down to these three things:\r\n2016/12/03 07:01:07 ui:     azure-arm:\r\n2016/12/03 07:01:07 ui:     azure-arm: #1) Respect the privacy of others.\r\n2016/12/03 07:01:07 ui:     azure-arm: #2) Think before you type.\r\n2016/12/03 07:01:07 ui:     azure-arm: #3) With great power comes great responsibility.\r\n2016/12/03 07:01:07 ui:     azure-arm:\r\n2016/12/03 07:01:07 ui:     azure-arm: sudo: no tty present and no askpass program specified\r\n```\r\n\r\nAfter some googling, I've found that I should set `\"ssh_pty\": true`, but this doesn't do anything. It still prints the same thing and just waits for me to type in the password.\r\n\r\nIt's really strange because I created the same image on Azure manually and was able to do things like `sudo bash` with the core user without any password prompting, and without that output above.\r\n\r\nFor reference, the sudoers file on that image is:\r\n```\r\n## Default sudoers for CoreOS\r\n\r\n## Pass LESSCHARSET through for systemd commands run through sudo that call less.\r\n## See https://github.com/coreos/bugs/issues/365.\r\nDefaults env_keep += \"LESSCHARSET\"\r\n\r\n## enable root and wheel\r\nroot ALL=(ALL) ALL\r\n%wheel ALL=(ALL) ALL\r\n\r\n## enable passwordless access for sudo\r\n%sudo ALL=(ALL) NOPASSWD: ALL\r\n\r\n## the core user has no password by default\r\ncore ALL=(ALL) NOPASSWD: ALL\r\n\r\n## Read drop-in files from /etc/sudoers.d\r\n## (the '#' here does not indicate a comment)\r\n#includedir /etc/sudoers.d\r\n```\r\n\r\nSo the `core` user definitely has sudo access. The `whoami` command that I've run confirms that I'm the `core` user.\r\n\r\nI've tried the example [here](https://github.com/mitchellh/packer/blob/master/examples/azure/ubuntu_quickstart.json) and it was working just fine. \r\n\r\nMaybe this is just a CoreOS/Azure issue?\r\n"},"comment":{"url":"https://api.github.com/repos/mitchellh/packer/issues/comments/264983071","html_url":"https://github.com/mitchellh/packer/issues/4245#issuecomment-264983071","issue_url":"https://api.github.com/repos/mitchellh/packer/issues/4245","id":264983071,"user":{"login":"luhkevin","id":342515,"avatar_url":"https://avatars.githubusercontent.com/u/342515?v=3","gravatar_id":"","url":"https://api.github.com/users/luhkevin","html_url":"https://github.com/luhkevin","followers_url":"https://api.github.com/users/luhkevin/followers","following_url":"https://api.github.com/users/luhkevin/following{/other_user}","gists_url":"https://api.github.com/users/luhkevin/gists{/gist_id}","starred_url":"https://api.github.com/users/luhkevin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luhkevin/subscriptions","organizations_url":"https://api.github.com/users/luhkevin/orgs","repos_url":"https://api.github.com/users/luhkevin/repos","events_url":"https://api.github.com/users/luhkevin/events{/privacy}","received_events_url":"https://api.github.com/users/luhkevin/received_events","type":"User","site_admin":false},"created_at":"2016-12-05T21:29:44Z","updated_at":"2016-12-05T21:29:44Z","body":"Actually, it looks like using a dummy password worked, so thanks for the help on that!\r\nUnfortunately, I was also trying to use an ansible provisioner which requires SSH access in a similar way, and that is still bothering me about a password. It's returning in stdout:\r\n\r\n```\r\nsudo: a password is required\r\n```\r\n\r\nI'll try the same approach for ansible -- pass it a dummy password -- and let you know my results."}}
{"actor":{"display_login":"luhkevin"}}