ngine_io.exoscale_compute
Ansibleロール: Exoscaleコンピュート
:warning: 非推奨: Exoscaleは2024年5月1日以降、Cloudstack APIのサポートを終了します。
お知らせを確認。
Exoscaleクラウドの計算リソースを管理します。Exoscale Cloudで使用されます。
ロール変数
# 使用するAPI
exoscale__api_key:
exoscale__api_secret:
exoscale__api_endpoint: https://api.exoscale.ch/v1
# 使用するゾーン
exoscale__zone: ch-dk-2
# 作成するセキュリティグループ
exoscale__security_groups:
- name: default
rules:
- protocol: tcp
type: ingress
cidr: 0.0.0.0/0
start_port: 22
end_port: 22
# 作成するアフィニティグループ(デフォルトは[])
exoscale__affinity_groups:
- name: my cluster group
# 作成するネットワーク(デフォルトは[])
exoscale__networks:
- name: private-network
start_ip: 10.23.12.100
end_ip: 10.23.12.150
netmask: 255.255.255.0
# アップロードするSSHキー
exoscale__ssh_key_default_name: "{{ lookup('env', 'USER') }}@{{ lookup('pipe', 'hostname') }}"
exoscale__ssh_key_default_pubkey: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
exoscale__ssh_keys:
- name: "{{ exoscale__ssh_key_default_name }}"
pubkey: "{{ exoscale__ssh_key_default_pubkey }}"
# サーバインスタンス
exoscale__server_name: "{{ inventory_hostname_short }}"
exoscale__server_template: "Rocky Linux 8 (Green Obsidian) 64-bit"
exoscale__server_service_offering: Small
exoscale__server_root_disk_size: 10
exoscale__server_networks: "{{ omit }}"
exoscale__server_ip_to_networks: "{{ omit }}"
exoscale__server_security_groups:
- default
exoscale__server_affinity_groups: []
exoscale__server_ssh_key: "{{ exoscale__ssh_key_default_name }}"
exoscale__server_user_data: |
#cloud-config
manage_etc_hosts: false
fqdn: "{{ inventory_hostname }}"
exoscale__server_state: present
exoscale__server_allow_reboot: false
依存関係
Pythonライブラリの依存関係はrequirements.txt
を参照してください。
例
プレイブック
典型的なプレイブックは次のようになります。
---
- name: クラウドサーバをプロビジョニング
hosts: all
serial: 5
gather_facts: false
roles:
- role: ngine_io.exoscale_compute
delegate_to: localhost
post_tasks:
- name: SSHアクセスを待つ
delegate_to: localhost
wait_for:
host: "{{ ansible_host }}"
port: 22
timeout: 60
- name: cloud-initの完了を待つ
wait_for:
host: "{{ ansible_host }}"
path: /var/lib/cloud/instance/boot-finished
timeout: 600
一般的な設定
追加のセキュリティグループやルール、アフィニティグループ、ネットワークのための一般的な設定は、トップレベルのグループ(例: group_vars/all.yml
)に記述します。
# file: group_vars/all.yml
# API: クレデンシャル
exoscale__api_key: EXO...
exoscale__api_secret: ...$
# ゾーン: デフォルト ch-dk-2
exoscale__zone: ch-gva-2
# テンプレート: 使用されるテンプレートに応じて、SSH公開鍵を持つデフォルトユーザーが作成されます
ansible_user: rockylinux
exoscale__server_template: "Rocky Linux 8 (Green Obsidian) 64-bit 2021-08-25-13bb54"
# IPv6を有効にする
exoscale__server_ipv6_enabled: true
# セキュリティグループ: これらのセキュリティグループを作成します。
# 注意: 名前が異なる既存のセキュリティグループは変更されません。
# 注意: 下記のグループの追加既存ルールは変更されません。
exoscale__security_groups:
- name: proxy
rules:
- protocol: tcp
type: ingress
cidr: 0.0.0.0/0
port: 443
- protocol: tcp
type: ingress
cidr: 0.0.0.0/0
port: 80
- protocol: tcp
type: ingress
cidr: 1.2.3.4/32
start_port: 8000
end_port: 8999
- name: mqtt
rules:
- port: 1883
- port: 8883
# アフィニティグループ: これらのグループを作成します。
exoscale__affinity_groups:
- name: cassandra
- name: proxy
# バックエンドアクセスのためにプライベートネットワークを作成します。
exoscale__networks:
- name: my private net
start_ip: 10.23.12.100
end_ip: 10.23.12.150
netmask: 255.255.255.0
グループ / ホスト変数によるインスタンス設定
次のようなインベントリを想定します。
[proxy]
proxy1.example.com
proxy2.example.com
[cassandra]
cassandra1.example.com
cassandra2.example.com
cassandra3.example.com
すべてのプロキシインスタンスが異なるオファリングと追加のセキュリティグループproxyを使用することを確認します。
#file: group_vars/proxy.yml
# 大きなオファリング(デフォルトは小)
exoscale__server_service_offering: Medium
# インスタンスにセキュリティグループを割り当てる(デフォルト: [default])
exoscale__server_security_groups:
- default
- proxy
# プライベートネットワークを接続
exoscale__server_networks:
- my private net
すべてのcassandraインスタンスが異なるハードウェアホスト上にあることを確認します。
#file: group_vars/cassandra.yml
# すべてのインスタンスにアフィニティグループを割り当てる
exoscale__server_affinity_groups: cassandra
# CPU関連のハードウェアを使用
exoscale__server_service_offering: CPU-extra-large
# プライベートネットワークを接続
exoscale__server_networks:
- my private net
:information_source: ヒント: すべてのオファリングのリストを取得するには
cs listServiceOfferings | jq --raw-output '.serviceoffering[].name'
を実行します。
詳細については、CLIで使用されるライブラリの使い方を こちら でご確認ください。
ライセンス
MIT
著者情報
René Moser (@resmo)