mirror of
https://github.com/jcwimer/startup-infrastructure
synced 2026-03-24 22:34:42 +00:00
Headed in a new direction using swarm
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
group_vars/all
|
||||||
|
hosts
|
||||||
@@ -1,18 +1,23 @@
|
|||||||
---
|
---
|
||||||
# Variables listed here are applicable to all host groups
|
# Variables listed here are applicable to all host groups
|
||||||
|
|
||||||
# Software versions
|
### Software versions
|
||||||
docker_compose_version_to_install: 1.18.0
|
docker_compose_version_to_install: 1.18.0
|
||||||
docker_ce_version_to_install: 17.09.1~ce-0~ubuntu
|
docker_ce_version_to_install: 17.09.1~ce-0~ubuntu
|
||||||
|
|
||||||
# User stuff
|
### User stuff
|
||||||
default_pub_key: https://raw.githubusercontent.com/jcwimer/ubuntu-template/master/post/id_rsa.pub
|
default_pub_key: https://raw.githubusercontent.com/jcwimer/ubuntu-template/master/post/id_rsa.pub
|
||||||
standard_user: cody
|
standard_user: cody
|
||||||
git_user: "Jacob Cody Wimer"
|
git_user: "Jacob Cody Wimer"
|
||||||
git_email: "jacob.wimer@gmail.com"
|
git_email: "jacob.wimer@gmail.com"
|
||||||
chosen_timezone: "America/New_York"
|
chosen_timezone: "America/New_York"
|
||||||
|
# root domain for all services. You should have an A record for *.root_domain. For example, if your domain is test.com you should have an A record for *.test.com pointing to your node.
|
||||||
|
# this will allow automatic dns for for things like dokuwiki.test.com and portainer.test.com
|
||||||
|
root_domain: test.com
|
||||||
|
|
||||||
# Persistent storage if you are doing a single machine deploy, local is an option. If you are doing multi instance deploy, choose one of the following:
|
|
||||||
|
|
||||||
|
### Persistent storage if you are doing a single machine deploy, local is an option. If you are doing multi instance deploy, choose one of the following:
|
||||||
# nfs
|
# nfs
|
||||||
# digitalocean
|
# digitalocean
|
||||||
# gcp
|
# gcp
|
||||||
10
hosts.example
Normal file
10
hosts.example
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Node where config files get copied to and docker swarm gets initiated
|
||||||
|
# replace localhost with the ip of your bootstrap node
|
||||||
|
[bootstrap]
|
||||||
|
localhost
|
||||||
|
|
||||||
|
# nodes that will be swarm managers (note these will not host services)
|
||||||
|
[non-bootstrap-managers]
|
||||||
|
|
||||||
|
# nodes that will be swarm workers (note these will need to have more resources than managers)
|
||||||
|
[workers]
|
||||||
@@ -19,16 +19,9 @@
|
|||||||
tasks:
|
tasks:
|
||||||
- include: ../roles/common/tasks/main.yml
|
- include: ../roles/common/tasks/main.yml
|
||||||
|
|
||||||
- name: Deploy gitea
|
- name: Deploy startup-infrastructure swarm stack
|
||||||
hosts: gitea
|
hosts: bootstrap
|
||||||
user: root
|
user: root
|
||||||
serial: 100%
|
serial: 100%
|
||||||
tasks:
|
tasks:
|
||||||
- include: ../roles/gitea/tasks/main.yml
|
- include: ../roles/startup-infrastructure/tasks/main.yml
|
||||||
|
|
||||||
- name: Deploy dokuwiki
|
|
||||||
hosts: dokuwiki
|
|
||||||
user: root
|
|
||||||
serial: 100%
|
|
||||||
tasks:
|
|
||||||
- include: ../roles/dokuwiki/tasks/main.yml
|
|
||||||
6
roles/startup-infrastructure/tasks/main.yml
Normal file
6
roles/startup-infrastructure/tasks/main.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- name: Place the compose file
|
||||||
|
template: src=../roles/startup-infrastructure/templates/docker-compose.yml.j2 dest=/data/startup-infrastructure.yml
|
||||||
|
|
||||||
|
- name: Run stack deploy
|
||||||
|
shell: cd /data && docker stack deploy -c startup-infrastructure.yml startup-infrastructure
|
||||||
179
roles/startup-infrastructure/templates/docker-compose.yml.j2
Normal file
179
roles/startup-infrastructure/templates/docker-compose.yml.j2
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
version: '3.1'
|
||||||
|
networks:
|
||||||
|
appnet:
|
||||||
|
wekan:
|
||||||
|
driver: bridge
|
||||||
|
|
||||||
|
services:
|
||||||
|
traefik:
|
||||||
|
image: traefik:1.6.4
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- "443:443"
|
||||||
|
- "8081:8080"
|
||||||
|
networks:
|
||||||
|
- appnet
|
||||||
|
volumes:
|
||||||
|
- ./traefik.toml:/etc/traefik/traefik.toml
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
|
placement:
|
||||||
|
constraints:
|
||||||
|
- node.role == manager
|
||||||
|
|
||||||
|
portainer:
|
||||||
|
image: portainer/portainer
|
||||||
|
networks:
|
||||||
|
- appnet
|
||||||
|
volumes:
|
||||||
|
- portainer_data:/data
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
|
deploy:
|
||||||
|
labels:
|
||||||
|
- "traefik.frontend.entryPoints=http"
|
||||||
|
- "traefik.protocol=http"
|
||||||
|
- "traefik.backend=portainer"
|
||||||
|
- "traefik.port=9000"
|
||||||
|
- "traefik.docker.network=appnet"
|
||||||
|
- "traefik.frontend.rule=Host:portainer.{{ root_domain }}"
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
|
{% if {{ groups['workers'] | length }} > 0 %}
|
||||||
|
placement:
|
||||||
|
constraints:
|
||||||
|
- node.role == worker
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
bitwarden:
|
||||||
|
image: mprasil/bitwarden
|
||||||
|
networks:
|
||||||
|
- appnet
|
||||||
|
volumes:
|
||||||
|
- bitwarden_data:/data
|
||||||
|
deploy:
|
||||||
|
labels:
|
||||||
|
- "traefik.frontend.entryPoints=http"
|
||||||
|
- "traefik.protocol=http"
|
||||||
|
- "traefik.backend=bitwarden"
|
||||||
|
- "traefik.port=80"
|
||||||
|
- "traefik.docker.network=appnet"
|
||||||
|
- "traefik.frontend.rule=Host:bitwarden.{{ root_domain }}"
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
|
{% if {{ groups['workers'] | length }} > 0 %}
|
||||||
|
placement:
|
||||||
|
constraints:
|
||||||
|
- node.role == worker
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
gitea:
|
||||||
|
image: gitea/gitea:latest
|
||||||
|
environment:
|
||||||
|
- USER_UID=1000
|
||||||
|
- USER_GID=1000
|
||||||
|
networks:
|
||||||
|
- appnet
|
||||||
|
volumes:
|
||||||
|
- gitea_data:/data
|
||||||
|
ports:
|
||||||
|
- "2222:22"
|
||||||
|
deploy:
|
||||||
|
labels:
|
||||||
|
- "traefik.frontend.entryPoints=http"
|
||||||
|
- "traefik.protocol=http"
|
||||||
|
- "traefik.backend=git"
|
||||||
|
- "traefik.port=3000"
|
||||||
|
- "traefik.docker.network=appnet"
|
||||||
|
- "traefik.frontend.rule=Host:git.{{ root_domain }}"
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
|
{% if {{ groups['workers'] | length }} > 0 %}
|
||||||
|
placement:
|
||||||
|
constraints:
|
||||||
|
- node.role == worker
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
dokuwiki:
|
||||||
|
image: mprasil/dokuwiki
|
||||||
|
networks:
|
||||||
|
- appnet
|
||||||
|
volumes:
|
||||||
|
- dokuwiki_data:/dokuwiki
|
||||||
|
deploy:
|
||||||
|
labels:
|
||||||
|
- "traefik.frontend.entryPoints=http"
|
||||||
|
- "traefik.protocol=http"
|
||||||
|
- "traefik.backend=dokuwiki"
|
||||||
|
- "traefik.port=80"
|
||||||
|
- "traefik.docker.network=appnet"
|
||||||
|
- "traefik.frontend.rule=Host:dokuwiki.{{ root_domain }}"
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
|
{% if {{ groups['workers'] | length }} > 0 %}
|
||||||
|
placement:
|
||||||
|
constraints:
|
||||||
|
- node.role == worker
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
wekandb:
|
||||||
|
# All Wekan data is stored in MongoDB. For backup and restore, see:
|
||||||
|
# https://github.com/wekan/wekan/wiki/Export-Docker-Mongo-Data
|
||||||
|
image: mongo:3.2.21
|
||||||
|
command: mongod --smallfiles --oplogSize 128
|
||||||
|
networks:
|
||||||
|
- wekan
|
||||||
|
volumes:
|
||||||
|
- wekan-db:/data/db
|
||||||
|
- wekan-db-dump:/dump
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
|
{% if {{ groups['workers'] | length }} > 0 %}
|
||||||
|
placement:
|
||||||
|
constraints:
|
||||||
|
- node.role == worker
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
wekan:
|
||||||
|
image: quay.io/wekan/wekan
|
||||||
|
networks:
|
||||||
|
- wekan
|
||||||
|
- appnet
|
||||||
|
environment:
|
||||||
|
- ROOT_URL=http://{{ root_domain }}
|
||||||
|
- MONGO_URL=mongodb://wekandb:27017/wekan
|
||||||
|
#- MAIL_URL=smtp://user:pass@mailserver.example.com:25/
|
||||||
|
#- MAIL_FROM='Example Wekan Support <support@example.com>'
|
||||||
|
- WITH_API=true
|
||||||
|
deploy:
|
||||||
|
labels:
|
||||||
|
- "traefik.frontend.entryPoints=http"
|
||||||
|
- "traefik.protocol=http"
|
||||||
|
- "traefik.backend=wekan"
|
||||||
|
- "traefik.port=8080"
|
||||||
|
- "traefik.docker.network=appnet"
|
||||||
|
- "traefik.frontend.rule=Host:wekan.{{ root_domain }}"
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
|
{% if {{ groups['workers'] | length }} > 0 %}
|
||||||
|
placement:
|
||||||
|
constraints:
|
||||||
|
- node.role == worker
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% set docker_volumes = ['portainer_data','bitwarden_data','gitea_data','dokuwiki_data','wekan-db','wekan-db-dump'] %}
|
||||||
|
volumes:
|
||||||
|
{% for volume in docker_volumes %}
|
||||||
|
{{ volume }}:
|
||||||
|
{% if storage_type == 'nfs' %}
|
||||||
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: nfs
|
||||||
|
o: "addr={{ nfs_address }},soft,nolock,rw"
|
||||||
|
device: ":{{ nfs_root_path }}/{{ volume }}"
|
||||||
|
{% elif storage_type == 'local' %}
|
||||||
|
driver: local
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
4
supporting-scripts/deploy.sh
Normal file
4
supporting-scripts/deploy.sh
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#keep adding dirname's to go up more directories.
|
||||||
|
project_dir="$(dirname $( dirname $(readlink -f ${BASH_SOURCE[0]})))"
|
||||||
|
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook --private-key ${PRIVATE_KEY} -i ${project_dir}/hosts ${project_dir}/playbooks/multi-instance.yml
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#keep adding dirname's to go up more directories.
|
|
||||||
project_dir="$(dirname $( dirname $(readlink -f ${BASH_SOURCE[0]})))"
|
|
||||||
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ${project_dir}/multi-instance-hosts ${project_dir}/playbooks/multi-instance.yml
|
|
||||||
Reference in New Issue
Block a user