updated repos state
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Paul 2022-10-01 20:12:26 +02:00
parent 22f404b3f3
commit 58df6e58ba
5 changed files with 65 additions and 37 deletions

View File

@ -0,0 +1,2 @@
---
repos:

View File

@ -1,38 +1,4 @@
--- ---
repo-require: include:
cmd.run: - .prereqs
- name: apt install -y python3-apt - .repos
{%- for repo in pillar.get('repos') %}
{%- if repo['enabled'] %}
repo-{{ repo['name'] }}:
pkgrepo.managed:
- humanname: {{ repo['humanname'] }}
{%- if repo['ppa'] %}
- ppa: {{ repo['ppasrc'] }}
- dist: {{ repo['dist'] }}
{%- elif not repo['ppa'] %}
- name: {{ repo['src'] }}
- gpgcheck: {{ repo['gpgcheck']|default(1) }}
- file: {{ repo['file'] }}
- clean_file: true
{%- if repo['key_method'] is defined %}
{%- if repo['key_method'] == 'file' %}
- key_url: {{ repo['key_url'] }}
{%- elif repo['key_method'] == 'server' %}
- keyid: {{ repo['keyid'] }}
- keyserver: {{ repo['keyserver'] }}
{%- endif %}
{%- endif %}
{%- endif %}
{%- else %}
repo-{{ repo['name'] }}:
file.absent:
{%- if not repo['ppa'] %}
- name: {{ repo['file'] }}
{%- endif %}
{%- endif %}
{%- endfor %}

5
states/repos/map.jinja Normal file
View File

@ -0,0 +1,5 @@
{%- import_yaml "repos/defaults.yaml" as default_settings -%}
{%- set defaults = salt['grains.filter_by'](default_settings, default='repos') -%}
{%- set repos = salt['pillar.get']('repos', default=defaults, merge=True) -%}

8
states/repos/prereqs.sls Normal file
View File

@ -0,0 +1,8 @@
---
repo-pkg-require:
cmd.run:
- name: apt install -y python3-apt
repo-pkg-keyrings-dir:
file.directory:
- name: /etc/apt/keyrings

47
states/repos/repos.sls Normal file
View File

@ -0,0 +1,47 @@
---
{%- from "repos/map.jinja" import repos with context %}
{%- for repo in repos %}
{%- if repo.enabled %}
{%- if repo.key_method is defined %}
{%- if repo.key_method == 'file' %}
repo-key-{{ repo.name }}:
file.managed:
- name: /etc/apt/keyrings/{{ repo.name }}
- source: {{ repo.key_url }}
- skip_verify: true
{% endif %}
{% endif %}
repo-{{ repo.name }}:
pkgrepo.managed:
- humanname: {{ repo.humanname }}
{%- if repo.ppa %}
- ppa: {{ repo.ppasrc }}
- dist: {{ repo.dist }}
{%- else %}
- name: deb [signed-by=/etc/apt/keyrings/{{ repo.name }}] {{ repo.src }} {{ repo.suites }} {{ repo.components }}
- gpgcheck: {{ repo.gpgcheck|default(1) }}
- aptkey: false
- file: {{ repo.file }}
- clean_file: true
{%- if repo.key_method is defined %}
{%- if repo.key_method == 'file' %}
- key_url: {{ repo.key_url }}
{%- elif repo.key_method == 'server' %}
- keyid: {{ repo.keyid }}
- keyserver: {{ repo.keyserver }}
{%- endif %}
{%- endif %}
{%- endif %}
{%- else %}
repo-{{ repo.name }}:
file.absent:
{%- if not repo.ppa %}
- name: {{ repo.file }}
{%- endif %}
{%- endif %}
{%- endfor %}