From 28e3f21141880e6b9b717582c3059e899bce0627 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Mon, 21 Jun 2021 21:27:04 +0900 Subject: [PATCH] Install `Vault`. --- cookbooks/vault/attributes.rb | 8 ++++++++ cookbooks/vault/default.rb | 4 ++++ cookbooks/vault/install.rb | 20 +++++++++++++++++++ .../etc/apt/sources.list.d/hashicorp.list | 1 + 4 files changed, 33 insertions(+) create mode 100644 cookbooks/vault/attributes.rb create mode 100644 cookbooks/vault/default.rb create mode 100644 cookbooks/vault/install.rb create mode 100644 cookbooks/vault/templates/etc/apt/sources.list.d/hashicorp.list diff --git a/cookbooks/vault/attributes.rb b/cookbooks/vault/attributes.rb new file mode 100644 index 0000000..4124518 --- /dev/null +++ b/cookbooks/vault/attributes.rb @@ -0,0 +1,8 @@ +# ------------------------------------------- +# Specifying the default settings: +# ------------------------------------------- +node.reverse_merge!({ + 'vault' => { + 'manager' => false, + } +}) diff --git a/cookbooks/vault/default.rb b/cookbooks/vault/default.rb new file mode 100644 index 0000000..ab8f639 --- /dev/null +++ b/cookbooks/vault/default.rb @@ -0,0 +1,4 @@ +include_recipe './attributes.rb' + +include_recipe './install.rb' + diff --git a/cookbooks/vault/install.rb b/cookbooks/vault/install.rb new file mode 100644 index 0000000..b93c132 --- /dev/null +++ b/cookbooks/vault/install.rb @@ -0,0 +1,20 @@ +# Install `Consul`: +KEYSRV = "https://apt.releases.hashicorp.com/gpg" +ID = "A3219F7B" + +execute "apt-key adv --keyserver #{KEYSRV} --recv-keys #{ID}" do + not_if 'apt-key list | grep HashiCorp' +end + +# Retrieve the Ubuntu code: +DIST = run_command('lsb_release -cs').stdout.chomp + +# Deploy the `apt` sources: +template '/etc/apt/sources.list.d/hashicorp.list' do + action :create + variables(distribution: DIST) +end + +execute 'apt update' + +package 'vault' diff --git a/cookbooks/vault/templates/etc/apt/sources.list.d/hashicorp.list b/cookbooks/vault/templates/etc/apt/sources.list.d/hashicorp.list new file mode 100644 index 0000000..16f9f11 --- /dev/null +++ b/cookbooks/vault/templates/etc/apt/sources.list.d/hashicorp.list @@ -0,0 +1 @@ +deb [arch=amd64] https://apt.releases.hashicorp.com <%= @distribution %> main