「Ansibleによるインスタンスのデプロイ」の版間の差分

提供: Japanese Ikoula Wiki
Jump to navigation Jump to search
(ページの作成:「<span data-link_translate_fr_title="Deployer vos instances avec Ansible" data-link_translate_fr_url="Deployer vos instances avec Ansible"></span>:fr:Deployer vos insta…」)
 
1行目: 1行目:
 +
<span data-link_translate_pl_title="Wdrażaj instancje za pomocą Ansible"  data-link_translate_pl_url="Wdrażaj instancje za pomocą Ansible"></span>[[:pl:Wdrażaj instancje za pomocą Ansible]][[pl:Wdrażaj instancje za pomocą Ansible]]
 
<span data-link_translate_fr_title="Deployer vos instances avec Ansible"  data-link_translate_fr_url="Deployer vos instances avec Ansible"></span>[[:fr:Deployer vos instances avec Ansible]][[fr:Deployer vos instances avec Ansible]]
 
<span data-link_translate_fr_title="Deployer vos instances avec Ansible"  data-link_translate_fr_url="Deployer vos instances avec Ansible"></span>[[:fr:Deployer vos instances avec Ansible]][[fr:Deployer vos instances avec Ansible]]
 
<br />この記事は、自動翻訳ソフトウェアで行うからです。 [[:fr:Deployer vos instances avec Ansible|記事のソースはここ]]を参照してくださいすることができます。<br /><span data-translate="fr"></span><br />
 
<br />この記事は、自動翻訳ソフトウェアで行うからです。 [[:fr:Deployer vos instances avec Ansible|記事のソースはここ]]を参照してくださいすることができます。<br /><span data-translate="fr"></span><br />

2021年7月29日 (木) 16:35時点における版

pl:Wdrażaj instancje za pomocą Ansible fr:Deployer vos instances avec Ansible
この記事は、自動翻訳ソフトウェアで行うからです。 記事のソースはここを参照してくださいすることができます。

zh:用Ansible部署你的实例 de:Stellen Sie Ihre Instanzen mit Ansible bereit nl:Implementeer uw instanties met Ansible it:Distribuire le tue istanze con Ansible pt:Implante as suas instâncias com Ansible es:Despliegue de sus instancias con Ansible en:Deploy your instances with Ansible

説明

ここでは、Ansibleツールを使ってIKOULA One Cloudインスタンスを迅速に展開する方法を説明します。

まず、Ansibleをインストールする必要があります(https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html)続いて、"cs_instance "モジュール("pip install cs "でインストール可能)を使用します。 https://docs.ansible.com/ansible/2.6/modules/cs_instance_module.html)お客様がCloud IKOULA One APIを使用できるようにすること(Cloud IKOULA Oneアカウントをお持ちでない場合)。

Ansibleは、ほとんどのGNU/LinuxディストリビューションやMacOSで利用できますが、Cygwinを介してMicrosoft Windowsなどでも利用できます。


Ansible を使って、1つのコマンドでインスタンスをデプロイすることができます。

まず、 「Ansible 」の「cs_instance」モジュールの設定ファイル「.cloudstack.ini」を作成し、記入/適応する必要があります。

[CloudIkoulaOne]
endpoint = https://cloudstack.ikoula.com/client/api
key = <clé API de votre utilisateur/compte Cloud IKOULA One>
secret = <clé privée de votre utilisateur/compte Cloud IKOULA One>
timeout = 30

あとはこのコマンドを実行して、パラメータの値(インスタンス名、ネットワーク名など)やパラメータ自体(SSHキーペアを使うかどうかなど)を調整すればOKです。

ansible -i "localhost," -c local all -m cs_instance -a "name=<Nom de la VM> display_name=<Nom de la VM>  state=present template=< Nom entre simples quotes ou ID du template voulu> api_region=CloudIkoulaOne zone=<Nom de la zone voulu> service_offering=< Nom de l’offre de calcul voulu > networks=<Nom du réseau existant voulu> ssh_key=<Nom de la paire de clés ssh CIO existante>"

ここで「<Nom de l’offre de calcul voulu >」は、「」の選択です</Nom>。<Nom de l’offre de calcul voulu >

"t1.pico" (1/2 Core CPU with 512MB RAM and 100Mbps NIC)
"t1.micro" (1 Core CPU with 1GB RAM and 100Mbps NIC)
"m1.small" (1 Core CPU with 1.7GB RAM and 100Mbps NIC)
"m1.medium" (2 Cores CPU with 3.8GB RAM and 100Mbps NIC)
"m1.large" (4 Cores CPU with 7.6GB RAM and 100Mbps NIC)
"m1.extralarge" (8 Cores CPU with 15.3GB RAM and 100Mbps NIC)

ここでは、その例と、その実行によるリターンを紹介します。

