Skip to content

Containerized Ansible for use with (and within) Google Compute Engine

License

Notifications You must be signed in to change notification settings

chad-autry/wac-gce-ansible

Repository files navigation

wac-gce-ansible

Containerized Ansible for use with Google Compute Engine

  • Uses gcp_compute inventory plugin for dynamic inventory (requires service account)
  • Uses same service account with installed gcloud to automagically connect to instances
  • Uses instance labels to create Ansible groups

Status

Build Status Docker Hub

Setup

Example

  • Use one of the default directory layouts for playbooks and files.
  • Mount the top directory as /var/ansible. It is used as the working directory of the container.
  • Mount the directory which contains the service account file
  • Pass in the GCE project id as an environment variable
    • Note: The ID might not be the name, it might be the name with some additional digits appended
docker run -it --rm -v <playbook_directory>:/var/ansible -v /<service_account_directory>:/srcs -e GCP_SERVICE_ACCOUNT_FILE='/srcs/<service_account_json_credentials_name>' -e GCP_PROJECT='<project>' chadautry/wac-gce-ansible ansible-playbook /var/ansible/site.yml

Lookout for

Occasionally you may encounter an error 'Login profile size exceeds 32 KiB. Delete profile values to make additional space.' It just means too many ssh keys have built up for your service account.

gcloud auth activate-service-account --key-file=<yourKeyFile>
for i in $(gcloud compute os-login ssh-keys list | grep -v FINGERPRINT); do echo $i; gcloud compute os-login ssh-keys remove --key $i; done

About

Containerized Ansible for use with (and within) Google Compute Engine

Resources

License

Stars

Watchers

Forks

Packages

No packages published