diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b30143a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "scripts"] + path = scripts + url = https://github.com/armorfret/ci-helpers diff --git a/.prospectus b/.prospectus new file mode 100644 index 0000000..f1e0795 --- /dev/null +++ b/.prospectus @@ -0,0 +1,26 @@ +Prospectus.extra_dep('file', 'prospectus_travis') + +item do + noop + + extend ProspectusTravis::Build.new('armorfret/terraform-linode-wireguard-image') + + deps do + item do + name 'terraform' + + expected do + github_release + repo 'hashicorp/terraform' + regex /^v?([\d.]+)$/ + filter /^v?([\d.]+)$/ + end + + actual do + grep + file '.travis.yml' + regex /^\s+- TERRAFORM_VERSION=([\d.]+)$/ + end + end + end +end diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2880bae --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +dist: trusty +env: + global: + - TFBIN_DIR=$HOME/tfbin + - TERRAFORM_VERSION=0.11.13 +install: +- "./scripts/download_terraform.sh $TERRAFORM_VERSION" +script: +- "~/tfbin/terraform fmt -write=false -diff=true -check" +notifications: + email: false diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..74b636a --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2019 Les Aker + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..8a1e32c --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +terraform-linode-wireguard-image +========= + +[![MIT Licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://tldrlegal.com/license/mit-license) + +Terraform module that creates a [Linode](https://linode.com) Image pre-baked with updates and [this Ansible repo](https://github.com/akerl/deploy-wireguard-server/) for deploying [Wireguard](https://www.wireguard.com). + +## Usage + +``` +module "wireguard_image" { + source = "github.com/akerl/terraform-linode-wireguard-base" +} +``` + +## License + +terraform-linode-wireguard-base is released under the MIT License. See the bundled LICENSE file for details. diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..d21e0d8 --- /dev/null +++ b/main.tf @@ -0,0 +1,21 @@ +resource "random_id" "vm_suffix" { + byte_length = 8 +} + +module "vm" { + source = "armorfret/wireguard-base/linode" + version = "0.0.1" + name = "wg-image_${random_id.vm_suffix.hex}" + region = "us-east" + type = "g6-standard-1" + algo_repo = "${var.deploy_repo}" + source_image_id = "linode/ubuntu18.10" + ssh_keys = ["${var.ssh_keys}"] +} + +resource "linode_image" "image" { + linode_id = "${module.vm.linode_id}" + disk_id = "${module.vm.disk_id}" + label = "wireguard-image" + description = "Created by Terraform" +} diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..4a939a2 --- /dev/null +++ b/outputs.tf @@ -0,0 +1,4 @@ +output "image_id" { + value = "${linode_image.image.id}" + description = "ID of the Linode Image" +} diff --git a/scripts b/scripts new file mode 160000 index 0000000..be42d6f --- /dev/null +++ b/scripts @@ -0,0 +1 @@ +Subproject commit be42d6f7f6142d3039d57b01987bc137fc408986 diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..362db6a --- /dev/null +++ b/variables.tf @@ -0,0 +1,10 @@ +variable "deploy_repo" { + type = "string" + default = "https://github.com/akerl/deploy-wireguard-server" + description = "Repo to use for Ansible code" +} + +variable "ssh_keys" { + type = "list" + description = "SSH public keys used to log in as root to the server" +}