init
This commit is contained in:
commit
8ab79633ec
12 changed files with 207 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.vagrant
|
19
LICENSE
Normal file
19
LICENSE
Normal file
|
@ -0,0 +1,19 @@
|
|||
MIT License Copyright (c) 2021 "Stichting Disroot.org"
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
9
Playbooks/timetagger.yml
Normal file
9
Playbooks/timetagger.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
|
||||
- hosts: timetagger
|
||||
roles:
|
||||
- nginx
|
||||
- timetagger
|
||||
|
||||
vars_files:
|
||||
- ../defaults/main.yml
|
23
README.md
Normal file
23
README.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Timetagger - Ansible Role
|
||||
|
||||
This role covers deployment, configuration and software updates of Timetagger. This role is released under MIT Licence and we give no warranty for this piece of software. Currently supported OS - Debian.
|
||||
|
||||
You can deploy test instance using `Vagrantfile` attached to the role.
|
||||
|
||||
`vagrant up`
|
||||
|
||||
`ansible-playbook -b Playbooks/timetagger.yml`
|
||||
|
||||
Then you can access Roundcube from your computer on http://192.168.33.55
|
||||
|
||||
|
||||
## Playbook
|
||||
The playbook includes nginx, php-fpm and mariadb roles and deploys entire stack needed to run Timetagger. Additional roles are also available in the Ansible roles repos in git.
|
||||
|
||||
|
||||
## Create credentials
|
||||
Go to http://192.168.33.55/timetagger/cred or use your favourite BCrypt tool. Then edit `timetagger_credentials` va in `defaults/main.yml`
|
||||
|
||||
|
||||
## CHANGELOG
|
||||
- **33.07.2023** - Create the role
|
18
Vagrantfile
vendored
Normal file
18
Vagrantfile
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||
# configures the configuration version (we support older styles for
|
||||
# backwards compatibility). Please don't change it unless you know what
|
||||
# you're doing.
|
||||
Vagrant.configure("2") do |config|
|
||||
#config.ssh.insert_key = false
|
||||
config.vm.define "timetagger" do |timetagger|
|
||||
timetagger.vm.box = "generic/debian11"
|
||||
timetagger.vm.provider :libvirt do |libvirt|
|
||||
libvirt.memory = 256
|
||||
end
|
||||
timetagger.vm.network "private_network", ip: "192.168.33.55"
|
||||
config.vm.provision "shell", inline: "apt install acl"
|
||||
end
|
||||
end
|
50
defaults/main.yml
Normal file
50
defaults/main.yml
Normal file
|
@ -0,0 +1,50 @@
|
|||
---
|
||||
|
||||
timetagger_user: 'timetagger'
|
||||
timetagger_group: 'timetagger'
|
||||
timetagger_venv_path: '/home/{{ timetagger_user }}/timetagger_venv'
|
||||
timetagger_pkg:
|
||||
- python3-pip
|
||||
- virtualenv
|
||||
- python3-venv
|
||||
timetagger_pip_pkgs:
|
||||
- setuptools
|
||||
- wheel
|
||||
- pip
|
||||
- pyyaml
|
||||
|
||||
timetagger_bind_address: '0.0.0.0:8080' # default is 80 but it doesn't work if not root
|
||||
timetagger_datadir: '{{ timetagger_venv_path }}/_timetagger'
|
||||
timetagger_loglevel: 'info'
|
||||
timetagger_credentials:
|
||||
- username: 'user'
|
||||
hash_password: '$2a$08$8AqCRIXQ4TLuusrzmjHxJu0UJN1PyyPqxexZRHuTpJtiHMx.DbcFO' #user:changeme
|
||||
- username: 'user2'
|
||||
hash_password: '$2a$08$8AqCRIXQ4TLuusrzmjHxJu0UJN1PyyPqxexZRHuTpJtiHMx.DbcFO' #user2:changeme
|
||||
|
||||
|
||||
#nginx vhosts
|
||||
nginx_default_vhost: 'timetagger'
|
||||
nginx_default_vhost_ssl: 'timetagger'
|
||||
nginx_gen_dh: 'false'
|
||||
ssl_src_path: '/etc/letsencrypt/live'
|
||||
|
||||
nginx_vhosts:
|
||||
- name: 'timetagger'
|
||||
template: 'proxy'
|
||||
upstream_proto: 'http'
|
||||
upstream_port: '8080'
|
||||
upstream_name: '127.0.0.1'
|
||||
proto: 'http'
|
||||
listen: '80'
|
||||
#ssl_name: 'timetagger.localhost'
|
||||
secure_site: 'true'
|
||||
secure_cookie: 'true'
|
||||
#header_sameorigin: 'true'
|
||||
use_error_log: 'true'
|
||||
nginx_error_log_level: 'warn'
|
||||
use_access_log: 'false'
|
||||
redirect_https: 'true'
|
||||
letsencrypt: 'false'
|
||||
nginx_HSTS_policy: 'true'
|
||||
state: 'enable'
|
17
tasks/installapp.yml
Normal file
17
tasks/installapp.yml
Normal file
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
|
||||
- name: '[INSTALL] - Create the initial virtualenv, install and update pip and setuptools'
|
||||
pip:
|
||||
name: "{{ timetagger_pip_pkgs }}"
|
||||
virtualenv: '{{ timetagger_venv_path }}/'
|
||||
virtualenv_site_packages: yes
|
||||
become: yes
|
||||
become_user: '{{timetagger_user }}'
|
||||
|
||||
- name: '[INSTALL] - Install timetagger'
|
||||
pip:
|
||||
name: timetagger
|
||||
virtualenv: '{{ timetagger_venv_path }}'
|
||||
#virtualenv_site_packages: yes
|
||||
become: yes
|
||||
become_user: '{{ timetagger_user }}'
|
6
tasks/installdeps.yml
Normal file
6
tasks/installdeps.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
|
||||
- name: '[INSTALLDEP] - Install Dependencies'
|
||||
apt:
|
||||
name: "{{ timetagger_pkg }}"
|
||||
update_cache: yes
|
13
tasks/main.yml
Normal file
13
tasks/main.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
|
||||
- name: Add user
|
||||
include_tasks: user.yml
|
||||
|
||||
- name: Install dependencies
|
||||
include_tasks: installdeps.yml
|
||||
|
||||
- name: Install the app
|
||||
include_tasks: installapp.yml
|
||||
|
||||
- name: Deploy systemd
|
||||
include_tasks: systemd.yml
|
18
tasks/systemd.yml
Normal file
18
tasks/systemd.yml
Normal file
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
|
||||
- name: "[SYSTEMD] - Deploy Systemd config"
|
||||
template:
|
||||
src: etc/systemd/system/timetagger.service.j2
|
||||
dest: /etc/systemd/system/timetagger.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
register: timetagger
|
||||
|
||||
- name: "[SYSTEMD] - Enable systemd"
|
||||
service:
|
||||
name: timetagger
|
||||
state: restarted
|
||||
enabled: yes
|
||||
daemon_reload: true
|
||||
when: timetagger.changed
|
12
tasks/user.yml
Normal file
12
tasks/user.yml
Normal file
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
|
||||
- name: "[USER] - Add group"
|
||||
group:
|
||||
name: '{{ timetagger_group }}'
|
||||
state: present
|
||||
|
||||
- name: "[USER] - Add user timetagger"
|
||||
user:
|
||||
name: '{{ timetagger_user }}'
|
||||
shell: /bin/bash
|
||||
group: '{{ timetagger_group }}'
|
21
templates/etc/systemd/system/timetagger.service.j2
Normal file
21
templates/etc/systemd/system/timetagger.service.j2
Normal file
|
@ -0,0 +1,21 @@
|
|||
[Unit]
|
||||
Description=Timetagger to track your working time
|
||||
Documentation=https://github.com/almarklein/timetagger
|
||||
Requires=network.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Environment="TIMETAGGER_BIND={{ timetagger_bind_address }}"
|
||||
Environment="TIMETAGGER_DATADIR={{ timetagger_datadir }}"
|
||||
Environment="TIMETAGGER_LOG_LEVEL={{ timetagger_loglevel }}"
|
||||
Environment="TIMETAGGER_CREDENTIALS={% for item in timetagger_credentials %}{{ item.username }}:{{ item.hash_password }},{% endfor %}"
|
||||
|
||||
Type=simple
|
||||
User={{ timetagger_user }}
|
||||
ExecStart={{ timetagger_venv_path }}/bin/python3 -m timetagger
|
||||
#WorkingDirectory={{ timetagger_datadir }}
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in a new issue