Quick role to install Gitea from binary on Debian

This commit is contained in:
Sven Velt 2022-06-29 17:23:23 +02:00
commit 4d8d520ef5
4 changed files with 254 additions and 0 deletions

164
.gitignore vendored Normal file
View file

@ -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~

26
README.md Normal file
View file

@ -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 <sven-ansiblerole@velt.biz>
- https://git.velt.biz/

49
tasks/main.yml Normal file
View file

@ -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')"

15
tasks/prepare_debian.yml Normal file
View file

@ -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