For some reason, Packer couldn't identify the user from the environment.
This may already be solved if you use a newer version of Packer, but
otherwise the solution is to add "user": "<username>" to the ansible
provisioner, where <username> is the ansible_user you want to use. We don't
recommend running packer as root.

Thanks,
--Matt Hooker

On Wed, Apr 4, 2018 at 3:09 PM test <kswathi.k...@gmail.com> wrote:

> hi , i am trying to a gitlab-ci build using docker container
>
>  ubuntu:latest
>
> i have installed packer and when i try to execute packer build command i
> am getting an error. please help me solve this error.
>
> My image.json file
>
> {
>   "variables": {
>   },
>   "builders": [{
>     "type": "amazon-ebs",
>     "instance_type": "t2.large",
>     "region": "us-east-1",
>     "source_ami": "ami-d15a75c7",
>     "security_group_id": "xxxxx",
>     "subnet_id": "xxxxxxxxx",
>     "ami_name": "gitlab-runner-as_ubuntu_docker_{{timestamp}}",
>     "ssh_username": "ubuntu",
>     "ssh_pty": true,
>     "ssh_private_ip": true,
>     "associate_public_ip_address": false,
>     "shutdown_behavior": "stop",
>     "ena_support": true
>   }],
>   "provisioners": [
>     {
>       "type": "shell",
>       "inline": [
>         "sudo apt-get -y update",
>         "sudo apt-get install -y python-simplejson",
>         "sudo apt-get install -y python-requests",
>         "sudo apt-get install -y python-requests",
>         "sudo apt-get install python-pip -y"
>         ]
>      },
>      {
>       "type": "ansible",
>       "playbook_file":
> "/builds/infra/packer-role-gitlab-runner-autoscaling/playbook.yml",
>       "ansible_env_vars": [
>         "ANSIBLE_HOST_KEY_CHECKING=False",
>         "ANSIBLE_REMOTE_TMP=/tmp/ansible",
>         "ANSIBLE_ASK_SUDO_PASS=False",
>         "ANSIBLE_REMOTE_USER=ubuntu",
>         "ANSIBLE_USER_PYTHON=/usr/bin/python3",
>         "PYTHONPATH=/usr/local/bin/python2.7/site-packages",
>         "REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt"
>       ]
>     },
>      {
>       "type": "shell",
>       "script":
> "/builds/infra/packer-role-gitlab-runner-autoscaling/script.sh"
>      }
>   ]
> }
>
>
>
> $ packer -version
> 1.1.2
> $ whoami
> root
> $ packer_log=1 packer build image.json
> amazon-ebs output will be in this color.
>
> 1 error(s) occurred:
>
> * user: could not determine current user from environment.
> ERROR: Job failed: exit code 1
>
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in
> violation of those guidelines may result in your removal from this mailing
> list.
>
> GitHub Issues: https://github.com/mitchellh/packer/issues
> IRC: #packer-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to packer-tool+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/c8a99ded-231d-4ba6-8170-f7e7e3f19764%40googlegroups.com
> <https://groups.google.com/d/msgid/packer-tool/c8a99ded-231d-4ba6-8170-f7e7e3f19764%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to packer-tool+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/CAEpfdnx7xmqpnnCJ89A6xUzodkFdbCG5v_LZZT8UeUU0mziJeg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to