Bläddra i källkod

Merge "Fix|change system.repo update logic"

pull/163/head
Vasyl Saienko 6 år sedan
förälder
incheckning
c6f75efb50
2 ändrade filer med 60 tillägg och 25 borttagningar
  1. +27
    -0
      README.rst
  2. +33
    -25
      linux/system/repo.sls

+ 27
- 0
README.rst Visa fil

priority: 900 priority: 900
package: '*' package: '*'


.. note:: For old ubuntu releases (<xenial)
extra packages for apt transport, like ``apt-transport-https``
may be required to be installed manually.
(Chicken-eggs problem: we need to install packages to
reach repo from where they should be installed)
Otherwise, you still can try 'fortune' and install prereq.packages before
any repo configuration, using list of requires in map.jinja.


Disabling any prerequirment packages installation:
You can simply drop any package pre-installation (before system.linux.repo
will be processed) via cluster lvl:

.. code-block:: yaml

linux:
system:
pkgs: ~



Package manager proxy setup globally: Package manager proxy setup globally:


system: system:
purge_repos: true purge_repos: true


Refresh repositories metada, after configuration:

.. code-block:: yaml

linux:
system:
refresh_repos_meta: true

Setup custom apt config options: Setup custom apt config options:


.. code-block:: yaml .. code-block:: yaml

+ 33
- 25
linux/system/repo.sls Visa fil

{%- from "linux/map.jinja" import system with context %} {%- from "linux/map.jinja" import system with context %}
{%- if system.enabled %} {%- if system.enabled %}


{% if system.pkgs %}
linux_repo_prereq_pkgs: linux_repo_prereq_pkgs:
pkg.installed: pkg.installed:
- pkgs: {{ system.pkgs }} - pkgs: {{ system.pkgs }}
{%- endif %}


# global proxy setup # global proxy setup
{%- if system.proxy.get('pkg', {}).get('enabled', False) %} {%- if system.proxy.get('pkg', {}).get('enabled', False) %}
{%- if repo.get('enabled', True) %} {%- if repo.get('enabled', True) %}
linux_repo_{{ name }}: linux_repo_{{ name }}:
pkgrepo.managed: pkgrepo.managed:
- refresh_db: False
- require_in:
- refresh_db
{%- if repo.ppa is defined %} {%- if repo.ppa is defined %}
- ppa: {{ repo.ppa }} - ppa: {{ repo.ppa }}
{%- else %} {%- else %}
- architectures: {{ repo.architectures }} - architectures: {{ repo.architectures }}
{%- endif %} {%- endif %}
- file: /etc/apt/sources.list.d/{{ name }}.list - file: /etc/apt/sources.list.d/{{ name }}.list
- clean_file: {{ repo.clean|default(True) }}
- clean_file: {{ repo.get('clean_file', True) }}
{%- if repo.key_id is defined %} {%- if repo.key_id is defined %}
- keyid: {{ repo.key_id }} - keyid: {{ repo.key_id }}
{%- endif %} {%- endif %}
- key_url: {{ repo.key_url }} - key_url: {{ repo.key_url }}
{%- endif %} {%- endif %}
- consolidate: {{ repo.get('consolidate', False) }} - consolidate: {{ repo.get('consolidate', False) }}
- clean_file: {{ repo.get('clean_file', False) }}
- refresh_db: {{ repo.get('refresh_db', True) }}
{%- if repo.get('proxy', {}).get('enabled', False) or system.proxy.get('pkg', {}).get('enabled', False) or system.purge_repos|default(False) %}
- require: - require:
# FIXME remove this usless part
- pkg: linux_repo_prereq_pkgs
{%- if repo.get('proxy', {}).get('enabled', False) %}
{%- if repo.get('proxy', {}).get('enabled', False) %}
- file: /etc/apt/apt.conf.d/99proxies-salt-{{ name }} - file: /etc/apt/apt.conf.d/99proxies-salt-{{ name }}
{%- endif %}
{%- if system.proxy.get('pkg', {}).get('enabled', False) %}
{%- endif %}
{%- if system.proxy.get('pkg', {}).get('enabled', False) %}
- file: /etc/apt/apt.conf.d/99proxies-salt - file: /etc/apt/apt.conf.d/99proxies-salt
{%- endif %}
{%- if system.purge_repos|default(False) %}
{%- endif %}
{%- if system.purge_repos|default(False) %}
- file: purge_sources_list_d_repos - file: purge_sources_list_d_repos
{%- endif %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- else %} {%- else %}
linux_repo_{{ name }}_absent: linux_repo_{{ name }}_absent:
pkgrepo.absent: pkgrepo.absent:
- refresh_db: False
- require_in:
- refresh_db
{%- if repo.ppa is defined %} {%- if repo.ppa is defined %}
- ppa: {{ repo.ppa }} - ppa: {{ repo.ppa }}
{%- if repo.key_id is defined %} {%- if repo.key_id is defined %}
{%- endif %} {%- endif %}
file.absent: file.absent:
- name: /etc/apt/sources.list.d/{{ name }}.list - name: /etc/apt/sources.list.d/{{ name }}.list
file.absent:
- name: /etc/apt/apt.conf.d/99proxies-salt-{{ name }}
{%- endif %} {%- endif %}
{%- endif %} {# 1 #}

{%- endif %}
{%- endif %} {%- endif %}


{%- if grains.os_family == "RedHat" %} {%- if grains.os_family == "RedHat" %}
{%- if not repo.get('default', False) %} {%- if not repo.get('default', False) %}
linux_repo_{{ name }}: linux_repo_{{ name }}:
pkgrepo.managed: pkgrepo.managed:
- refresh_db: False
- require_in:
- refresh_db
- name: {{ name }} - name: {{ name }}
- humanname: {{ repo.get('humanname', name) }} - humanname: {{ repo.get('humanname', name) }}
{%- if repo.mirrorlist is defined %} {%- if repo.mirrorlist is defined %}
- gpgcheck: {% if repo.get('gpgcheck', False) %}1{% else %}0{% endif %} - gpgcheck: {% if repo.get('gpgcheck', False) %}1{% else %}0{% endif %}
{%- if repo.gpgkey is defined %} {%- if repo.gpgkey is defined %}
- gpgkey: {{ repo.gpgkey }} - gpgkey: {{ repo.gpgkey }}
{%- endif %}
{%- endif %} {%- endif %}
- require:
- pkg: linux_repo_prereq_pkgs
{%- endif %}

{%- else %} {%- else %}
pkgrepo.absent: pkgrepo.absent:
- refresh_db: False
- require_in:
- refresh_db
- name: {{ repo.source }} - name: {{ repo.source }}
{%- endif %} {%- endif %}

{%- endif %} {%- endif %}

{%- endfor %} {%- endfor %}


{%- if default_repos|length > 0 and grains.os_family == 'Debian' %} {%- if default_repos|length > 0 and grains.os_family == 'Debian' %}
{%- endif %} {%- endif %}
- defaults: - defaults:
default_repos: {{ default_repos }} default_repos: {{ default_repos }}
- require:
- pkg: linux_repo_prereq_pkgs


refresh_default_repo:
module.wait:
- name: pkg.refresh_db
- watch:
- file: default_repo_list
{%- endif %}


refresh_db:
{%- if system.get('refresh_repos_meta', True) %}
module.run:
- name: pkg.refresh_db
{%- else %}
test.succeed_without_changes
{%- endif %} {%- endif %}


{%- endif %} {%- endif %}

Laddar…
Avbryt
Spara