Unable to install the Google Cloud Logging Agent when using Packer

39 views
Skip to first unread message

Alexander Christie

unread,
Mar 11, 2020, 12:07:07 PM3/11/20
to Packer
Hi all!

I've hit an issue which I can't explain regarding inconsistent behaviour of the "https://dl.google.com/cloudagents/install-logging-agent.sh" when run via terminal and via packer.

Running via terminal produces the expected result of installing the agent whilst running via packer causes the following failure:
==> googlecompute: Failed to download metadata for repo 'google-cloud-logging'
==> googlecompute: Error: Failed to download metadata for repo 'google-cloud-logging'

Now I understand that this looks a lot like the "I'm using /sh instead of /bash" from the https://packer.io/docs/provisioners/shell.html#troubleshooting section of the documentation. However this is not the case as I explicitly run the script with bash and have verified that it is being run with bash through packer in a couple of different ways.

I've included a replication case below that can easily be spun up by anyone with a Google Cloud Project. Hopefully someone here can see what is going wrong?

Thanks!


{
 
"variables": {},
 
"builders": [{
 
"type": "googlecompute",
 
"ssh_username": "provisioning",
 
"source_image_family": "centos-8",
 
"zone": "europe-west1-b",
 
"disable_default_service_account": true,
 
"image_name": "centos-8-base-{{isotime \"2006-01-02\"}}"
 
}],
 
"provisioners": [
 
{
 
"type": "shell",
 
"inline": [
 
"sudo yum upgrade -y"
 
]
 
},
 
{
 
"type": "shell",
 
"inline": [
 
"curl -sL https://dl.google.com/cloudagents/install-logging-agent.sh | sudo bash -"
 
]
 
}
 
]
}


Rickard von Essen

unread,
Mar 11, 2020, 2:59:39 PM3/11/20
to packe...@googlegroups.com
Instead of curling down the script, download it and use the file privisioner to get it into the image and run that. Also add set -x on the top of it and you will probably find the issue. 

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/5a382fa4-078e-4685-bf24-a71482f1cc53%40googlegroups.com.

Alexander Christie

unread,
Mar 11, 2020, 3:28:15 PM3/11/20
to Packer
Hi Rickard,

I actually tried that earlier today and was unable to find any additional logs to help me understand what was going on.

I also tried changing the execute command in a few different configurations but was ultimately unable to get any additional details.

Thanks,
Alex
To unsubscribe from this group and stop receiving emails from it, send an email to packe...@googlegroups.com.

Rickard von Essen

unread,
Mar 11, 2020, 5:02:01 PM3/11/20
to packe...@googlegroups.com
Try installing python2 before running the script. 

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/e941f51b-3c5e-4c5a-bd57-689bb14d152f%40googlegroups.com.

Alexander Christie

unread,
Mar 12, 2020, 8:01:34 AM3/12/20
to Packer
For future readers who might find this post the issue is that the Google Cloud Logging and Monitoring Agent scripts require a PTY terminal for reasons I have been unable to asertain.

To fix this issue simply add
"ssh_pty": true

It seems that the interactive nature of the SSH connection unblocks some kind of HTTPS error inside of Yum.

If anyone from Packer or Google would like to explore this further it would be highly interesting to know the details!

Thanks,
Alex
Reply all
Reply to author
Forward
0 new messages