improve packer template
Some checks failed
OpenTofu Automation / deploy (push) Has been cancelled

This commit is contained in:
Matt Reeves 2024-11-07 20:22:31 -05:00
parent 5d30cf42f3
commit 5df60301c2
6 changed files with 52 additions and 21 deletions

View file

@ -1,11 +0,0 @@
services:
actual_server:
container_name: actual
image: ghcr.io/actualbudget/actual-server:24.11.0
ports:
- '5006:5006'
environment:
- ACTUAL_PORT=5006
volumes:
- /docker/appdata/actual/data:/data
restart: unless-stopped

View file

@ -0,0 +1,7 @@
{
"log-driver": "loki",
"log-opts": {
"loki-url": "http://ubu.lan:3100/loki/api/v1/push",
"loki-batch-size": "400"
}
}

View file

@ -105,17 +105,28 @@ build {
inline = [ "sudo cp /tmp/pve.cfg /etc/cloud/cloud.cfg.d/pve.cfg" ] inline = [ "sudo cp /tmp/pve.cfg /etc/cloud/cloud.cfg.d/pve.cfg" ]
} }
provisioner "file" {
source = "files/daemon.json"
destination = "/tmp/daemon.json"
}
provisioner "shell" { provisioner "shell" {
inline = [ inline = [
# Install packages and add repositories # Install packages and add repositories
"sudo add-apt-repository -y ppa:zhangsongcui3371/fastfetch", "wget https://github.com/fastfetch-cli/fastfetch/releases/download/2.29.0/fastfetch-linux-amd64.deb",
"sudo dpkg -i fastfetch-linux-amd64.deb",
"rm -f fastfetch-linux-amd64.deb",
"sudo apt-get update", "sudo apt-get update",
"sudo apt-get install -y ca-certificates curl gnupg lsb-release nfs-common net-tools zsh fastfetch fzf", "sudo apt-get install -y ca-certificates curl gnupg lsb-release nfs-common net-tools zsh fzf",
# Change default shell to zsh # Change default shell to zsh
"sudo chsh -s $(which zsh) mafyuh", "sudo chsh -s $(which zsh) mafyuh",
# Install Docker # Install Docker & Loki Plugin
"curl -fsSL https://get.docker.com | sudo sh", "curl -fsSL https://get.docker.com | sudo sh",
"sudo docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions",
"sudo mv /tmp/daemon.json /etc/docker/daemon.json",
# Set DNS
"sudo mkdir -p /etc/systemd/resolved.conf.d && echo '[Resolve]\nDNS=10.0.0.40' | sudo tee /etc/systemd/resolved.conf.d/dns_servers.conf",
# Install Oh My Zsh and plugins # Install Oh My Zsh and plugins
"sh -c \"$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)\" --unattended", "sh -c \"$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)\" --unattended",
"git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting", "git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting",
@ -132,7 +143,7 @@ build {
# Setup Git # Setup Git
"git config --global user.name \"Mafyuh\"", "git config --global user.name \"Mafyuh\"",
"git config --global user.email \"matt@mafyuh.com\"", "git config --global user.email \"matt@mafyuh.com\"",
"sudo apt-get -y update" "sudo apt-get -y upgrade"
] ]
} }

View file

@ -106,16 +106,28 @@ build {
} }
provisioner "file" {
source = "files/daemon.json"
destination = "/tmp/daemon.json"
}
provisioner "shell" { provisioner "shell" {
inline = [ inline = [
# Install packages and add repositories # Install packages and add repositories
"sudo add-apt-repository -y ppa:zhangsongcui3371/fastfetch", "wget https://github.com/fastfetch-cli/fastfetch/releases/download/2.29.0/fastfetch-linux-amd64.deb",
"sudo dpkg -i fastfetch-linux-amd64.deb",
"rm -f fastfetch-linux-amd64.deb",
"sudo apt-get update", "sudo apt-get update",
"sudo apt-get install -y ca-certificates curl gnupg lsb-release nfs-common net-tools zsh fastfetch fzf", "sudo apt-get install -y ca-certificates curl gnupg lsb-release nfs-common net-tools zsh fzf",
# Change default shell to zsh # Change default shell to zsh
"sudo chsh -s $(which zsh) mafyuh", "sudo chsh -s $(which zsh) mafyuh",
# Install Docker # Install Docker & Loki Plugin
"curl -fsSL https://get.docker.com | sudo sh", "curl -fsSL https://get.docker.com | sudo sh",
"sudo docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions",
"sudo mv /tmp/daemon.json /etc/docker/daemon.json",
# Set DNS
"sudo mkdir -p /etc/systemd/resolved.conf.d && echo '[Resolve]\nDNS=10.0.0.40' | sudo tee /etc/systemd/resolved.conf.d/dns_servers.conf",
# Install Oh My Zsh and plugins # Install Oh My Zsh and plugins
"sh -c \"$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)\" --unattended", "sh -c \"$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)\" --unattended",
"git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting", "git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting",
@ -132,7 +144,7 @@ build {
# Setup Git # Setup Git
"git config --global user.name \"Mafyuh\"", "git config --global user.name \"Mafyuh\"",
"git config --global user.email \"matt@mafyuh.com\"", "git config --global user.email \"matt@mafyuh.com\"",
"sudo apt-get -y update" "sudo apt-get -y upgrade"
] ]
} }

View file

@ -16,7 +16,6 @@ resource "proxmox_virtual_environment_file" "cloud_config" {
- name: mafyuh - name: mafyuh
groups: groups:
- sudo - sudo
- docker
shell: /bin/bash shell: /bin/bash
ssh_authorized_keys: ssh_authorized_keys:
- ${trimspace(local.ssh_public_key_1)} - ${trimspace(local.ssh_public_key_1)}
@ -25,6 +24,7 @@ resource "proxmox_virtual_environment_file" "cloud_config" {
runcmd: runcmd:
- apt update - apt update
- apt upgrade -y - apt upgrade -y
- usermod -aG docker mafyuh
- timedatectl set-timezone America/New_York - timedatectl set-timezone America/New_York
- su - mafyuh -c 'git clone https://git.mafyuh.dev/mafyuh/iac.git /home/mafyuh/iac' - su - mafyuh -c 'git clone https://git.mafyuh.dev/mafyuh/iac.git /home/mafyuh/iac'
- echo "done" > /tmp/cloud-config.done - echo "done" > /tmp/cloud-config.done
@ -47,7 +47,6 @@ resource "proxmox_virtual_environment_file" "cloud_config2" {
- name: mafyuh - name: mafyuh
groups: groups:
- sudo - sudo
- docker
shell: /bin/bash shell: /bin/bash
ssh_authorized_keys: ssh_authorized_keys:
- ${trimspace(local.ssh_public_key_1)} - ${trimspace(local.ssh_public_key_1)}
@ -56,6 +55,7 @@ resource "proxmox_virtual_environment_file" "cloud_config2" {
runcmd: runcmd:
- apt update - apt update
- apt upgrade -y - apt upgrade -y
- usermod -aG docker mafyuh
- timedatectl set-timezone America/New_York - timedatectl set-timezone America/New_York
- su - mafyuh -c 'git clone https://git.mafyuh.dev/mafyuh/iac.git /home/mafyuh/iac' - su - mafyuh -c 'git clone https://git.mafyuh.dev/mafyuh/iac.git /home/mafyuh/iac'
- echo "done" > /tmp/cloud-config.done - echo "done" > /tmp/cloud-config.done

View file

@ -91,3 +91,15 @@ variable "ssh_password" {
type = string type = string
sensitive = true sensitive = true
} }
variable "grafana_auth" {
description = "Service Account token"
type = string
sensitive = true
}
variable "grafana_url" {
description = "Grafana Url"
type = string
sensitive = true
}