Compare commits

..

3 Commits

Author SHA1 Message Date
30900bb721 testing 2022-05-25 01:26:08 -04:00
aa9aa8985b testing 2022-05-24 22:16:17 -04:00
e1c8dc55d3 testing 2022-05-24 21:15:10 -04:00
16 changed files with 103 additions and 56 deletions

View File

@ -5,7 +5,8 @@
- host_vars/proxy.yml - host_vars/proxy.yml
roles: roles:
- base - base
- postgresql
- proxy - proxy
- docker - docker
- bitwarden
- gitea - gitea
- bitwarden

View File

@ -1,5 +1,5 @@
bitwarden_name: bitwarden bitwarden_name: bitwarden
bitwarden_root: "/opt/{{ bitwarden_name }}" bitwarden_root: "{{ docker_root }}/{{ bitwarden_name }}"
bitwarden_database: "{{ bitwarden_name }}" bitwarden_database: "{{ bitwarden_name }}"
bitwarden_standalone: false bitwarden_standalone: false
bitwarden_production: false bitwarden_production: false

View File

@ -1,7 +1,16 @@
- name: Stop Bitwarden for rebuild
service:
name: "{{ bitwarden_name }}"
state: stopped
listen: rebuild_bitwarden
- name: Rebuild Bitwarden - name: Rebuild Bitwarden
shell: "{{ bitwarden_root }}/bitwarden.sh rebuild" shell: "{{ bitwarden_root }}/bitwarden.sh rebuild"
listen: rebuild_bitwarden listen: rebuild_bitwarden
- name: Start Bitwarden - name: Start Bitwarden after rebuild
shell: "{{ bitwarden_root }}/bitwarden.sh start" service:
listen: start_bitwarden name: "{{ bitwarden_name }}"
state: started
enabled: true
listen: rebuild_bitwarden

View File

@ -25,16 +25,13 @@
shell: "{{ bitwarden_root }}/bw_wrapper" shell: "{{ bitwarden_root }}/bw_wrapper"
args: args:
creates: "{{ bitwarden_root }}/bwdata/config.yml" creates: "{{ bitwarden_root }}/bwdata/config.yml"
notify: start_bitwarden
- name: Install docker-compose override - name: Install docker-compose override
template: template:
src: compose.override.yml.j2 src: compose.override.yml.j2
dest: "{{ bitwarden_root }}/bwdata/docker/docker-compose.override.yml" dest: "{{ bitwarden_root }}/bwdata/docker/docker-compose.override.yml"
when: traefik_version is defined when: traefik_version is defined
notify: notify: rebuild_bitwarden
- rebuild_bitwarden
- start_bitwarden
- name: Disable bitwarden-nginx HTTP on 80 - name: Disable bitwarden-nginx HTTP on 80
replace: replace:
@ -42,9 +39,7 @@
regexp: "^http_port: 80$" regexp: "^http_port: 80$"
replace: "http_port: 8080" replace: "http_port: 8080"
when: not bitwarden_standalone when: not bitwarden_standalone
notify: notify: rebuild_bitwarden
- rebuild_bitwarden
- start_bitwarden
- name: Disable bitwarden-nginx HTTPS on 443 - name: Disable bitwarden-nginx HTTPS on 443
replace: replace:
@ -52,9 +47,7 @@
regexp: "^https_port: 443$" regexp: "^https_port: 443$"
replace: "https_port: 8443" replace: "https_port: 8443"
when: not bitwarden_standalone when: not bitwarden_standalone
notify: notify: rebuild_bitwarden
- rebuild_bitwarden
- start_bitwarden
- name: Disable Bitwarden managed Lets Encrypt - name: Disable Bitwarden managed Lets Encrypt
replace: replace:
@ -62,9 +55,7 @@
regexp: "^ssl_managed_lets_encrypt: true$" regexp: "^ssl_managed_lets_encrypt: true$"
replace: "ssl_managed_lets_encrypt: false" replace: "ssl_managed_lets_encrypt: false"
when: not bitwarden_standalone or not bitwarden_production when: not bitwarden_standalone or not bitwarden_production
notify: notify: rebuild_bitwarden
- rebuild_bitwarden
- start_bitwarden
- name: Disable Bitwarden managed SSL - name: Disable Bitwarden managed SSL
replace: replace:
@ -72,6 +63,17 @@
regexp: "^ssl: true$" regexp: "^ssl: true$"
replace: "ssl: false" replace: "ssl: false"
when: not bitwarden_standalone when: not bitwarden_standalone
notify: notify: rebuild_bitwarden
- rebuild_bitwarden
- start_bitwarden - name: Install Bitwarden systemd service
template:
src: bitwarden.service.j2
dest: "/etc/systemd/system/{{ bitwarden_name }}.service"
register: bitwarden_systemd
notify: rebuild_bitwarden
- name: Reload systemd manager configuration
systemd:
daemon_reload: true
when: bitwarden_systemd.changed
notify: rebuild_bitwarden

