And to use a non default source image you should set https://packer.io/docs/builders/googlecompute.html#source_image_project_id
On Wed, Aug 21, 2019, 22:39 Rickard von Essen <[email protected]> wrote: > First you have to create an image from the disk in gcs with gcloud, see > https://cloud.google.com/sdk/gcloud/reference/compute/images/create > > Use the --source-uri argument. > > On Wed, Aug 21, 2019, 21:58 Wes Quinn <[email protected]> wrote: > >> Hello, >> >> I am working with packerpy and GCP to be able to load an OVA file to a >> personal bucket and then modify that image and create a new image from >> that, using the provisioners feature in a JSON file. >> >> I have the process to upload to a personal bucket working, but I can't >> figure out how to get packer to find my image in my personal bucket. >> Packer keeps searching the public area. I didn't see where I can use a >> bucket. >> >> Anyone have any idea on how to get packet to modify the image from the >> personal bucket? >> >> On a separate note, I am able to use packer, in this same manner with >> AWS, just fine. >> >> Here is an example of my JSON for GCP: >> >> { >> "variables": { >> "disk_size": 150, >> "project_id": "proj-id", >> "result_image": "packer-example-{{timestamp}}", >> "source_image": "rhel-7-5-x86-64-minimal-ova", >> "ssh_password": "password", >> "ssh_timeout": "3m", >> "ssh_username": "user", >> "zone": "us-east-1" >> }, >> "builders": [ >> { >> "disk_size": "{{user `disk_size`}}", >> "image_name": "{{user `result_image`}}", >> "project_id": "{{user `project_id`}}", >> "source_image": "{{user `source_image`}}", >> "ssh_password": "{{user `ssh_password`}}", >> "ssh_username": "{{user `ssh_username`}}", >> "type": "googlecompute", >> "zone": "{{user `zone`}}" >> } >> ], >> "provisioners": [ >> { >> "type": "file", >> "source": "./welcome.sh", >> "destination": "/root/", >> "direction": "upload" >> }, >> { >> "type": "shell", >> "inline": [ >> "chmod +x welcome.sh", >> "./welcome.sh" >> ] >> } >> ] >> } >> >> Here is the Python code that uses the above JSON code: >> import argparse >> import json >> from packerpy import PackerExecutable >> parser = argparse.ArgumentParser(description='This script modifies a GCP >> image in GCP.') >> parser.add_argument('-f', '--json_file', required=True, help='The JSON >> file that contains the changes to make to the image file.') >> args = parser.parse_args() >> json_file = args.json_file >> packer_bin = '/usr/local/bin/packer' >> p = PackerExecutable(packer_bin) >> (results, output, error) = p.build(json_file) >> if results == 0: >> print('Success!') >> else: >> print('Error:', error) >> print('\nOutput:', output) >> >> If you have any questions, please ask. >> >> Thank you very much! >> Wes Quinn >> >> -- >> 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 [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/packer-tool/5b866b6d-1ee3-4632-8df9-1c585d710e77%40googlegroups.com >> <https://groups.google.com/d/msgid/packer-tool/5b866b6d-1ee3-4632-8df9-1c585d710e77%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CALz9Rt9b6JyMDc8ykerdz%2BtNcJUShmhM8U5bN%2BUMG1BprNLKDw%40mail.gmail.com.
