Failed to change ownership of the temporary files Ansible needs to create despite connecting as a privileged user

3,875 views
Skip to first unread message

ajith u

unread,
Jun 13, 2020, 12:13:06 PM6/13/20
to packe...@googlegroups.com
Hi,
I am using packer to create an image which has a playbook which is being executed as a non-root user. While running the packer build command I get below error in the ansible playbook secion.

   docker: TASK [Gathering Facts] *********************************************************
    docker: fatal: [default]: FAILED! => {"msg": "Failed to change ownership of the temporary files Ansible needs to create despite connecting as a privileged user. Unprivileged become user would be unable to read the file."}


I did some googling and added below option in the json file.
..
..
{
      "type": "ansible",
      "user": "root",
      "playbook_file": "../../../ansible/playbooks/build/build.yml",
      "extra_arguments": [
        "--extra-vars",
        "ansible_host={{user `ansible_host`}} ansible_connection={{user `ansible_connection`}} allow_world_readable_tmpfiles=true"
      ]
    }
..
..

Please let me know if any other places I can give this option.

thanks,
Ajith

Tarun Mittal

unread,
Jun 13, 2020, 12:35:31 PM6/13/20
to packe...@googlegroups.com
Try to run ansible-playbook as become_user using root

--
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/hashicorp/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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CAHGGiCRm01TyDZZEudn3ceje%3D%3DTPy9N_OUmboUfmw21Fge8dnQ%40mail.gmail.com.

Note: This message is the property of HashedIn and its subsidiaries. It may be legally privileged and/or confidential and is intended only for the use of the addressee(s). No addressee should forward, print, copy, or otherwise reproduce this message in any manner that would allow it to be viewed by any individual not originally listed as a recipient. If the reader of this message is not the intended recipient, you are hereby notified that any unauthorized disclosure, dissemination, distribution, copying or the taking of any action in reliance on the information herein is strictly prohibited. If you have received this communication in error, please immediately notify the sender and delete this message.

ajith u

unread,
Jun 13, 2020, 12:39:41 PM6/13/20
to packe...@googlegroups.com
that works , but due to other restrictions, need to run that playbook as non-root user.



--

Tarun Mittal

unread,
Jun 13, 2020, 12:42:23 PM6/13/20
to packe...@googlegroups.com
Check permission of the files and try to run that command directly without using ansible.

ajith u

unread,
Jun 13, 2020, 12:44:07 PM6/13/20
to packe...@googlegroups.com
that works..but i need to create image using packer and ansible. Running playbook locally without packer works.

Tarun Mittal

unread,
Jun 13, 2020, 1:02:26 PM6/13/20
to packe...@googlegroups.com
Did you try using type as shell in packer file 

ajith u

unread,
Jun 13, 2020, 1:11:32 PM6/13/20
to packe...@googlegroups.com

Tarun Mittal

unread,
Jun 13, 2020, 7:50:33 PM6/13/20
to packe...@googlegroups.com
Can you share the ansible playbook and packer.json file

ajith u

unread,
Jun 23, 2020, 9:46:28 AM6/23/20
to packe...@googlegroups.com
The issue got fixed.All I have to do is to set the USER env variable.

Reply all
Reply to author
Forward
0 new messages