View File

@ -0,0 +1,13 @@
[Unit]
Description=Bitwarden Password Manager Server
PartOf=docker.service
After=docker.service
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart={{ bitwarden_root }}/bitwarden.sh start
ExecStop={{ bitwarden_root }}/bitwarden.sh stop
[Install]
WantedBy=multi-user.target

View File

@ -1 +1,3 @@
docker_root: /var/lib/docker-compose
docker_compose: /usr/bin/docker-compose docker_compose: /usr/bin/docker-compose
docker_compose_service: compose

View File

@ -4,6 +4,22 @@
state: present state: present
update_cache: true update_cache: true
- name: Create docker-compose root
file:
path: "{{ docker_root }}"
state: directory
- name: Install docker-compose systemd service
template:
src: docker-compose.service.j2
dest: "/etc/systemd/system/{{ docker_compose_service }}@.service"
register: compose_systemd
- name: Reload systemd manager configuration
systemd:
daemon_reload: true
when: compose_systemd.changed
- name: Add users to docker group - name: Add users to docker group
user: user:
name: "{{ item }}" name: "{{ item }}"

View File

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=%i docker service Description=%i docker-compose service
PartOf=docker.service PartOf=docker.service
After=docker.service After=docker.service

View File

@ -3,6 +3,8 @@ gitea_name: gitea
gitea_sshport: "222" gitea_sshport: "222"
gitea_webport: "3000" gitea_webport: "3000"
gitea_volume: "{{ gitea_name }}" gitea_volume: "{{ gitea_name }}"
gitea_rooturl: "http://{{ gitea_domain }}"
gitea_signup: true
# database settings # database settings
gitea_dbtype: postgres gitea_dbtype: postgres
@ -11,4 +13,4 @@ gitea_dbname: "{{ gitea_name }}"
gitea_dbuser: "{{ gitea_name }}" gitea_dbuser: "{{ gitea_name }}"
# host # host
gitea_root: "/opt/{{ gitea_name }}" gitea_root: "{{ docker_root }}/{{ gitea_name }}"

View File

@ -1,4 +0,0 @@
- name: Reload systemd manager configuration
systemd:
daemon_reload: true
listen: gitea_systemd

View File

@ -3,6 +3,16 @@
path: "{{ gitea_root }}" path: "{{ gitea_root }}"
state: directory state: directory
- name: Create gitea database
postgresql_db:
name: "{{ gitea_dbname }}"
- name: Create gitea database user
postgresql_user:
db: "{{ gitea_dbname }}"
name: "{{ gitea_dbuser }}"
password: "{{ gitea_dbpass }}"
- name: Install Gitea's docker-compose file - name: Install Gitea's docker-compose file
template: template:
src: docker-compose.yml.j2 src: docker-compose.yml.j2
@ -13,19 +23,8 @@
src: compose-env.j2 src: compose-env.j2
dest: "{{ gitea_root }}/.env" dest: "{{ gitea_root }}/.env"
- name: Install Gitea systemd service - name: Start and enable Gitea service
template:
src: gitea.service.j2
dest: "/etc/systemd/system/{{ gitea_name }}.service"
register: gitea_systemd
- name: Reload systemd manager configuration
systemd:
daemon_reload: true
when: gitea_systemd.changed
- name: Start and enable Gitea
service: service:
name: "{{ gitea_name }}" name: "{{ docker_compose_service }}@{{ gitea_name }}"
state: started state: started
enabled: true enabled: true

