Controlling Google Cloud Platform with ansible
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.make
gce_vars
group_vars
inventory
Makefile
README.md
ansible_hosts
dns-records.retry
dns-records.yml
gce-instances-create.retry
gce-instances-create.yml
gce-instances-delete.yml
gce-instances-state.retry
gce-instances-state.yml
gce-network.yml
gce.ini
inventory.json
ips

README.md

Clickity click Twitter Follow Skype Contact

Getting started

Clone this repo and initialize submodules:

git clone https://github.com/mateothegreat/ansible-google-cloud && cd $_
git submodule update --init

Control Google Cloud Platform with ansible by Example

Requirements

pip install ansible
pip install pycrypto
pip install apache-libcloud

Google Compute Engine

Creating Instances

$ ansible-playbook gce-instances-create.yml -e instances=test-01,test-02

PLAY [Create instance(s)] ******************************************************************************************************TASK [Launch instances] ********************************************************************************************************changed: [127.0.0.1]
TASK [Wait for SSH to come up] *************************************************************************************************
ok: [127.0.0.1] => (item={u'status': u'RUNNING', u'network': u'default', u'zone': u'us-central1-a', u'tags': [u'test'], u'image': u'centos-7-v20180314', u'disks': [u'test-01'], u'name': u'test-01', u'public_ip': u'104.197.64.187', u'private_ip': u'10.128.0.7', u'machine_type': u'n1-standard-1', u'subnetwork': u'default', u'metadata': {}})
ok: [127.0.0.1] => (item={u'status': u'RUNNING', u'network': u'default', u'zone': u'us-central1-a', u'tags': [u'test'], u'image': u'centos-7-v20180314', u'disks': [u'test-02'], u'name': u'test-02', u'public_ip': u'35.188.121.115', u'private_ip': u'10.128.0.8', u'machine_type': u'n1-standard-1', u'subnetwork': u'default', u'metadata': {}})

TASK [Add host to groupname] ***************************************************************************************************
changed: [127.0.0.1] => (item={u'status': u'RUNNING', u'network': u'default', u'zone': u'us-central1-a', u'tags': [u'test'], u'image': u'centos-7-v20180314', u'disks': [u'test-01'], u'name': u'test-01', u'public_ip': u'104.197.64.187', u'private_ip': u'10.128.0.7', u'machine_type': u'n1-standard-1', u'subnetwork': u'default', u'metadata': {}})
changed: [127.0.0.1] => (item={u'status': u'RUNNING', u'network': u'default', u'zone': u'us-central1-a', u'tags': [u'test'], u'image': u'centos-7-v20180314', u'disks': [u'test-02'], u'name': u'test-02', u'public_ip': u'35.188.121.115', u'private_ip': u'10.128.0.8', u'machine_type': u'n1-standard-1', u'subnetwork': u'default', u'metadata': {}})

PLAY RECAP *********************************************************************************************************************
127.0.0.1                  : ok=3    changed=2    unreachable=0    failed=0

Deleting Instances

$ ansible-playbook gce-instances-delete.yml -e instances=test-01,test-02

PLAY [Delete instance(s)] *******************************************************************************************************
TASK [Destroy instances] ********************************************************************************************************changed: [127.0.0.1]

PLAY RECAP **********************************************************************************************************************127.0.0.1                  : ok=1    changed=1    unreachable=0    failed=0