Basic, no frills, single file playbooks to provision, run tasks and terminate a vm.
Ansible control machine is running Mac OS 10.15.1
ansible --version = 2.9.0
- Necessary libraries have been installed on Ansible control machine. Link
- GCP Service Account credentials have been created and downloaded. See Ansible GCP Guide. Link
- GCP SSH Keypair has been created locally and the public key has been uploaded to the GCP | Computer Engine | Metadata | SSH Keys. Note that this will give project wide access to ssh to linux computer instances and may be undesired. In this case i'm using 'gce-user' and have an associated ssh keypair. (Keypair name is referenced in the playbook). Link
- Default network is being used which already has the pre-populated firewall rules setup for remote access via ssh.
Playbook run-time : ~ 5 mins
This playbook will:
- Launch an google compute engine rhel instance
- Connect via ssh to the external IP of the new instance
- Gather facts on the instance
- Reboot the instance
- Terminate the instance
<gcp_project>
value = path to the GCP Service account<gcp_cred_file>
value = path to the GCP Service account credentials file. e.g ~/gcp_creds/cred_file.json<ansible_ssh_private_key_file>
value = path to private key file. e.g ~/.ssh/my_key
ansible-playbook launch_gcp_compute_rhel.yml --extra-vars '{"gcp_project":"value","gcp_cred_file":"value","ansible_ssh_private_key_file":"value" }'
Coming soon....