$ ansible -i "localhost," -c local all -m cs_instance -a "name=Debian9advz1 display_name=Debian9adv1 state=present template='Debian 9 - Minimal - 64bits' api_region=CloudIkoulaOne zone=EU-FR-IKDC1-Z1-ADV service_offering=t1.micro networks=My-Network-Z1 ssh_key=MY_SSHKEY"
localhost | SUCCESS => {
    "account": "ikoula",
    "affinity_groups": [],
    "changed": true,
    "created": "2018-09-12T10:05:00+0200",
    "default_ip": "10.1.1.176",
    "display_name": "Debian9adv1",
    "domain": "ROOT",
    "hypervisor": "XenServer",
    "id": "3c60acc9-1480-48bc-ab78-934f0e607d6c",
    "instance_name": "i-1079-67026-VM",
    "name": "Debian9advz1",
    "password": "KYqrT3h28qOs",
    "password_enabled": true,
    "security_groups": [],
    "service_offering": "t1.micro",
    "ssh_key": "MY_SSHKEY",
    "state": "Running",
    "tags": [],
    "template": "Debian 9 - Minimal - 64bits",
    "user_data": "",
    "zone": "EU-FR-IKDC1-Z1-ADV"
}

この例では、Advanced Zone(EU-FR-IKDC1-Z1-ADV)にDebian 9インスタンスを配置し、My-Network-Z1というネットワークでコンピュート・オファリング "t1.micro "を使用し、SSHキー・ペア "MY_SSHKEY "を設定しています。

すべての使用可能なパラメータやその他の例を見るには、"cs_instance "モジュールのansible-docを使用してください。

$ ansible-doc cs_instance
> CS_INSTANCE    (/usr/lib/python2.7/site-packages/ansible/modules/cloud/cloudstack/cs_instance.py)

  Deploy, start, update, scale, restart, restore, stop and destroy instances.

Options (= is mandatory):

- account
        Account the instance is related to.
        [Default: None]
- affinity_groups
        Affinity groups names to be applied to the new instance.
        [Default: []]
- api_http_method
        HTTP method used.
        (Choices: get, post)[Default: get]
- api_key
        API key of the CloudStack API.
        [Default: None]
- api_region
        Name of the ini section in the `cloustack.ini' file.
        [Default: cloudstack]
- api_secret
        Secret key of the CloudStack API.
        [Default: None]
- api_timeout
        HTTP timeout.
        [Default: 10]
- api_url
        URL of the CloudStack API e.g. https://cloud.example.com/client/api.
        [Default: None]
- cpu
        The number of CPUs to allocate to the instance, used with custom service offerings
        [Default: None]
- cpu_speed
        The clock speed/shares allocated to the instance, used with custom service offerings
        [Default: None]
- disk_offering
        Name of the disk offering to be used.
        [Default: None]
- disk_size
        Disk size in GByte required if deploying instance from ISO.
        [Default: None]
...

注:コマンドの出力は、その長さのために意図的に切り捨てられています。

Ansibleプレイブックによるインスタンスのデプロイメント

上記と同様に、Ansibleの「cs_instance」モジュールの設定ファイル「.cloudstack.ini」を作成し、記入・適応する必要があります。

[CloudIkoulaOne]
endpoint = https://cloudstack.ikoula.com/client/api
key = <clé API de votre utilisateur/compte Cloud IKOULA One>
secret = <clé privée de votre utilisateur/compte Cloud IKOULA One>
timeout = 30

あとは、以下のようなプレイブックファイル(yml拡張子/YAML形式)を作成して、パラメータの値(インスタンス名、ネットワーク名など)やパラメータ自体(SSHキーペアを使うかどうかなど)を調整すればOKです。

アドバンスドゾーンにインスタンスをデプロイするプレイブックの例。

$ cat deploy_instance_adv.yml
---

- hosts: all
  connection: local
  user: root

  tasks:

  - name: 'Create Debian instance in Cloud IKOULA One with Ansible Playbook'
    cs_instance:
      name: "<Nom de la VM>"
      state: present
      display_name: "<Nom de la VM>"
      template: "<Nom entre simples quotes ou ID du template CIO voulu>"
      api_region: "CloudIkoulaOne"
      zone: "<Nom de la zone voulu>"
      service_offering: "<Nom de l’offre de calcul voulu >"
      networks: "<Nom du réseau existant voulu>"
      ssh_key: "<Nom de la paire de clés ssh CIO existante>"
...

基本ゾーンにインスタンスを配置するためのプレイブックの例(networkパラメータをsecurity groupsパラメータに置き換え、vmに割り当てられたパブリックIPアドレスを配置後に返すことを追加しただけの例)。

$ cat deploy_instance_basic.yml
---

- hosts: all
  connection: local
  user: root

  tasks:

  - name: 'Create Debian instance in Cloud IKOULA One with Ansible Playbook'
    cs_instance:
      name: "<Nom de la VM>"
      state: present
      display_name: "<Nom de la VM>"
      template: "<Nom entre simples quotes ou ID du template CIO voulu>"
      api_region: "CloudIkoulaOne"
      zone: "<Nom de la zone voulu>"
      service_offering: "<Nom de l’offre de calcul voulu >"
      security_groups: "<Nom du groupe de sécurité existant voulu>"
      ssh_key: "<Nom de la paire de clés ssh CIO existante>"

  - name: "VM ip address:"
    debug:
      var: vminfo.default_ip
...


パラメータとその値を調整した後、プレイブックを実行する例を以下に示します(必要に応じてプレイブックファイルの名前を変更してください)。

$ ansible-playbook -i "localhost," -c local deploy_instance_adv.yml

PLAY [all] ********************************************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [Create Debian instance in Cloud IKOULA One with Ansible Playbook] ********************************************************************************************************************************************************************************************************************************
changed: [localhost]

PLAY RECAP ********************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0

Catégorie :Cloud public Catégorie:API Catégorie :Cloud</Nom>