shell provisiner for vmware-iso builder

292 views
Skip to first unread message

Sheshagiri Rao Mallipedhi

unread,
Oct 13, 2014, 8:07:32 AM10/13/14
to packe...@googlegroups.com
Hi Guys,

I'm having some problem with running the shell provisioner in vmware-iso builder, following is the error that i get

2014/10/13 16:34:51 packer-builder-vmware-iso: 2014/10/13 16:34:51 scp stderr (length 25): Sink: C0644 26 script.sh
2014/10/13 16:34:51 packer-builder-vmware-iso: 2014/10/13 16:34:51 opening new ssh session
2014/10/13 16:34:51 packer-builder-vmware-iso: 2014/10/13 16:34:51 starting remote command: chmod 0777 /tmp/script.sh
2014/10/13 16:34:51 packer-builder-vmware-iso: 2014/10/13 16:34:51 remote command exited with '0': chmod 0777 /tmp/script.sh
2014/10/13 16:34:51 packer-builder-vmware-iso: 2014/10/13 16:34:51 [INFO] RPC endpoint: Communicator ended with: 0
2014/10/13 16:34:51 [INFO] RPC client: Communicator ended with: 0
2014/10/13 16:34:51 [INFO] RPC endpoint: Communicator ended with: 0
2014/10/13 16:34:51 packer-command-build: 2014/10/13 16:34:51 [INFO] RPC client: Communicator ended with: 0
2014/10/13 16:34:51 packer-command-build: 2014/10/13 16:34:51 [INFO] RPC endpoint: Communicator ended with: 0
2014/10/13 16:34:51 [INFO] RPC client: Communicator ended with: 0
2014/10/13 16:34:51 [INFO] RPC endpoint: Communicator ended with: 0
2014/10/13 16:34:51 packer-provisioner-shell: 2014/10/13 16:34:51 [INFO] RPC client: Communicator ended with: 0
2014/10/13 16:34:51 packer-builder-vmware-iso: 2014/10/13 16:34:51 opening new ssh session
2014/10/13 16:34:51 packer-builder-vmware-iso: 2014/10/13 16:34:51 starting remote command: chmod +x /tmp/script.sh; PACKER_BUILD_NAME=vmware-iso PACKER_BUILDER_TYPE=vmware-iso /tmp/script.sh
    vmware-iso: bash: /tmp/script.sh: #!/bin/sh: bad interpreter: Permission denied
2014/10/13 16:34:51 ui:     vmware-iso: bash: /tmp/script.sh: #!/bin/sh: bad interpreter: Permission denied
2014/10/13 16:34:51 packer-builder-vmware-iso: 2014/10/13 16:34:51 remote command exited with '126': chmod +x /tmp/script.sh; PACKER_BUILD_NAME=vmware-iso PACKER_BUILDER_TYPE=vmware-iso /tmp/script.sh
2014/10/13 16:34:51 packer-builder-vmware-iso: 2014/10/13 16:34:51 [INFO] RPC endpoint: Communicator ended with: 126
2014/10/13 16:34:51 [INFO] 0 bytes written for 'stderr'
2014/10/13 16:34:51 [INFO] 69 bytes written for 'stdout'
2014/10/13 16:34:51 [INFO] RPC client: Communicator ended with: 126
2014/10/13 16:34:51 [INFO] RPC endpoint: Communicator ended with: 126
2014/10/13 16:34:51 packer-command-build: 2014/10/13 16:34:51 [INFO] 0 bytes written for 'stderr'
2014/10/13 16:34:51 packer-command-build: 2014/10/13 16:34:51 [INFO] 69 bytes written for 'stdout'
2014/10/13 16:34:51 packer-command-build: 2014/10/13 16:34:51 [INFO] RPC client: Communicator ended with: 126
2014/10/13 16:34:51 packer-command-build: 2014/10/13 16:34:51 [INFO] RPC endpoint: Communicator ended with: 126
2014/10/13 16:34:51 [INFO] RPC client: Communicator ended with: 126
2014/10/13 16:34:51 [INFO] 0 bytes written for 'stderr'


my provisioner is as following

 "provisioners": [
                {
                        "type": "file",
                        "source": "/root/test",
                        "destination": "/root",
                        "only": ["vmware-iso"]
                },
                {
                         "type": "shell",
                         "scripts": [
                         "/root/test/install.sh"
                          ]
                },
                {
                        "type": "shell",
                        "inline": ["sleep 1000"],
                        "only": ["vmware-iso"]
                }
                ]

I copy few files and then run a script that i already copied. Any suggestions would be great here on what is going wrong.

Thank You
-Sheshagiri

Alvaro Miranda Aguilera

unread,
Oct 13, 2014, 3:54:00 PM10/13/14
to packe...@googlegroups.com
Hello,

first I would suggest run a dos2unix and check for any extra character, in case are some weird windows character.

2nd, on the host mahcine, this file exist? /root/test/install.sh since my understanding is packer will copy /root/test/install.sh as /tmp/script.sh and run this /tmp/script.sh

3rd , from this error:
#!/bin/sh: bad interpreter: Permission denied

What os is the vm? /bin/sh is there?


--
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.
For more options, visit https://groups.google.com/d/optout.

Sheshagiri Rao Mallipedhi

unread,
Oct 13, 2014, 5:23:11 PM10/13/14
to packe...@googlegroups.com
Hello,

Yes the file(/root/test/install.sh) is available and its a rhel-5.7 vm. I got rid in the error after add the following line in my template.

     {
                        "execute_command": "echo 'Hello' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
                        "type": "shell",
                         "scripts": [
                         "/root/ipfm/install.sh"
                          ]
                },
Documentation on packer.io says "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}" is present by default. Might be a typo in the documentation.

-Sheshagiri
Reply all
Reply to author
Forward
0 new messages