From fa615c5c92506b1aafd78eaa7d83e92e79fa0690 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Wed, 9 Oct 2019 19:28:34 -0400 Subject: [PATCH] first stab --- files/apache.config | 10 +++++++ files/gitea.service | 36 ++++++++++++++++++++++++ handlers/main.yml | 3 ++ tasks/main.yml | 68 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 files/apache.config create mode 100644 files/gitea.service create mode 100644 handlers/main.yml create mode 100644 tasks/main.yml diff --git a/files/apache.config b/files/apache.config new file mode 100644 index 0000000..0c8f44e --- /dev/null +++ b/files/apache.config @@ -0,0 +1,10 @@ + + ServerName git.babyl.ca + ServerAlias git.babyl.ca + + ProxyPass / http://localhost:8085/ + ProxyPassReverse / http://localhost:8085/ + + CustomLog ${APACHE_LOG_DIR}/git.log combined + + diff --git a/files/gitea.service b/files/gitea.service new file mode 100644 index 0000000..339f5f3 --- /dev/null +++ b/files/gitea.service @@ -0,0 +1,36 @@ +[Unit] +Description=Gitea (Git with a cup of tea) +After=syslog.target +After=network.target +#Requires=mysql.service +#Requires=mariadb.service +#Requires=postgresql.service +#Requires=memcached.service +#Requires=redis.service + +[Service] +# Modify these two values and uncomment them if you have +# repos with lots of files and get an HTTP error 500 because +# of that +### +#LimitMEMLOCK=infinity +#LimitNOFILE=65535 +RestartSec=2s +Type=simple +User=gitea +Group=gitea +WorkingDirectory=/home/gitea/ +# If using unix socket: Tells Systemd to create /run/gitea folder to home gitea.sock +# Manual cration would vanish after reboot. +#RuntimeDirectory=gitea +ExecStart=/home/gitea/bin/gitea web -c /home/gitea/custom/conf/app.ini +Restart=always +Environment=USER=gitea HOME=/home/gitea GITEA_WORK_DIR=/home/gitea +# If you want to bind Gitea to a port below 1024 uncomment +# the two values below +### +#CapabilityBoundingSet=CAP_NET_BIND_SERVICE +#AmbientCapabilities=CAP_NET_BIND_SERVICE + +[Install] +WantedBy=multi-user.target diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..2356a12 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,3 @@ +- name: restart apache + service: name=apache2 state=restarted + become: yes diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..f9f1d9f --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,68 @@ +- name: add gitea user + become: yes + user: + name: gitea + +- name: create sub-directories + become: yes + file: + path: /home/gitea/{{item}} + state: directory + owner: gitea + loop: + - log + - data + - custom + - bin + + +- name: d/l gitea + become: yes + get_url: + mode: a+x + dest: /home/gitea/bin/gitea + url: https://dl.gitea.io/gitea/1.9.4/gitea-1.9.4-linux-386 + +- name: workdir in bash + become: yes + become_user: gitea + lineinfile: + path: /home/gitea/.bashrc + regexp: GITEA_WORK_DIR + line: export GITEA_WORK_DIR=/home/gitea + backup: yes + +- name: install service + become: yes + copy: + dest: /etc/systemd/system/gitea.service + src: files/gitea.service + force: no + backup: yes + +- name: enable service + become: yes + systemd: + state: started + name: gitea.service + enabled: yes + +- name: apache config + become: yes + template: + dest: /etc/apache2/sites-available/gitea + src: files/apache.config + force: no + backup: yes + +- name: enable apache config + become: yes + notify: restart apache + file: + path: /etc/apache2/sites-enabled/gitea + force: no + src: /etc/apache2/sites-available/gitea + state: link + +# running from the command line: +# GITEA_WORK_DIR=/var/lib/gitea/ /usr/local/bin/gitea web -c /etc/gitea/app.ini