Compare commits

...

2 commits

Author SHA1 Message Date
7c220a5501 fix #2 2023-04-13 11:43:42 +02:00
74a4de1615 virtualize (#3)
Reviewed-on: https://git.pim.kunis.nl/home/max/pulls/3
2023-04-12 21:26:46 +00:00
14 changed files with 153 additions and 39 deletions

37
.gitignore vendored
View file

@ -1 +1,38 @@
# Local .terraform directories
**/.terraform/*
# .tfstate files
*.tfstate
*.tfstate.*
# Crash log files
crash.log
crash.*.log
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json
# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json
# Include override files you do wish to add to version control using negated pattern
# !example_override.tf
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
# Ignore CLI configuration files
.terraformrc
terraform.rc
.terraform.lock.hcl
*.tfbackend
.vault_password .vault_password

View file

@ -1,5 +1,4 @@
[defaults] [defaults]
# (pathspec) Colon separated paths in which Ansible will search for Roles.
roles_path=~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:roles roles_path=~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:roles
inventory=inventory inventory=inventory
vault_password_file=util/secret-service-client.sh vault_password_file=util/secret-service-client.sh

30
data/main.tf Normal file
View file

@ -0,0 +1,30 @@
terraform {
backend "pg" {
schema_name = "max-data"
conn_str = "postgres://terraform@10.42.0.1/terraform_state"
}
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
}
}
}
provider "libvirt" {
uri = "qemu+ssh://root@atlas.lan/system"
}
resource "libvirt_volume" "data" {
name = "max-data"
pool = "data"
size = 1024 * 1024 * 1024 * 65
lifecycle {
prevent_destroy = true
}
}
output "data_disk_id" {
value = libvirt_volume.data.id
}

View file

@ -1,4 +1,4 @@
base_data_dir: /data base_data_dir: /mnt/data
base_service_dir: /srv base_service_dir: /srv
# Additional open ports # Additional open ports

View file

@ -1,7 +1,5 @@
all: all:
children: hosts:
homeserver: max:
hosts: ansible_user: root
max: ansible_host: max.dmz
ansible_user: root
ansible_host: max.dmz

26
main.tf Normal file
View file

@ -0,0 +1,26 @@
terraform {
backend "pg" {
schema_name = "max"
conn_str = "postgres://terraform@10.42.0.1/terraform_state"
}
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
}
}
}
provider "libvirt" {
uri = "qemu+ssh://root@atlas.lan/system"
}
module "tf-datatest" {
source = "git::https://git.pim.kunis.nl/home/tf-modules.git//debian"
name = "max"
domain_name = "tf-max"
data_disk = "/kvm/data/max-data"
#ansible_command = "ansible-playbook max.yml"
memory = 1024 * 8
mac = "CA:FE:C0:FF:EE:03"
}

25
max.yml
View file

@ -1,7 +1,26 @@
- name: Setup homeserver - name: Setup homeserver
hosts: homeserver hosts: max
gather_facts: no
pre_tasks:
- name: Wait for host to come up
wait_for:
state: started
port: 22
host: max.dmz
timeout: 300
connect_timeout: 300
search_regex: OpenSSH
delegate_to: localhost
- name: Wait for cloud-init to finish
shell:
cmd: "cloud-init status --wait"
register: cloudinit
changed_when: "'..' in cloudinit.stdout"
- name: Gather facts
setup:
roles: roles:
- {role: 'ssh', tags: 'ssh'}
- {role: 'watchtower', tags: 'watchtower'} - {role: 'watchtower', tags: 'watchtower'}
- {role: 'forgejo', tags: 'forgejo'} - {role: 'forgejo', tags: 'forgejo'}
- {role: 'syncthing', tags: 'syncthing'} - {role: 'syncthing', tags: 'syncthing'}
@ -11,7 +30,7 @@
- {role: 'mastodon', tags: 'mastodon'} - {role: 'mastodon', tags: 'mastodon'}
- {role: 'seafile', tags: 'seafile'} - {role: 'seafile', tags: 'seafile'}
- {role: 'jitsi', tags: 'jitsi'} - {role: 'jitsi', tags: 'jitsi'}
- {role: 'freshrss', tags: 'freshrss'} # - {role: 'freshrss', tags: 'freshrss'}
- {role: 'static', tags: 'static'} - {role: 'static', tags: 'static'}
- {role: 'inbucket', tags: 'inbucket'} - {role: 'inbucket', tags: 'inbucket'}
- {role: 'prometheus', tags: 'prometheus'} - {role: 'prometheus', tags: 'prometheus'}

View file

@ -1,5 +0,0 @@
nameserver 192.168.30.7
nameserver 192.168.30.1
nameserver 1.1.1.1
nameserver 1.0.0.1
search lan

View file

@ -9,13 +9,9 @@
file: file:
path: "{{ base_service_dir }}" path: "{{ base_service_dir }}"
state: directory state: directory
- name: Disable systemd-resolved - name: Delete externally managed environment file
systemd: shell:
name: systemd-resolved cmd: "rm /usr/lib/python*/EXTERNALLY-MANAGED"
enabled: false register: rm
state: stopped changed_when: "rm.rc == 0"
- name: Copy resolv.conf failed_when: "false"
copy:
src: "{{ role_path }}/files/resolv.conf"
dest: /etc/resolv.conf
follow: true

View file

@ -12,7 +12,7 @@
keyring: /etc/apt/keyrings/docker.gpg keyring: /etc/apt/keyrings/docker.gpg
- name: Add Docker repository - name: Add Docker repository
apt_repository: apt_repository:
repo: "deb [signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable" repo: "deb [signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
register: apt_repository register: apt_repository
- name: Update APT cache - name: Update APT cache
apt: apt:

View file

@ -9,7 +9,7 @@ stock = utf-8
[auth] [auth]
realm = Radicale - Password Required realm = Radicale - Password Required
type = htpasswd type = htpasswd
htpasswd_filename = /radicale/users htpasswd_filename = /config/users
htpasswd_encryption = md5 htpasswd_encryption = md5
[rights] [rights]

View file

@ -13,7 +13,7 @@
- name: Copy radicale.conf - name: Copy radicale.conf
copy: copy:
src: "{{ role_path }}/files/radicale.conf" src: "{{ role_path }}/files/radicale.conf"
dest: "{{ service_dir }}/config/radicale.conf" dest: "{{ service_dir }}/config/config"
- name: Copy users file - name: Copy users file
copy: copy:
src: "{{ role_path }}/files/users" src: "{{ role_path }}/files/users"

View file

@ -1,18 +1,28 @@
version: '3' version: '3.7'
networks:
traefik:
external: true
services: services:
radicale: radicale:
restart: always image: tomsquest/docker-radicale
image: mailu/radicale:1.9
container_name: radicale container_name: radicale
init: true
read_only: true
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
cap_add:
- SETUID
- SETGID
- CHOWN
- KILL
healthcheck:
test: curl -f http://127.0.0.1:5232 || exit 1
interval: 30s
retries: 3
restart: unless-stopped
volumes: volumes:
- {{ data_dir }}:/data - {{ data_dir }}:/data
- {{ service_dir }}/config:/radicale - {{ service_dir }}/config:/config:ro
command: radicale -S -C /radicale/radicale.conf
networks: networks:
- traefik - traefik
labels: labels:
@ -23,3 +33,7 @@ services:
- traefik.http.routers.radicale.tls.certresolver=letsencrypt - traefik.http.routers.radicale.tls.certresolver=letsencrypt
- traefik.http.routers.radicale.service=radicale - traefik.http.routers.radicale.service=radicale
- traefik.http.services.radicale.loadbalancer.server.port=5232 - traefik.http.services.radicale.loadbalancer.server.port=5232
networks:
traefik:
external: true

View file

@ -1,3 +1,3 @@
service_name: static service_name: static
service_dir: "{{ base_service_dir }}/{{ service_name }}" service_dir: "{{ base_service_dir }}/{{ service_name }}"
git_origin: "http://localhost:{{ internal_forgejo_port }}/pim/static.git" git_origin: "http://git.pim.kunis.nl/pim/static.git"