Compare commits
	
		
			2 Commits
		
	
	
		
			readme
			...
			6675f49a6e
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 6675f49a6e | |||
| 0c3503b10b | 
							
								
								
									
										35
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								README.md
									
									
									
									
									
								
							@@ -1,39 +1,25 @@
 | 
				
			|||||||
# Homelab
 | 
					# Project Moxie
 | 
				
			||||||
This repository contains Ansible to automate Debian GNU/Linux servers, deploying
 | 
					 | 
				
			||||||
server technologies that are either useful in a personal capacity or provide
 | 
					 | 
				
			||||||
educational value on automating enterprise infrastructure.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
Development is accomplished using Vagrant to allow easy reproducibility in an
 | 
					Project Moxie is a personal IT homelab project written in Ansible and executed by Jenkins. It is a growing collection of infrastructure as code (IaC) I write out of curiosity and for reference purposes, keeping a handful of beneficial projects managed and secured.
 | 
				
			||||||
isolated virtual environment that be ran on your local machine.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Quick Start
 | 
					## Quick Start
 | 
				
			||||||
These steps assume a basic understanding of GNU/Linux, Hypervisors, Vagrant, and Ansible.
 | 
					
 | 
				
			||||||
 | 
					To configure a local virtual machine for testing, follow these simple steps.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Prerequisites
 | 
					### Prerequisites
 | 
				
			||||||
