This example uses the packer ansible provisioner to create a GCP compute image.
[1] Create docker container
docker build -t centos7-ansible .
[2] Export environment variables, using a relative path for GOOGLE_APPLICATION_CREDENTIALS
export GOOGLE_APPLICATION_CREDENTIALS=./keys/service_account.json
export GCP_PROJECT=PROJECT_ID
[1] Test playbook inside docker container
./docker-test.sh
[1] Start docker ansible control node
./docker-run.sh
[2] Create packer image
packer build centos.json