CLOVER🍀

That was when it all began.

Terraform、Vagrant、ConsulなどのHashiCorp製品をLinuxのパッケージマネージャーでインストールする

これは、なにをしたくて書いたもの?

自分はTerraformやVagrantなど、HashiCorp製品をそれなりに使っているのですが、いつもzipなりdebなりで
インストールしていました。

ですが、最近Terraformのドキュメントにaptやyumリポジトリに関するドキュメントが増えていたのに気づき。

APT Packages for Debian and Ubuntu - Terraform by HashiCorp

Yum Packages for Red Hat Enterprise Linux, Fedora, and Amazon Linux - Terraform by HashiCorp

ちょっと調べてみようかなと。

HashiCorp apt/yumリポジトリ

こちらにブログ記事がありました。

Announcing the HashiCorp Linux Repository

apt、yum(dnf)を使って、HashiCorp製品をインストールできます。

プラットフォームとしては、DebianUbuntu LinuxFedoraCentOSRHELAmazon Linuxに対応しているようです。

インストールされるバイナリはこちらに置かれているものと同じもので、

All Projects | HashiCorp Releases

ものによってはsystemd等でのサービスにも対応していそうな雰囲気があります。

では、使ってみましょう。

環境

今回の環境は、Ubuntu Linux 20.04 LTSです。

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:    20.04
Codename:   focal


$ uname -srvmpio
Linux 5.4.0-80-generic #90-Ubuntu SMP Fri Jul 9 22:49:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

aptリポジトリの追加

aptリポジトリの場合は、以下のようにGPGキーとリポジトリの追加を行います。

$ curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
$ sudo apt-add-repository "deb [arch=$(dpkg --print-architecture)] https://apt.releases.hashicorp.com $(lsb_release -cs) main"

主要なパッケージを検索。全部ありますね。

$ apt search '^(vagrant|terraform|consul|waypoint|boundary|packer|nomad|vault)$'
ソート中... 完了
全文検索... 完了  
boundary/focal 0.4.0 amd64
  Boundary is a tool for identity-based secure access management. Please submit issues to https://github.com/hashicorp/boundary/issues

consul/focal 1.10.1 amd64
  Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure. Please submit issues to https://github.com/hashicorp/consul/issues

nomad/focal 1.1.2 amd64
  Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations. Please submit issues to https://github.com/hashicorp/nomad/issues

packer/focal 1.7.4 amd64
  Packer is a tool for creating identical machine images for multiple platforms from a single source configuration. Please submit issues to https://github.com/hashicorp/packer/issues

terraform/focal 1.0.3 amd64
  Terraform enables you to safely and predictably create, change, and improve infrastructure. It is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned. Please submit issues to https://github.com/hashicorp/terraform/issues

vagrant/focal 2.2.17 amd64
  Vagrant is a tool for building and distributing development environments.

vault/focal 1.7.3 amd64
  A tool for secrets management, encryption as a service, and privileged access management. Please submit issues to https://github.com/hashicorp/vault/issues

waypoint/focal 0.4.2 amd64
  Waypoint is a tool to build, deploy, and release any application on any platform. Please submit issues to https://github.com/hashicorp/waypoint/issues

インストールしてみる

いくつかインストールしてみましょう。

Terraform。

$ sudo apt install terraform


$ terraform version
Terraform v1.0.3
on linux_amd64

Vagrant

$ sudo apt install vagrant


$ vagrant version
Installed Version: 2.2.17
Latest Version: 2.2.17
 
You're running an up-to-date version of Vagrant!

Consul。

$ sudo apt install consul


$ consul version
Consul v1.10.1
Revision db839f18b
Protocol 2 spoken by default, understands 2 to 3 (agent will automatically use protocol >2 when speaking to compatible agents)

Consulはsystemdのサービスユニットとして登録してくれたりしないかな、と思いましたが、そうでもなかったようです。

$ sudo systemctl list-units | grep consul

他にも関連するパッケージをインストールできそうですね。

$ sudo apt install terraform-ls


$ sudo apt install vagrant-
vagrant-bindfs            vagrant-digitalocean      vagrant-librarian-puppet  vagrant-lxc               vagrant-sshfs             
vagrant-cachier           vagrant-hostmanager       vagrant-libvirt           vagrant-mutate 
$ sudo apt install consul-template


$ sudo apt install consul-
consul-enterprise      consul-template        consul-terraform-sync

aptでインストールできた方が個人的には便利なので、今後はこちらを使っていきましょう。