From 4d8d520ef5a9fd2a260ff76a3b7b062ba947362d Mon Sep 17 00:00:00 2001 From: Sven Velt Date: Wed, 29 Jun 2022 17:23:23 +0200 Subject: [PATCH] Quick role to install Gitea from binary on Debian --- .gitignore | 164 +++++++++++++++++++++++++++++++++++++++ README.md | 26 +++++++ tasks/main.yml | 49 ++++++++++++ tasks/prepare_debian.yml | 15 ++++ 4 files changed, 254 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 tasks/main.yml create mode 100644 tasks/prepare_debian.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc4c0c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,164 @@ +# ---> Ansible +*.retry + +# ---> Python +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# ---> Vim +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + diff --git a/README.md b/README.md new file mode 100644 index 0000000..2965c62 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# gitea-server +Install a gitea as server + +## Requirements +- None + +## Role Variables +- tbd + +## Dependencies +- None + +# Example Playbook + + - hosts: servers + roles: + - { role: gitea-server } + +## License +AGPL3.0-or-later + +## Author Information + +- Sven Velt +- https://git.velt.biz/ + diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..5faaac8 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,49 @@ +--- +- name: "INCLUDE» prepare_OS-FAMILY.yml" + include_tasks: "prepare_{{ ansible_os_family }}.yml" + +- name: Get latest version number + uri: + url: https://dl.gitea.io/gitea/version.json + register: gitea_version + +- name: Check for downloaded archive + stat: + path: /usr/local/sbin/gitea-{{ gitea_version.json.latest.version }}-linux-amd64.xz + register: gitea_archive + +- name: Check for unpacked executable + stat: + path: /usr/local/sbin/gitea-{{ gitea_version.json.latest.version }}-linux-amd64 + register: gitea_executable + +- name: Download gitea + get_url: + url: "https://dl.gitea.io/gitea/{{ gitea_version.json.latest.version }}/gitea-{{ gitea_version.json.latest.version }}-linux-amd64.xz" + dest: /usr/local/sbin/ + when: gitea_executable.stat.exists == False and gitea_archive.stat.exists == False + +- name: Uncompress archive + command: "unxz /usr/local/sbin/gitea-{{ gitea_version.json.latest.version }}-linux-amd64.xz" + when: gitea_executable.stat.exists == False + +- name: Set file mode + file: + path: "/usr/local/sbin/gitea-{{ gitea_version.json.latest.version }}-linux-amd64" + owner: root + group: root + mode: 0755 + +- name: Check for symlink + stat: + path: "/usr/local/sbin/gitea" + register: gitea_link + +- name: Set link + file: + path: "/usr/local/sbin/gitea" + src: "/usr/local/sbin/gitea-{{ gitea_version.json.latest.version }}-linux-amd64" + state: link + force: yes + when: "not(gitea_link.stat.exists and gitea_link.stat.islnk and stat.lnk_source|default('') == '/usr/local/sbin/gitea-' + gitea_version.json.latest.version + '-linux-amd64')" + diff --git a/tasks/prepare_debian.yml b/tasks/prepare_debian.yml new file mode 100644 index 0000000..3a0054c --- /dev/null +++ b/tasks/prepare_debian.yml @@ -0,0 +1,15 @@ +--- +- name: Update APT cache + apt: + update_cache: yes + cache_valid_time: 3600 + +- name: Install required packages + apt: + name: + - curl + - git + - gnupg2 + - xz-utils + state: latest +