tansudasli.gcp_instances

Role Name

=========

Set up compute instance(s) on GCP with production-level standards.

  • instance(s)
  • dedicated boot-disk
  • dedicated data and log disk
  • a static IP

Requirements


  • ansible client
  • ansible.cfg file
  • a service account and GCP account

Role Variables


This role is designed for standalone provisioning by default. For distributed provisioning, you can add more nodes with a proper naming format in your YAML file.

In defaults/main.yml, you can specify:

# GCP project
general:
    project: sandbox-236618       # GCP project ID 
    region: europe-west4          # GCP region
    auth_kind: serviceaccount     
    service_account_file: ~/.ssh/ansible.json
scopes:
    - https://www.googleapis.com/auth/compute

# design your infrastructure architecture
nodes:
  - name: standalone-node    # Example node names: standalone-node, name-node, data-node1, etc.
    zone: europe-west4-a     # Choose nearby zones and distribute other nodes accordingly
    machine_type: f1-micro   # Upgrade if necessary
    ips:
        - nic: 
            name: "ip-01"
    tags: hadoop             # Tags used by firewall rules (use tool names like hadoop or elasticsearch)
    labels:                  # Filtering! Use tool names as type and master/worker for identification
        type: hdfs
        name: master
    boot_disk:
        - disk:
            name: "boot-disk-01"
            size: 100
            image: "projects/ubuntu-os-cloud/global/images/family/ubuntu-2004-lts"
            auto_delete: true
            boot: true
    additional_disks:
        - disk: 
            name: "data-disk-01"
            size: 300
            auto_delete: true     # Set to false for production environments
            boot: false
        - disk: 
            name: "log-disk-01"
            size: 300
            auto_delete: true     # Set to false for production environments
            boot: false

Dependencies


N/A

Example Playbook


Click here to test and view example playbooks.

ansible.cfg

[defaults]
host_key_checking = False
inventory = hosts

remote_user = tansudasli                          # Your GCP account
private_key_file = ~/.ssh/google_compute_engine   # Always use this file for authentication if specified

[inventory]
# List of active inventory plugins and their order of usage.
enable_plugins = host_list, script, yaml, ini, auto, gcp_compute

provision.yaml

- name: Create Compute Instance(s)
  hosts: localhost
  gather_facts: no

  vars:
     general:
         project: sandbox-236618
         region: europe-west4
         auth_kind: serviceaccount
         service_account_file: ~/.ssh/ansible.json
     scopes:
         - https://www.googleapis.com/auth/compute
          
  tasks:

  roles:
    # Run with default variable values
    - role: tansudasli.gcp_instances  

License


Apache-2.0

Author Information


tansudasli

Informazioni sul progetto

Provisions compute instance(s) on GCP with production grade requirements.

Installa
ansible-galaxy install tansudasli.gcp_instances
Licenza
apache-2.0
Download
85
Proprietario
Ansible role boilerplates to inject into the projects that runs on GCP