Help us understand the problem. What is going on with this article?

TerraformでDigitalOcean上にdroneを作成

More than 5 years have passed since last update.

概要

TerraformでDigitalOcean上にdroneを作成

説明

terraform

Terraform は、インフラの構築・変更・バージョン変更を行うツール

digitalocean

1時間1円から使えるシンプルなクラウドホスティング

drone

drone.ioのオープンソース版
droneは、ホスト型継続的インテグレーションサービス。自動的に構築、テスト、コードに変更を加えるように展開するためにプロジェクトを設定できる.

前準備

参考記事
Terraform を Digital Ocean で触ってみた (初級編)
TerraformでDigitalOceanのdroplet作成

tarraformのプラン

variable "api_token" {}
variable "ssh_public_key" {}
variable "ssh_private_key" {}
variable "ssh_fingerprint" {}

provider "digitalocean" {
  token = "${var.api_token}"
}

resource "digitalocean_droplet" "drone" {
    image = "5900200"
    name = "drone"
    region = "sgp1"
    size = "512mb"
    private_networking = true
    ssh_keys = [
      "${var.ssh_fingerprint}"
    ]
    connection {
      user = "root"
      type = "ssh"
      key_file = "${var.ssh_private_key}"
      timeout = "2m"
    }
    provisioner "remote-exec" {
      inline = [
        "export PATH=$PATH:/usr/bin",
        "sudo apt-get update",
        "wget http://downloads.drone.io/latest/drone.deb",
        "sudo dpkg -i drone.deb"
      ]
    }
    provisioner "local-exec" {
        command = "echo ${digitalocean_droplet.drone.ipv4_address} >> ${digitalocean_droplet.drone.name}_ip.txt"
    }
}

実行

terraform apply  -var "ssh_private_key=$HOME/.ssh/id_rsa" -var "ssh_public_key=$HOME/.ssh/id_rsa.pub" -var "api_token=$DIGITALOCEAN_API_TOKEN" -var "ssh_fingerprint=$SSH_FINGERPRINT"

実行が成功すると実行ディレクトリに以下のファイルが作成されます
drone_ip.txt
書いてあるIPを使用して,以下のページを表示すると初期設定ができます
http://ip/install

メモ

  • image = "5900200"は2014/09/21のdocker インストール済みイメージのため適当に修正してください。
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away