added go-aptproxy state

This commit is contained in:
Paul 2021-11-27 13:31:34 +01:00
parent ddae2b2ac8
commit 07ebd0facd
8 changed files with 110 additions and 0 deletions

View File

@ -0,0 +1,11 @@
---
go-aptproxy:
enabled: true
install_dir: /usr/local/apps
release_dir: /usr/local/apps/releases
working_dir: /var/cache/go-aptproxy
port: 8000
mirror: https://git.paulbsd.com/paulbsd/go-aptproxy/releases/download
version: 1.0.0
os: linux
arch: amd64

View File

@ -0,0 +1,4 @@
---
include:
- .install
- .service

View File

@ -0,0 +1,26 @@
---
{%- from "go-aptproxy/map.jinja" import go-aptproxy with context %}
go-aptproxy-archive-extract:
archive.extracted:
- name: {{ go-aptproxy.release_dir }}/go-aptproxy-{{ go-aptproxy.version }}
- source: {{ go-aptproxy.mirror }}/{{ go-aptproxy.version }}/go-aptproxy-{{ go-aptproxy.version }}-{{ go-aptproxy.os }}-{{ go-aptproxy.arch }}.tar.gz
- skip_verify: true
- enforce_toplevel: false
- if_missing: {{ go-aptproxy.release_dir }}/go-aptproxy-{{ go-aptproxy.version }}
- watch_in:
- service: go-aptproxy-service
go-aptproxy-binary-symlink:
file.symlink:
- name: {{ go-aptproxy.install_dir }}/go-aptproxy
- target: {{ go-aptproxy.release_dir }}/go-aptproxy-{{ go-aptproxy.version }}
- require:
- archive: go-aptproxy-archive-extract
- watch_in:
- service: go-aptproxy-service
go-aptproxy-cleanup:
software.cleanup:
- name: go-aptproxy
- path: {{ go-aptproxy.release_dir }}
- version: {{ go-aptproxy.version }}

View File

@ -0,0 +1,3 @@
---
Linux:
os: "linux"

View File

@ -0,0 +1,14 @@
{%- import_yaml "go-aptproxy/defaults.yaml" as default_settings -%}
{%- import_yaml "go-aptproxy/kernelmap.yaml" as kernelmap -%}
{%- import_yaml "go-aptproxy/osarchmap.yaml" as osarchmap -%}
{%- set defaults = salt['grains.filter_by'](default_settings,
default='go-aptproxy',
merge=salt['grains.filter_by'](osarchmap, grain='osarch',
merge=salt['grains.filter_by'](kernelmap, grain='kernel')
)
)
-%}
{%- set go-aptproxy = salt['pillar.get']('go-aptproxy', default=defaults, merge=True) -%}

View File

@ -0,0 +1,21 @@
---
amd64:
arch: "amd64"
x86_64:
arch: "amd64"
386:
arch: "386"
arm64:
arch: "arm64"
armv6l:
arch: "arm"
armv7l:
arch: "arm"
armhf:
arch: "arm"

View File

@ -0,0 +1,17 @@
## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }}
{%- from "go-aptproxy/map.jinja" import go-aptproxy with context %}
[Unit]
Description=go-aptproxy
Documentation=https://git.paulbsd.com/paulbsd/go-aptproxy
After=network.target
[Service]
Type=simple
ExecStart={{ go-aptproxy.install_dir }}/go-aptproxy/go-aptproxy -directory {{ go-aptproxy.working_dir }} -port {{ go-aptproxy.port }}
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartForceExitStatus=SIGPIPE
KillMode=control-group
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,14 @@
---
{%- from "go-aptproxy/map.jinja" import go-aptproxy with context %}
go-aptproxy-service-file:
file.managed:
- name: /etc/systemd/system/go-aptproxy.service
- source: salt://go-aptproxy/go-aptproxy.service.j2
- user: root
- group: root
- template: jinja
go-aptproxy-service:
service.running:
- name: go-aptproxy
- enable: true