Added a basic setup with package install, config, and service management
This commit is contained in:
parent
ab178945d1
commit
fe72021f00
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
|||||||
Copyright (c) <year> <owner>
|
Copyright (c) 2023 Metaunix.net
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
20
README.md
20
README.md
@ -1,3 +1,21 @@
|
|||||||
# gitea-formula
|
# gitea-formula
|
||||||
|
|
||||||
Formula to manage Gitea installations
|
Formula to manage Gitea installations
|
||||||
|
|
||||||
|
## Available States
|
||||||
|
|
||||||
|
### gitea
|
||||||
|
|
||||||
|
Includes all of the states required to install, configure, and start the Gitea service.
|
||||||
|
|
||||||
|
### gitea.package
|
||||||
|
|
||||||
|
Installs the gitea package.
|
||||||
|
|
||||||
|
### gitea.config
|
||||||
|
|
||||||
|
Configures the gitea application.
|
||||||
|
|
||||||
|
### gitea.service
|
||||||
|
|
||||||
|
Ensures the gitea service is running.
|
||||||
|
18
gitea/config/file.sls
Normal file
18
gitea/config/file.sls
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
|
{%- set sls_package_install = tplroot ~ '.package.install' %}
|
||||||
|
{%- from tplroot ~ "/map.jinja" import gitea with context %}
|
||||||
|
|
||||||
|
include:
|
||||||
|
- {{ sls_package_install }}
|
||||||
|
|
||||||
|
gitea_config_file:
|
||||||
|
file.managed:
|
||||||
|
- name: {{ gitea.config_path }}
|
||||||
|
- user: {{ gitea.config_owner }}
|
||||||
|
- group: {{ gitea.config_group }}
|
||||||
|
- mode: {{ gitea.config_mode }}
|
||||||
|
- require:
|
||||||
|
- sls: {{ sls_package_install }}
|
5
gitea/config/init.sls
Normal file
5
gitea/config/init.sls
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
include:
|
||||||
|
- .file
|
12
gitea/defaults.yaml
Normal file
12
gitea/defaults.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=yaml
|
||||||
|
|
||||||
|
gitea:
|
||||||
|
pkg_manage_repo: False
|
||||||
|
pkg_name: 'gitea'
|
||||||
|
config_path: '/etc/gitea/app.ini'
|
||||||
|
config_owner: 'gitea'
|
||||||
|
config_group: 'gitea'
|
||||||
|
config_mode: 0644
|
||||||
|
service_name: 'gitea'
|
||||||
|
service_enabled: True
|
4
gitea/init.sls
Normal file
4
gitea/init.sls
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
include:
|
||||||
|
- .package
|
||||||
|
- .config
|
||||||
|
- .service
|
32
gitea/map.jinja
Normal file
32
gitea/map.jinja
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=jinja
|
||||||
|
|
||||||
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
|
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
|
||||||
|
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
|
||||||
|
|
||||||
|
{#- Retrieve the config dict only once #}
|
||||||
|
{%- set _config = salt['config.get'](tplroot, default={}) %}
|
||||||
|
|
||||||
|
{%- set defaults = salt['grains.filter_by'](
|
||||||
|
default_settings,
|
||||||
|
default=tplroot,
|
||||||
|
merge=salt['grains.filter_by'](
|
||||||
|
osfamilymap,
|
||||||
|
grain='os_family',
|
||||||
|
merge=salt['grains.filter_by'](
|
||||||
|
_config,
|
||||||
|
default='lookup'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
%}
|
||||||
|
|
||||||
|
{%- set config = salt['grains.filter_by'](
|
||||||
|
{'defaults': defaults},
|
||||||
|
default='defaults',
|
||||||
|
merge=_config
|
||||||
|
)
|
||||||
|
%}
|
||||||
|
|
||||||
|
{%- set gitea = config %}
|
5
gitea/osfamilymap.yaml
Normal file
5
gitea/osfamilymap.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=yaml
|
||||||
|
|
||||||
|
FreeBSD:
|
||||||
|
config_path: '/usr/local/etc/gitea/app.ini'
|
5
gitea/package/init.sls
Normal file
5
gitea/package/init.sls
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
include:
|
||||||
|
- .install
|
17
gitea/package/install.sls
Normal file
17
gitea/package/install.sls
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
|
{%- from tplroot ~ "/map.jinja" import gitea with context %}
|
||||||
|
gitea_pkg_install:
|
||||||
|
pkg.installed:
|
||||||
|
- name: {{ gitea.pkg_name }}
|
||||||
|
group.present:
|
||||||
|
- name: {{ gitea.config_group }}
|
||||||
|
- system: True
|
||||||
|
user.present:
|
||||||
|
- name: {{ gitea.config_owner }}
|
||||||
|
- gid: {{ gitea.config_group }}
|
||||||
|
- system: True
|
||||||
|
|
||||||
|
{%- endif %}
|
5
gitea/service/init.sls
Normal file
5
gitea/service/init.sls
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
include:
|
||||||
|
- .running
|
16
gitea/service/running.sls
Normal file
16
gitea/service/running.sls
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
|
{%- set sls_config_file = tplroot ~ '.config.file' %}
|
||||||
|
{%- from tplroot ~ "/map.jinja" import gitea with context %}
|
||||||
|
|
||||||
|
include:
|
||||||
|
- {{ sls_config_file }}
|
||||||
|
|
||||||
|
gitea_service:
|
||||||
|
service.running:
|
||||||
|
- name: {{ gitea.service_name }}
|
||||||
|
- enable: {{ gitea.service_enabled }}
|
||||||
|
- watch:
|
||||||
|
- sls: {{ sls_config_file }}
|
Loading…
Reference in New Issue
Block a user