- [Vagrant](https://developer.hashicorp.com/vagrant/docs/installation)
 | 
					
 | 
				
			||||||
- [Supported hypervisor](https://developer.hashicorp.com/vagrant/docs/providers)
 | 
					Vagrant and VirtualBox are used to develop Project Moxie. You will need to install these before continuing.
 | 
				
			||||||
- Ansible
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Installation
 | 
					### Installation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
1. Clone this repository
 | 
					1. Clone this repository
 | 
				
			||||||
   ```
 | 
					   ```
 | 
				
			||||||
   git clone https://git.krislamo.org/kris/homelab
 | 
					   git clone https://github.com/krislamo/moxie
 | 
				
			||||||
   ```
 | 
					 | 
				
			||||||
   OR download from the mirror on GitHub:
 | 
					 | 
				
			||||||
   ```
 | 
					 | 
				
			||||||
   git clone https://github.com/krislamo/homelab
 | 
					 | 
				
			||||||
   ```
 | 
					   ```
 | 
				
			||||||
 | 
					2. Set the `PLAYBOOK` environmental variable to a development playbook name in the `dev/` directory
 | 
				
			||||||
 | 
					
 | 
				
			||||||
2. Find available playbooks for development
 | 
					   The following `PLAYBOOK` names are available: `dockerbox`, `hypervisor`, `minecraft`, `bitwarden`, `nextcloud`, `nginx`
 | 
				
			||||||
   ```
 | 
					 | 
				
			||||||
   cd homelab
 | 
					 | 
				
			||||||
   ```
 | 
					 | 
				
			||||||
   ```
 | 
					 | 
				
			||||||
   find dev -maxdepth 1 -name "*.yml" -exec basename {} .yml \;
 | 
					 | 
				
			||||||
   ```
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
3. Set the `PLAYBOOK` environmental variable to a value listed in the last step, e.g.,
 | 
					 | 
				
			||||||
   ```
 | 
					   ```
 | 
				
			||||||
   export PLAYBOOK=dockerbox
 | 
					   export PLAYBOOK=dockerbox
 | 
				
			||||||
   ```
 | 
					   ```
 | 
				
			||||||
@@ -43,10 +29,11 @@ These steps assume a basic understanding of GNU/Linux, Hypervisors, Vagrant, and
 | 
				
			|||||||
   ```
 | 
					   ```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### Copyright and License
 | 
					#### Copyright and License
 | 
				
			||||||
Copyright (C) 2020-2022  Kris Lamoureux
 | 
					Copyright (C) 2020-2021  Kris Lamoureux
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[](https://www.gnu.org/licenses/gpl-3.0)
 | 
					[](https://www.gnu.org/licenses/gpl-3.0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.
 | 
					This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 | 
					This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,8 +7,8 @@
 | 
				
			|||||||
    - base
 | 
					    - base
 | 
				
			||||||
    - docker
 | 
					    - docker
 | 
				
			||||||
    - traefik
 | 
					    - traefik
 | 
				
			||||||
    - nextcloud
 | 
					#    - nextcloud
 | 
				
			||||||
    - gitea
 | 
					#    - gitea
 | 
				
			||||||
    - jenkins
 | 
					#    - jenkins
 | 
				
			||||||
    - prometheus
 | 
					#    - prometheus
 | 
				
			||||||
    - nginx
 | 
					#    - nginx
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,12 +1,16 @@
 | 
				
			|||||||
 | 
					# container settings
 | 
				
			||||||
traefik_name: traefik
 | 
					traefik_name: traefik
 | 
				
			||||||
traefik_dashboard: false
 | 
					traefik_standalone: true
 | 
				
			||||||
traefik_root: "/opt/{{ traefik_name }}"
 | 
					traefik_debug: false
 | 
				
			||||||
traefik_localonly: "10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 127.0.0.0/8"
 | 
					traefik_web_entry: "80:80"
 | 
				
			||||||
 | 
					traefik_websecure_entry: "443:443"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# review these options before pushing (if i can remember)
 | 
				
			||||||
traefik_production: false
 | 
					traefik_production: false
 | 
				
			||||||
traefik_hsts_enable: false
 | 
					traefik_hsts_enable: false
 | 
				
			||||||
traefik_hsts_preload: false
 | 
					traefik_hsts_preload: false
 | 
				
			||||||
traefik_hsts_seconds: 0
 | 
					traefik_hsts_seconds: 0
 | 
				
			||||||
traefik_http_redirect: false
 | 
					traefik_http_redirect: false
 | 
				
			||||||
traefik_ports:
 | 
					
 | 
				
			||||||
  - "80:80"
 | 
					# host
 | 
				
			||||||
  - "443:443"
 | 
					traefik_root: "{{ docker_compose_root }}/{{ traefik_name }}"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,11 +4,8 @@
 | 
				
			|||||||
    state: touch
 | 
					    state: touch
 | 
				
			||||||
  listen: reload_traefik
 | 
					  listen: reload_traefik
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Restart Traefik container
 | 
					- name: Restart Traefik
 | 
				
			||||||
  docker_container:
 | 
					  service:
 | 
				
			||||||
    name: "{{ traefik_name }}"
 | 
					    name: "{{ docker_compose_service }}@{{ traefik_name }}"
 | 
				
			||||||
    image: traefik:{{ traefik_version }}
 | 
					    state: restarted
 | 
				
			||||||
    state: started
 | 
					 | 
				
			||||||
    container_default_behavior: "no_defaults"
 | 
					 | 
				
			||||||
    restart: yes
 | 
					 | 
				
			||||||
  listen: restart_traefik
 | 
					  listen: restart_traefik
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,14 +1,8 @@
 | 
				
			|||||||
- name: Create Traefik configuration directories
 | 
					- name: Create Traefik directories
 | 
				
			||||||
  file:
 | 
					  file:
 | 
				
			||||||
    path: "{{ traefik_root }}/config/dynamic"
 | 
					    path: "{{ traefik_root }}/config/dynamic"
 | 
				
			||||||
    state: directory
 | 
					    state: directory
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Install static Traefik configuration
 | 
					 | 
				
			||||||
  template:
 | 
					 | 
				
			||||||
    src: traefik.yml.j2
 | 
					 | 
				
			||||||
    dest: "{{ traefik_root }}/config/traefik.yml"
 | 
					 | 
				
			||||||
  notify: restart_traefik
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- name: Install dynamic security configuration
 | 
					- name: Install dynamic security configuration
 | 
				
			||||||
  template:
 | 
					  template:
 | 
				
			||||||
    src: security.yml.j2
 | 
					    src: security.yml.j2
 | 
				
			||||||
@@ -25,32 +19,26 @@
 | 
				
			|||||||
  loop: "{{ traefik_external }}"
 | 
					  loop: "{{ traefik_external }}"
 | 
				
			||||||
  when: traefik_external is defined
 | 
					  when: traefik_external is defined
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Create Traefik network
 | 
					- name: Install Traefik's docker-compose file
 | 
				
			||||||
  docker_network:
 | 
					  template:
 | 
				
			||||||
    name: traefik
 | 
					    src: docker-compose.yml.j2
 | 
				
			||||||
 | 
					    dest: "{{ traefik_root }}/docker-compose.yml"
 | 
				
			||||||
 | 
					  notify: restart_traefik
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Start Traefik container
 | 
					- name: Install Traefik's docker-compose variables
 | 
				
			||||||
  docker_container:
 | 
					  template:
 | 
				
			||||||
    name: "{{ traefik_name }}"
 | 
					    src: compose-env.j2
 | 
				
			||||||
    image: traefik:{{ traefik_version }}
 | 
					    dest: "{{ traefik_root }}/.env"
 | 
				
			||||||
 | 
					  notify: restart_traefik
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: Install static Traefik configuration
 | 
				
			||||||
 | 
					  template:
 | 
				
			||||||
 | 
					    src: traefik.yml.j2
 | 
				
			||||||
 | 
					    dest: "{{ traefik_root }}/config/traefik.yml"
 | 
				
			||||||
 | 
					  notify: restart_traefik
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: Start and enable Traefik service
 | 
				
			||||||
 | 
					  service:
 | 
				
			||||||
 | 
					    name: "{{ docker_compose_service }}@{{ traefik_name }}"
 | 
				
			||||||
    state: started
 | 
					    state: started
 | 
				
			||||||
    restart_policy: always
 | 
					    enabled: true
 | 
				
			||||||
    ports: "{{ traefik_ports }}"
 | 
					 | 
				
			||||||
    container_default_behavior: "no_defaults"
 | 
					 | 
				
			||||||
    networks_cli_compatible: "false"
 | 
					 | 
				
			||||||
    networks:
 | 
					 | 
				
			||||||
      - name: traefik
 | 
					 | 
				
			||||||
    labels:
 | 
					 | 
				
			||||||
      traefik.http.routers.traefik.rule: "Host(`{{ traefik_domain }}`)"
 | 
					 | 
				
			||||||
      #traefik.http.middlewares.auth.basicauth.users: "{{ traefik_auth }}"
 | 
					 | 
				
			||||||
      #traefik.http.middlewares.localonly.ipwhitelist.sourcerange: "{{ traefik_localonly }}"
 | 
					 | 
				
			||||||
      #traefik.http.routers.traefik.tls.certresolver: letsencrypt
 | 
					 | 
				
			||||||
      #traefik.http.routers.traefik.middlewares: "securehttps@file,auth@docker,localonly"
 | 
					 | 
				
			||||||
      traefik.http.routers.traefik.service: "api@internal"
 | 
					 | 
				
			||||||
      traefik.http.routers.traefik.entrypoints: websecure
 | 
					 | 
				
			||||||
      traefik.http.routers.traefik.tls: "true"
 | 
					 | 
				
			||||||
      traefik.docker.network: traefik
 | 
					 | 
				
			||||||
      traefik.enable: "{{ traefik_dashboard | string }}"
 | 
					 | 
				
			||||||
    volumes:
 | 
					 | 
				
			||||||
      - /var/run/docker.sock:/var/run/docker.sock
 | 
					 | 
				
			||||||
      - "{{ traefik_root }}/config:/etc/traefik"
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										8
									
								
								roles/traefik/templates/compose-env.j2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								roles/traefik/templates/compose-env.j2
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					# {{ ansible_managed }}
 | 
				
			||||||
 | 
					traefik_version={{ traefik_version }}
 | 
				
			||||||
 | 
					traefik_name={{ traefik_name }}
 | 
				
			||||||
 | 
					traefik_domain={{ gitea_domain }}
 | 
				
			||||||
 | 
					traefik_dashboard={{ traefik_dashboard | string | lower }}
 | 
				
			||||||
 | 
					traefik_debug={{ traefik_debug | string | lower }}
 | 
				
			||||||
 | 
					traefik_web_entry={{ traefik_web_entry }}
 | 
				
			||||||
 | 
					traefik_websecure_entry={{ traefik_websecure_entry }}
 | 
				
			||||||
							
								
								
									
										42
									
								
								roles/traefik/templates/docker-compose.yml.j2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								roles/traefik/templates/docker-compose.yml.j2
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
				
			|||||||
 | 
					version: '3.7'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					networks:
 | 
				
			||||||
 | 
					  traefik:
 | 
				
			||||||
 | 
					    name: traefik
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					services:
 | 
				
			||||||
 | 
					  traefik:
 | 
				
			||||||
 | 
					    image: "traefik:${traefik_version}"
 | 
				
			||||||
 | 
					    container_name: "${traefik_name}"
 | 
				
			||||||
 | 
					    command:
 | 
				
			||||||
 | 
					      - --api.dashboard=${traefik_dashboard:-false}
 | 
				
			||||||
 | 
					      - --api.debug=${traefik_debug:-false}
 | 
				
			||||||
 | 
					      - --providers.docker=true
 | 
				
			||||||
 | 
					      - --entrypoints.web.address=:80
 | 
				
			||||||
 | 
					{% if traefik_standalone %}
 | 
				
			||||||
 | 
					      - --entrypoints.web.http.redirections.entrypoint.to=websecure
 | 
				
			||||||
 | 
					      - --entrypoints.web.http.redirections.entrypoint.scheme=https
 | 
				
			||||||
 | 
					      - --entrypoints.web.http.redirections.entrypoint.permanent=true
 | 
				
			||||||
 | 
					      - --entrypoints.websecure.address=:443
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
 | 
					    ports:
 | 
				
			||||||
 | 
					      - "${traefik_web_entry:-80:80}"
 | 
				
			||||||
 | 
					{% if traefik_standalone %}
 | 
				
			||||||
 | 
					      - "${traefik_websecure_entry:-443:443}"
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
 | 
					    networks:
 | 
				
			||||||
 | 
					      - traefik
 | 
				
			||||||
 | 
					    labels:
 | 
				
			||||||
 | 
					      - "traefik.http.routers.traefik.rule=Host(`{{ traefik_domain }}`)"
 | 
				
			||||||
 | 
					      - "traefik.http.routers.traefik.service=api@internal"
 | 
				
			||||||
 | 
					{% if traefik_standalone %}
 | 
				
			||||||
 | 
					      - "traefik.http.routers.traefik.entrypoints=websecure"
 | 
				
			||||||
 | 
					      - "traefik.http.routers.traefik.tls=true"
 | 
				
			||||||
 | 
					{% else %}
 | 
				
			||||||
 | 
					      - "traefik.http.routers.traefik.entrypoints=web"
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
 | 
					      - "traefik.docker.network=traefik"
 | 
				
			||||||
 | 
					      - "traefik.enable=${traefik_dashboard:-false}"
 | 
				
			||||||
 | 
					    volumes:
 | 
				
			||||||
 | 
					      - /var/run/docker.sock:/var/run/docker.sock
 | 
				
			||||||
 | 
					      - "{{ traefik_root }}/config:/etc/traefik"
 | 
				
			||||||
		Reference in New Issue
	
	Block a user