瀏覽代碼

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 年之前
父節點
當前提交
45cf452dbb
共有 2 個檔案被更改,包括 29 行新增28 行删除
  1. +20
    -28
      linux/system/repo.sls
  2. +9
    -0
      tests/pillar/system.sls

+ 20
- 28
linux/system/repo.sls 查看文件

@@ -8,9 +8,8 @@ linux_repo_prereq_pkgs:
{%- endif %}

# 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:
file.managed:
- template: jinja
@@ -24,6 +23,8 @@ linux_repo_prereq_pkgs:
/etc/apt/apt.conf.d/99proxies-salt:
file.absent
{%- endif %}
{%- else %}
# Implement grobal proxy configiration for non-debian OS.
{%- endif %}

{% set default_repos = {} %}
@@ -70,7 +71,7 @@ linux_repo_{{ name }}_pin:
- name: /etc/apt/preferences.d/{{ name }}
{%- endif %}

{%- if repo.get('key') %} {# 2 #}
{%- if repo.get('key') %}
linux_repo_{{ name }}_key:
cmd.run:
- name: |
@@ -135,23 +136,19 @@ linux_repo_{{ name }}:
- key_url: {{ repo.key_url }}
{%- endif %}
- 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:
{%- if repo.get('proxy', {}).get('enabled', False) %}
- 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
{%- endif %}
{%- if system.purge_repos|default(False) %}
{%- if system.purge_repos|default(False) %}
- file: purge_sources_list_d_repos
{%- endif %}
{%- endif %}
{%- endif %}
{%- else %}
linux_repo_{{ name }}_absent:
linux_repo_{{ name }}:
pkgrepo.absent:
- refresh_db: False
- require:
- file: /etc/apt/apt.conf.d/99proxies-salt-{{ name }}
- require_in:
- refresh_db
{%- if repo.ppa is defined %}
@@ -165,24 +162,19 @@ linux_repo_{{ name }}_absent:
- keyid: {{ repo.key_id }}
{%- 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 %}

{%- 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
# TODO, implement per proxy configuration for Yum
{%- endif %}
{%- endif %}

{%- if not repo.get('default', False) %}
{%- if not repo.get('default', False) %}
linux_repo_{{ name }}:
pkgrepo.managed:
- refresh_db: False
@@ -190,24 +182,24 @@ linux_repo_{{ name }}:
- refresh_db
- name: {{ name }}
- humanname: {{ repo.get('humanname', name) }}
{%- if repo.mirrorlist is defined %}
{%- if repo.mirrorlist is defined %}
- mirrorlist: {{ repo.mirrorlist }}
{%- else %}
{%- else %}
- baseurl: {{ repo.source }}
{%- endif %}
{%- endif %}
- gpgcheck: {% if repo.get('gpgcheck', False) %}1{% else %}0{% endif %}
{%- if repo.gpgkey is defined %}
{%- if repo.gpgkey is defined %}
- gpgkey: {{ repo.gpgkey }}
{%- endif %}
{%- endif %}
{%- else %}
{%- else %}
pkgrepo.absent:
- refresh_db: False
- require_in:
- refresh_db
- name: {{ repo.source }}
{%- endif %}
{%- endif %}
{%- endif %}
{%- endfor %}

{%- if default_repos|length > 0 and grains.os_family == 'Debian' %}

+ 9
- 0
tests/pillar/system.sls 查看文件

@@ -126,6 +126,15 @@ linux:
htop:
version: latest
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:
source: "deb http://ppa.launchpad.net/tcpcloud/contrail-3.0/ubuntu xenial main"
keyid: E79EE90C

Loading…
取消
儲存