Browse Source

Fix global proxy processing

* Fix processing disabled repo
   * Extend tests for such case

Change-Id: Ib3243f2b3e70aecef65273be215b30613b8df025
Closes-Bug: PROD-21954 (PROD:21954)
pull/138/head
azvyagintsev 6 years ago
parent
commit
45cf452dbb
2 changed files with 29 additions and 28 deletions
  1. +20
    -28
      linux/system/repo.sls
  2. +9
    -0
      tests/pillar/system.sls

+ 20
- 28
linux/system/repo.sls View File

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


# global proxy setup # global proxy setup
{%- if system.proxy.get('pkg', {}).get('enabled', False) %}
{%- if grains.os_family == 'Debian' %}

{%- if grains.os_family == 'Debian' %}
{%- if system.proxy.get('pkg', {}).get('enabled', False) %}
/etc/apt/apt.conf.d/99proxies-salt: /etc/apt/apt.conf.d/99proxies-salt:
file.managed: file.managed:
- template: jinja - template: jinja
/etc/apt/apt.conf.d/99proxies-salt: /etc/apt/apt.conf.d/99proxies-salt:
file.absent file.absent
{%- endif %} {%- endif %}
{%- else %}
# Implement grobal proxy configiration for non-debian OS.
{%- endif %} {%- endif %}


{% set default_repos = {} %} {% set default_repos = {} %}
- name: /etc/apt/preferences.d/{{ name }} - name: /etc/apt/preferences.d/{{ name }}
{%- endif %} {%- endif %}


{%- if repo.get('key') %} {# 2 #}
{%- if repo.get('key') %}
linux_repo_{{ name }}_key: linux_repo_{{ name }}_key:
cmd.run: cmd.run:
- name: | - name: |
- key_url: {{ repo.key_url }} - key_url: {{ repo.key_url }}
{%- endif %} {%- endif %}
- consolidate: {{ repo.get('consolidate', False) }} - consolidate: {{ repo.get('consolidate', False) }}
{%- if repo.get('proxy', {}).get('enabled', False) or system.proxy.get('pkg', {}).get('enabled', False) or system.purge_repos|default(False) %}
- require: - require:
{%- 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) %}
- file: /etc/apt/apt.conf.d/99proxies-salt - file: /etc/apt/apt.conf.d/99proxies-salt
{%- endif %}
{%- if system.purge_repos|default(False) %}
{%- 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 }}:
pkgrepo.absent: pkgrepo.absent:
- refresh_db: False - refresh_db: False
- require:
- file: /etc/apt/apt.conf.d/99proxies-salt-{{ name }}
- require_in: - require_in:
- refresh_db - refresh_db
{%- if repo.ppa is defined %} {%- if repo.ppa is defined %}
- keyid: {{ repo.key_id }} - keyid: {{ repo.key_id }}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
file.absent:
- name: /etc/apt/sources.list.d/{{ name }}.list
file.absent:
- name: /etc/apt/apt.conf.d/99proxies-salt-{{ name }}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}


{%- if grains.os_family == "RedHat" %}

{%- if repo.get('enabled', True) %}
{%- if grains.os_family == "RedHat" %}


{%- if repo.get('proxy', {}).get('enabled', False) %}
{%- if repo.get('enabled', True) %}
{%- if repo.get('proxy', {}).get('enabled', False) %}
# PLACEHOLDER # PLACEHOLDER
# TODO, implement per proxy configuration for Yum # TODO, implement per proxy configuration for Yum
{%- endif %}
{%- endif %}


{%- 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 - refresh_db: False
- refresh_db - 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 %}
- mirrorlist: {{ repo.mirrorlist }} - mirrorlist: {{ repo.mirrorlist }}
{%- else %}
{%- else %}
- baseurl: {{ repo.source }} - baseurl: {{ repo.source }}
{%- endif %}
{%- endif %}
- 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 %} {%- endif %}
{%- else %}
{%- else %}
pkgrepo.absent: pkgrepo.absent:
- refresh_db: False - refresh_db: False
- require_in: - require_in:
- refresh_db - 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' %}

+ 9
- 0
tests/pillar/system.sls View File

htop: htop:
version: latest version: latest
repo: repo:
disabled_repo:
source: "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
enabled: false
disabled_repo_left_proxy:
source: "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
enabled: false
proxy:
enabled: true
https: https://127.0.5.1:443
opencontrail: opencontrail:
source: "deb http://ppa.launchpad.net/tcpcloud/contrail-3.0/ubuntu xenial main" source: "deb http://ppa.launchpad.net/tcpcloud/contrail-3.0/ubuntu xenial main"
keyid: E79EE90C keyid: E79EE90C

Loading…
Cancel
Save