commit 88456218626c1482cb0e77c0b2cd676ac39d8f6b Author: Denis Knauf Date: Tue Sep 15 16:43:53 2020 +0200 init diff --git a/README.adoc b/README.adoc new file mode 100644 index 0000000..9e13b72 --- /dev/null +++ b/README.adoc @@ -0,0 +1,100 @@ +Role Name +========= + +____ +Gitea - Git with a cup of tea +A painless self-hosted Git service. +Gitea is a community managed lightweight code hosting solution written in Go. It is published under the MIT license. +____ + +It installs nginx, postgresql and gitea for you git-service. + +Requirements +------------ + +You need to have debian (or compatible, like ubuntu) or alpine already installed. + +* sshd + +It will install all dependencies on host-machine: + +* Postgresql +* nginx +* gitea - itself + +It expects for TLS a PKI in `/etc/nginx/tls/`, +where you have to place `**hostname**.key`, `**hostname**.crt`. + +Role Variables +-------------- + +gitea_version:: +You need to define it, it cannot determine newest version, yet. + +gitea_download_uri:: +The URI to the binary. +You need to define it, it cannot determine newest version, yet. + +gitea_fqdn:: +Full qualified domain name for the webserver. + +gitea_root_uri:: +The Link to your gitea service. Default `https://{{gitea_fqdn}}/`. + +Example Playbook +---------------- + +This determines the newest version of gitea automatically. +So it defines `gitea_version` and `gitea_download_uri`. + +---- +--- +# vim: set expandtab tabstop=2 shiftwidth=2: + +- hosts: gitea + remote_user: root + become: false + + tasks: + - delegate_to: local + run_once: true + remote_user: root + become: false + gem: + user_install: false + name: '{{item}}' + with_items: + - oga + - httpclient + - name: determine newest provided version + delegate_to: local + become: false + run_once: true + shell: | + ruby -roga -rhttpclient < $2 OR login_source.is_actived <> $3 OR login_source.cfg <> $4; + +# EXECUTE upsert_login_source ('ldap', 5, 'true', '{"Name":"ldap","Host":"ldap.technikum-wien.at","Port":389,"SecurityProtocol":2,"SkipVerify":false,"BindDN":"ou=People,dc=technikum-wien,dc=at","BindPassword":"","UserBase":"","UserDN":"uid=%s,ou=People,dc=technikum-wien,dc=at","AttributeUsername":"uid","AttributeName":"givenName","AttributeSurname":"sn","AttributeMail":"mail","AttributesInBind":false,"Filter":"(\u0026(objectClass=posixAccount)(uid=%s))","AdminFilter":"","GroupEnabled":false,"GroupDN":"","GroupFilter":"","GroupMemberUID":"","UserUID":"","Enabled":true}'); +# failed_when: "'ERROR:' in ldap_auth_sql.stderr" +# changed_when: "'INSERT 0 0' not in ldap_auth_sql.stdout" +# register: ldap_auth_sql + +- name: create gitea-config + template: + src: gitea.ini.j2 + dest: /etc/gitea/app.ini + owner: git + +#- name: create tls-dir +# file: +# dest: '{{item}}' +# state: directory +# force: yes +# owner: root +# mode: 0700 +# with_items: +# - /etc/nginx/tls +- name: copy nginx-sites + when: '"apt" == ansible_pkg_mgr|lower' + template: + src: "nginx.j2" + dest: "/etc/nginx/sites-available/gitea" +- name: enable nginx-sites + when: '"apt" == ansible_pkg_mgr|lower' + file: + state: link + src: "../sites-available/gitea" + dest: "/etc/nginx/sites-enabled/gitea" +- name: copy nginx-sites + when: '"apk" == ansible_pkg_mgr|lower' + template: + src: "nginx.j2" + dest: "/etc/nginx/conf.d/gitea.conf" + +- name: systemctl daemon-reload + when: ansible_service_mgr == "systemd" + systemd: + daemon-reload: yes +- name: enable services + service: + name: '{{item}}' + enabled: true + state: restarted + with_items: + - nginx + - gitea diff --git a/templates/gitea.ini.j2 b/templates/gitea.ini.j2 new file mode 100644 index 0000000..63843e3 --- /dev/null +++ b/templates/gitea.ini.j2 @@ -0,0 +1,64 @@ +APP_NAME = Gitea +RUN_USER = git +RUN_MODE = prod + +[database] +DB_TYPE = postgres +HOST = /var/run/postgresql/ +NAME = gitea +USER = git +PASSWD = +SSL_MODE = disable +PATH = ../gitea.db + +[repository] +ROOT = /home/git/gitea-repositories + +[server] +DOMAIN = {{gitea_fqdn}} +# HTTP_ADDR = 127.0.0.1 +# HTTP_PORT = 1025 +PROTOCOL = unix +HTTP_ADDR = /run/gitea/sock +ROOT_URL = {{gitea_root_uri}} +DISABLE_SSH = false +SSH_PORT = 22 +START_SSH_SERVER = false +OFFLINE_MODE = false +DISABLE_ROUTER_LOG = true + +[mailer] +ENABLED = false + +[service] +REGISTER_EMAIL_CONFIRM = false +ENABLE_NOTIFY_MAIL = false +DISABLE_REGISTRATION = true +ENABLE_CAPTCHA = true +REQUIRE_SIGNIN_VIEW = false + +[picture] +DISABLE_GRAVATAR = true +ENABLE_FEDERATED_AVATAR = false + +[session] +PROVIDER = file + +[log] +MODE = file +LEVEL = Info +ROOT_PATH = /var/log/gitea + +[security] +INSTALL_LOCK = true +SECRET_KEY = UqhGAUYCwUAUfJKwHDaBgJ9GysNysL8wHeUqdKSxFbwljRaVUgFqOPkBV3AXcbL8 +INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1ODkxOTc0MDl9.eg5ukVv6gmDymYbysWXzjZeVK6-7lT2rGNZdqBMG1w0 + +[markup.asciidoc] +ENABLED = true +FILE_EXTENSIONS = .adoc,.asciidoc +RENDER_COMMAND = "asciidoctor --out-file=- --safe-mode secure --no-header-footer --backend xhtml5 -" +IS_INPUT_FILE = false + +[oauth2] +JWT_SECRET = hiNsZNEuDQGcgz68cjtGdG7ylkuuMWFXwwCg_1oICzA diff --git a/templates/nginx.j2 b/templates/nginx.j2 new file mode 100644 index 0000000..d6230c0 --- /dev/null +++ b/templates/nginx.j2 @@ -0,0 +1,35 @@ +upstream gitea { + server unix:/run/gitea/sock; +} + +server { + listen 443 ssl http2; + server_name {{ gitea_fqdn }}; + + ssl_prefer_server_ciphers on; + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers 'EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA256:EECDH:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!IDEA:!ECDSA:kEDH:CAMELLIA128-SHA:AES128-SHA'; + ssl_certificate /etc/nginx/tls/{{ansible_fqdn}}.crt; + ssl_certificate_key /etc/nginx/tls/{{ansible_fqdn}}.key; + ssl_dhparam /etc/nginx/tls/{{ansible_fqdn}}.dh; + ssl_session_timeout 5m; + add_header Strict-Transport-Security max-age=15768000; + gzip off; + + root /srv/gitea/public; + + index index.html; + location / { + proxy_pass http://gitea/; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_redirect off; + } + + error_page 500 502 503 504 /500.html; + error_page 404 /404.html; + error_page 422 /422.html; + + #log_not_found on; + #log_subrequest on; +} diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..9e83d64 --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - gitea \ No newline at end of file diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..acf5b95 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,4 @@ +--- +gitea_architectures_map: + x86_64: 'amd64' + i386: '386'