alexmzirai / ansible_gcloud

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automate Instance and Apache Server on GCP using Ansible

Description

The goal of this repository is to create a instance on GCP and deploy apache server on that instance using ansible playbook.

Prerequisites

  1. Create Project on Google Cloud Platform.
  2. Create a Serviceaccount with editor access. (Refer Creating-service-account)

Getting Started !!

  1. Install python version > 3.0
$ sudo yum install python3-pip
  1. The GCP modules require both the requests and the google-auth libraries to be installed.
$ sudo pip3 install requests google-auth
  1. Install Ansible
$ sudo pip3 install ansible 
  1. Download .JSON credentials file of created service account.
  2. Edit instance_name in vars/main.yml, by default it is centos-7.
  3. Edit machine_type in vars/main.yml, by default it is e2-micro.
  4. Edit zone in vars/main.yml, by default it is us-central1-a.
  5. Edit source_image in vars/main.yml, by default it is CENTOS-7.
  6. Give project id, .JSON file_path in vars/main.yml file.
  7. Run the Playbook
$ ansible-playbook gce.yml
  1. Your Google Compute Engine Instance is now created, with Apache Server installed in it.
  2. Browse to instance public ip address.

About