View File

@ -1,6 +1,8 @@
# {{ ansible_managed }} # {{ ansible_managed }}
gitea_version={{ gitea_version }} gitea_version={{ gitea_version }}
gitea_name={{ gitea_name }} gitea_name={{ gitea_name }}
gitea_domain={{ gitea_domain }}
gitea_rooturl={{ gitea_rooturl }}
gitea_webport={{ gitea_webport }} gitea_webport={{ gitea_webport }}
gitea_sshport={{ gitea_sshport }} gitea_sshport={{ gitea_sshport }}
gitea_dbtype={{ gitea_dbtype }} gitea_dbtype={{ gitea_dbtype }}
@ -8,3 +10,8 @@ gitea_dbhost={{ gitea_dbhost }}
gitea_dbname={{ gitea_dbname }} gitea_dbname={{ gitea_dbname }}
gitea_dbuser={{ gitea_dbuser }} gitea_dbuser={{ gitea_dbuser }}
gitea_dbpass={{ gitea_dbpass }} gitea_dbpass={{ gitea_dbpass }}
{% if not gitea_signup %}
gitea_disable_registration=true
{% else %}
gitea_disable_registration=false
{% endif %}

View File

@ -5,17 +5,22 @@ services:
image: "gitea/gitea:${gitea_version}" image: "gitea/gitea:${gitea_version}"
container_name: "${gitea_name}" container_name: "${gitea_name}"
ports: ports:
- "${gitea_webport}:3000"
- "${gitea_sshport}:22" - "${gitea_sshport}:22"
- "127.0.0.1:5432:5432" - "127.0.0.1:${gitea_webport}:3000"
extra_hosts:
- "host.docker.internal:host-gateway"
environment: environment:
- USER_UID=1000 - USER_UID=1000
- USER_GID=1000 - USER_GID=1000
- GITEA__server__ROOT_URL=${gitea_rooturl}
- GITEA__server__DOMAIN=${gitea_domain}
- GITEA__server__SSH_DOMAIN=${gitea_domain}
- GITEA__database__DB_TYPE=${gitea_dbtype} - GITEA__database__DB_TYPE=${gitea_dbtype}
- GITEA__database__HOST=${gitea_dbhost} - GITEA__database__HOST=${gitea_dbhost}
- GITEA__database__NAME=${gitea_dbname} - GITEA__database__NAME=${gitea_dbname}
- GITEA__database__USER=${gitea_dbuser} - GITEA__database__USER=${gitea_dbuser}
- GITEA__database__PASSWD=${gitea_dbpass} - GITEA__database__PASSWD=${gitea_dbpass}
- GITEA__service__DISABLE_REGISTRATION=${gitea_disable_registration}
volumes: volumes:
- {{ gitea_volume }}:/data - {{ gitea_volume }}:/data
- /etc/timezone:/etc/timezone:ro - /etc/timezone:/etc/timezone:ro

View File

@ -1,14 +0,0 @@
[Unit]
Description=Gitea Docker Service
PartOf=docker.service
After=docker.service
[Service]
Type=oneshot
RemainAfterExit=true
WorkingDirectory={{ gitea_root }}/
ExecStart={{ docker_compose }} up -d --remove-orphans
ExecStop={{ docker_compose }} down
[Install]
WantedBy=multi-user.target

View File

@ -62,6 +62,7 @@
file: file:
path: /etc/letsencrypt/renewal-hooks/post path: /etc/letsencrypt/renewal-hooks/post
state: directory state: directory
when: proxy.production is defined and proxy.production
- name: Install nginx post renewal hook - name: Install nginx post renewal hook
copy: copy:

View File

@ -1,3 +1,11 @@
{% if item.https is not defined or item.https %}
server {
listen 80;
server_name {{ item.domain }};
return 301 https://{{ item.domain }}$request_uri;
}
{% endif %}
server { server {
listen 443 ssl; listen 443 ssl;
server_name {{ item.domain }}; server_name {{ item.domain }};