packer ansible centos [Errno 13] Permission denied

530 views
Skip to first unread message

Rajinder Singh

unread,
Dec 2, 2017, 8:32:05 PM12/2/17
to Packer
I am baking an image in Azure using packer.
Base image is Centos 7.4

If I run packer from MacOS image bakes successfully.
If I try to bake the exact same image from Ubuntu it is failing. Our build server bamboo is running on Ubuntu 16.04

Here is the error

msg": "The destination directory (/etc) is not writable by the current user. Error was: [Errno 13] Permission denied: '/etc/.ansible_tmpnMneufhost.conf'" [0m

It is failing while running ansible playbook. It is trying to write in /etc directory and does not have permissions.

I did set
"ssh_pty": true,


Here is how I am invoking ansible playbook
{
"type": "ansible",
"playbook_file": "./server-hardening.yml",
"extra_arguments": [ "-vvvv" ]
},

I have tried updating the ansible playbook like this:

- hosts: all
become: true
become_method: sudo
become_user: root

But I still get the same error.


We are also baking a Ubuntu 16.04 using similar playbook and it is working.

To summarize I can bake Centos 7.4 by running packer build from Mac OS but the same configuration fails to build when packer is run from Ubuntu 16.04 build server.

Let me know if anybody has any suggestions.

Thanks






Rickard von Essen

unread,
Dec 3, 2017, 12:35:40 AM12/3/17
to packe...@googlegroups.com
Can you share your playbook or something that reproduces the problem? 

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/989e001b-f028-4d58-be1b-c1a11c69a2a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alvaro Miranda Aguilera

unread,
Dec 3, 2017, 6:43:40 AM12/3/17
to packe...@googlegroups.com
hello

just to be sure, both computer are running on the same packer version?

what user are you using to connect?

won't be possible that due being different computers you are connecting to different regions, etc that end using different source ubuntu box?

Alvaro.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/989e001b-f028-4d58-be1b-c1a11c69a2a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Rajinder Singh

unread,
Dec 3, 2017, 8:59:38 AM12/3/17
to Packer
My MacBook Pro where I can bake images successfully is running 

packer version 1.1.1
ansible version 2.4.1.0

Our build server which is ubuntu 16.04 VM running in Azure is running
packer version 1.1.2
ansible version 2.4.1.0

I did downgrade the version of packer on ubuntu to 1.1.1 and got the same result.

Since I am using the same packer config image is being baked in "East US" 
I am setting ssh_username to 'packer'

I have included my packer config

Only difference between successful image baking and failure is running packer on Ubuntu 16.04 vs Mac OS High Sierra. Mac OS High Sierra running same version of packer/ansible/same packer config, same ansible playbook works. It fails on Ubuntu.
The image I am baking is Centos 7.4

I can share the ansible playbook privately if I can get an email address.

Here is the packer config


{
  "variables": {
    "azureserviceprincipalusername": "",
    "azureserviceprincipalpassword": "",
    "azuretenantid": "",
    "azuresubscriptionid": "",
    "buildservercontact": "m...@email.com",
    "imageresourcegroup": "imagerg",
    "imagename": "",
    "location": "East US",
    "imagestoragetype": "Standard_LRS",
    "os_type": "",
    "image_publisher": "",
    "image_offer": "",
    "image_sku": ""
   },

  "builders": [{
    "type": "azure-arm",
    "ssh_pty": true,

    "client_id": "{{user `azureserviceprincipalusername`}}",
    "client_secret": "{{user `azureserviceprincipalpassword`}}",
    "tenant_id": "{{user `azuretenantid`}}",
    "subscription_id": "{{user `azuresubscriptionid`}}",

    "managed_image_resource_group_name": "{{user `imageresourcegroup`}}",
    "managed_image_name": "{{user `imagename`}}",
    "managed_image_storage_account_type": "{{user `imagestoragetype`}}",

    "os_type": "{{user `os_type`}}",
    "image_publisher": "{{user `image_publisher`}}",
    "image_offer": "{{user `image_offer`}}",
    "image_sku": "{{user `image_sku`}}",
    "ssh_username": "packer",

    "azure_tags": {        
        "task": "Image deployment",
        "contact": "{{user `buildservercontact`}}"
    },

    "location": "{{user `location`}}",
    "vm_size": "Standard_DS2_v2"
  }],
  "provisioners": [
    {
      "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
      "scripts":  [ "scripts/installclamav.sh" ],
      "type": "shell"
    },
    {
      "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
      "scripts":  [ "scripts/installdocker.sh" ],
      "type": "shell"
    },
    {
      "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
      "scripts":  [ "scripts/installsplunk.sh" ],
      "type": "shell"
    },           
    {
      "type": "ansible",
      "playbook_file": "./server-hardening.yml",
      "extra_arguments": [ "-vvvv" ]
    },   
    {
      "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
      "scripts":  [ "scripts/deprovision.sh" ],
      "skip_clean": true,
      "type": "shell"
    }
  ]
}


To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages