This commit is contained in:
parent
22f404b3f3
commit
58df6e58ba
2
states/repos/defaults.yaml
Normal file
2
states/repos/defaults.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
repos:
|
@ -1,38 +1,4 @@
|
||||
---
|
||||
repo-require:
|
||||
cmd.run:
|
||||
- name: apt install -y python3-apt
|
||||
|
||||
{%- 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 %}
|
||||
include:
|
||||
- .prereqs
|
||||
- .repos
|
||||
|
5
states/repos/map.jinja
Normal file
5
states/repos/map.jinja
Normal 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
8
states/repos/prereqs.sls
Normal 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
47
states/repos/repos.sls
Normal 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 %}
|
||||
|
Loading…
Reference in New Issue
Block a user