tansudasli.gcp_instances

役割名

生産レベルの要件を持つGCPでコンピュータインスタンスをプロビジョニングします。

  • インスタンス
  • 専用ブートディスク
  • 専用データおよびログディスク
  • 静的IP

要件

  • ansible クライアント
  • ansible.cfg ファイル
  • サービスアカウントおよびGCPアカウント

役割の変数

デフォルトでは、役割はスタンドアロンプロビジョニングをサポートしています。分散プロビジョニングを希望する場合は、実行中のyamlファイルに適切な命名規則で追加のノードを提供できます。

defaults/main.yml,

# GCPプロジェクト
general:
    project: sandbox-236618       # GCPプロジェクトID 
    region: europe-west4          # GCPリージョン
    auth_kind: serviceaccount     
    service_account_file: ~/.ssh/ansible.json
scopes:
    - https://www.googleapis.com/auth/compute

# インフラストラクチャアーキテクチャを設計する
nodes:
  - name: standalone-node    #ノード名(例: standalone-node/name-node/secondary-name-node/data-node1/data-node2)
    zone: europe-west4-a     # 近くのリージョンを選択し、他のノードに分散させる
    machine_type: f1-micro   # 必要に応じて増やす
    ips:
        - nic: 
            name: "ip-01"
    tags: hadoop             # FWルールで使用されるネットワークタグ!ツール名を使用(例: hadoop, elasticsearch)
    labels:                  # フィルタリング!ツール名をタイプ + master/workerとして使用
        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     # falseは生産用途には推奨
            boot: false
        - disk: 
            name: "log-disk-01"
            size: 300
            auto_delete: true     # falseは生産用途には推奨
            boot: false

依存関係

該当なし

例のプレイブック

クリックして、テストおよび例のプレイブックを確認してください。

ansible.cfg

[defaults]
host_key_checking = False
inventory = hosts

remote_user = tansudasli                          # あなたのGCPアカウント
private_key_file = ~/.ssh/google_compute_engine   # 設定されている場合、常にこれを使用して認証

[inventory]
# 有効なインベントリプラグインのリストおよびそれを使用する順序。
enable_plugins = host_list, script, yaml, ini, auto, gcp_compute

provision.yaml

- name: コンピュートインスタンスを作成する
  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:
    # デフォルトの変数値で実行
    - role: tansudasli.gcp_instances  

ライセンス

Apache-2.0

著者情報

tansudasli

プロジェクトについて

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

インストール
ansible-galaxy install tansudasli.gcp_instances
ライセンス
apache-2.0
ダウンロード
85
所有者
Ansible role boilerplates to inject into the projects that runs on GCP