Skip to content

Commit

Permalink
chore(deps): update dependency pytest to v8.1.1 (#201)
Browse files Browse the repository at this point in the history
chore(deps): update dependency pytest to v8.1.1
fix(ubuntu): add docker plugin to ubuntu template
fix(consul): add ansible plugin to consul template
feat(vault): add autojoin token
fix(vault): fix plugin declaration in vault template
ci(vault): add vault autojoin token to vault secrets

Signed-off-by: Bruce Becker <[email protected]>

---------

Signed-off-by: Bruce Becker <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Bruce Becker <[email protected]>
  • Loading branch information
renovate[bot] and brucellino authored Mar 12, 2024
1 parent c06e98d commit a308b31
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
${HOME}/bin/vault secrets enable -path="kv" kv-v2
- name: Populate the DO secret
run: ${HOME}/bin/vault kv put -mount="digitalocean" tokens packer=${{ secrets.DO_TOKEN }}
- name: Populate vault autojoin token
run: ${HOME}/bin/vault kv patch -mount="digitalocean" tokens vault_auto_join=${{ secrets.DO_TOKEN }}
- name: Populate the GH secret
run: ${HOME}/bin/vault kv put -mount="kv" github ghcr_token=${{ secrets.GITHUB_TOKEN }}
- name: Populate Consul Encryption Key
Expand Down
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ repos:
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ['@commitlint/config-conventional']
additional_dependencies:
- "@commitlint/config-conventional"
- "@commitlint/cli"
- repo: https://github.com/ansible-community/ansible-lint
rev: v24.2.0
hooks:
Expand Down
4 changes: 4 additions & 0 deletions consul/consul-do.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ packer {
version = ">= v1.0.8"
source = "github.com/hashicorp/docker"
}
ansible = {
version = "~> 1"
source = "github.com/hashicorp/ansible"
}
}
}
variable "consul_version" {
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
ansible-lint==24.2.0
ansible==9.3.0
pyhcl==0.4.5
pytest==8.1.0
pytest==8.1.1
pytest-testinfra==10.1.0
python-consul==1.1.0
6 changes: 6 additions & 0 deletions ubuntu-server/ubuntu_server_amd64.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
packer {
required_version = ">=1.7.0"
required_plugins {
docker = {
source = "github.com/hashicorp/docker"
version = "~> 1"
}
}
}

variable "version" {
Expand Down
13 changes: 6 additions & 7 deletions vault/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
hosts: all
become: true
vars:
vault_version: 1.13.0
vault_version: 1.15.1
vault_config_dir: /etc/vault
vault_bin_dir: /usr/local/bin
raft_data_dir: /data/raft
Expand All @@ -16,12 +16,11 @@
- unzip
region: "ams3"
pre_tasks:
- name: Wait
ansible.builtin.pause:
seconds: 60
- name: Force update
ansible.builtin.raw: apt-get -y update
changed_when: false
- name: Wait for cloud-init to finish
ansible.builtin.wait_for:
state: present
path: /var/log/cloud-init-output.log
search_regex: "^Cloud-init.*finished.*$"
tasks:
- name: Ensure prerequisites
ansible.builtin.package:
Expand Down
28 changes: 24 additions & 4 deletions vault/vault-do.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
packer {
required_plugins {
digitalocean = {
version = ">= v1.1.0"
version = ">= v1.2.0"
source = "github.com/digitalocean/digitalocean"
}
ansible = {
version = "~> 1"
source = "github.com/hashicorp/ansible"
}
}
}

Expand All @@ -21,14 +25,22 @@ variable "size" {
variable "base_image_name" {
type = string
sensitive = false
default = "20.04 (LTS) x64"
default = "23.10 x64"
}

local "do_token" {
expression = vault("digitalocean/data/tokens", "packer")
sensitive = true
}

local "autojoin_token" {
expression = vault("digitalocean/data/tokens", "vault_auto_join")
sensitive = true
}

local "build_tag" {
expression = join("-", ["created", "at", formatdate("YYYY-MM-DD-hh-mm", timestamp())])
}

variable "vpc_uuid" {
type = string
Expand Down Expand Up @@ -56,7 +68,7 @@ source "digitalocean" "server" {
monitoring = true
private_networking = true
droplet_name = "vault-build-${formatdate("YYYY-MM-DD-hh-mm", timestamp())}"
tags = ["packer", "vault"]
tags = ["packer", "vault", "auto-destroy", local.build_tag]
vpc_uuid = var.vpc_uuid
}

Expand All @@ -67,7 +79,15 @@ build {
playbook_file = "playbook.yml"
extra_arguments = [
"--extra-vars",
"region=${var.region}"
"region=${var.region}",
"--extra-vars",
"autojoin_token=${local.autojoin_token}"
]
}
provisioner "shell" {
inline = [
"ls -lht /etc/vault.d",
"cat /etc/vault.d/vault.hcl"
]
}
}
14 changes: 10 additions & 4 deletions vault/vault.hcl.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ui = true

storage "raft" {
path = "[[ raft_data_dir ]]"
node_id = "digitalocean-host"
Expand All @@ -19,12 +21,12 @@ listener "tcp" {

{% raw %}
listener "tcp" {
address = "{{ GetInterfaceIP \"eth0\" }}:8200"
address = "{{ GetInterfaceIP \"eth1\" }}:8200"
tls_disable = true
}

api_addr = "http://{{ GetInterfaceIP \"eth0\" }}:8200"
cluster_addr = "http://{{ GetInterfaceIP \"eth0\" }}:8201"
api_addr = "http://{{ GetInterfaceIP \"eth1\" }}:8200"
cluster_addr = "http://{{ GetInterfaceIP \"eth1\" }}:8201"
{% endraw %}

{% if consul_agent | default (false) %}
Expand All @@ -36,4 +38,8 @@ service_registration "consul" {
}
{% endif %}

ui = true

telemetry {
disable_hostname = false
prometheus_retention_time = "24h"
}

0 comments on commit a308b31

Please sign in to comment.