Quellcode durchsuchen

Add apt's preferences mgmt

Ignore .kitchen dir

Add defaults for preferences mgmt

Add some pillar examples for preferences mgmt

Add tests for preferences

Add entries in the README file

Missing map.jinja entry
master
Javier Bértoli vor 8 Jahren
Ursprung
Commit
6f7022fc56
9 geänderte Dateien mit 152 neuen und 33 gelöschten Zeilen
  1. +1
    -0
      .gitignore
  2. +14
    -21
      .kitchen.yml
  3. +12
    -2
      README.rst
  4. +4
    -0
      apt/map.jinja
  5. +38
    -0
      apt/preferences.sls
  6. +34
    -9
      pillar.example
  7. +48
    -0
      test/integration/preferences/serverspec/preferences_spec.rb
  8. +1
    -1
      test/integration/repositories/serverspec/repositories_spec.rb
  9. +0
    -0
      test/shared/spec_helper.rb

+ 1
- 0
.gitignore Datei anzeigen

@@ -1 +1,2 @@
*.swp
.kitchen

+ 14
- 21
.kitchen.yml Datei anzeigen

@@ -10,7 +10,15 @@ platforms:
provisioner:
name: salt_solo
salt_version: 2015.8.8
data_path: test/shared
is_file_root: true
pillars-from-files:
apt.sls: pillar.example
pillars:
top.sls:
base:
'*':
- apt
grains:
os_family: Debian

@@ -22,24 +30,9 @@ suites:
'*':
- apt.repositories
- apt.update
pillars:
top.sls:
base:
'*':
- apt
apt.sls:
apt:
remove_sources_list: true
clean_sources_list_d: true
repositories:
debian-jessie:
distro: jessie
url: http://httpredir.debian.org/debian
type: [source]
comps: [main, contrib, non-free]
dropbox:
distro: jessie
url: http://linux.dropbox.com/debian
arch: [i386, amd64]
keyid: 1C61A2656FB57B7E4DE0F4C1FC918B335044912E
keyserver: pgp.mit.edu
- name: preferences
provisioner:
state_top:
base:
'*':
- apt.preferences

+ 12
- 2
README.rst Datei anzeigen

@@ -30,7 +30,7 @@ Runs ``apt-get update``.
Runs ``apt-get upgrade``.

``apt.repositories``
---------------
--------------------

Allows you to configure and manage repositories from pillar. Check ``pillar.example``
to see possible values. If used and no repositories are provided, sane default
@@ -39,8 +39,18 @@ values from ``map.jinja`` are used.
Check https://wiki.debian.org/SourcesList for an explanation about the resulting
files structure.

``apt.preferences``
-------------------

Allows you to configure and manage apt's preferences from pillar. Check
``pillar.example`` to see possible values. If used and no repositories are
provided, sane default values from ``map.jinja`` are used.

Check https://wiki.debian.org/AptPreferences?action=show&redirect=preferences
and ``man 5 apt_preferences`` for an explanation about the resulting files structure.

``apt.ppa``
-------------
-----------
Installs ``python-software-properties``
(``$ /usr/bin/apt-add-repository ppa:user/repository``).


+ 4
- 0
apt/map.jinja Datei anzeigen

@@ -10,6 +10,10 @@
'sources_list_dir': '/etc/apt/sources.list.d',
'remove_sources_list': false,
'clean_sources_list_d': false,
'preferences_dir': '/etc/apt/preferences.d',
'remove_preferences': false,
'clean_preferences_d': false,
'default_keyserver': 'pool.sks-keyservers.net',
'default_url': 'http://httpredir.debian.org/debian/',
'repositories': {
'sane_default': {

+ 38
- 0
apt/preferences.sls Datei anzeigen

@@ -0,0 +1,38 @@
{% from "apt/map.jinja" import apt as apt_map with context %}
{% set apt = pillar.get('apt', {}) %}
{% set remove_preferences = apt.get('remove_preferences', apt_map.remove_preferences) %}
{% set clean_preferences_d = apt.get('clean_preferences_d', apt_map.clean_preferences_d) %}
{% set preferences_dir = apt.get('preferences_dir', apt_map.preferences_dir) %}
{% set preferences = apt.get('preferences', apt_map.preferences) %}
{% set default_url = apt.get('default_url', apt_map.default_url) %}

/etc/apt/preferences:
{% if remove_preferences %}
file.absent
{% else %}
file.managed:
- mode: '0644'
- user: root
- group: root
{% endif %}

{{ preferences_dir }}:
file.directory:
- mode: '0755'
- user: root
- group: root
- clean: {{ clean_preferences_d }}

{% for pref_file, args in preferences.iteritems() %}
{%- set p_package = args.package if args.package is defined else '*' %}

{{ preferences_dir }}/{{ pref_file }}:
file.managed:
- mode: '0644'
- user: root
- group: root
- contents:
- "{{ 'Package: ' ~ p_package }}"
- "{{ 'Pin: ' ~ args.pin }}"
- "{{ 'Pin-Priority: ' ~ args.priority }}"
{% endfor %}

+ 34
- 9
pillar.example Datei anzeigen

@@ -2,6 +2,9 @@ apt:
remove_sources_list: true
clean_sources_list_d: true

remove_preferences: true
clean_preferences_d: true

unattended:
allowed_origins:
- origin1
@@ -35,13 +38,35 @@ apt:
distro: stable-updates
url: http://httpredir.debian.org/debian/
comps: [main, contrib, non-free]
my-fancy-repo:
distro: whatever/is/needed/here
url: http://my.repo.url
raspbian:
distro: wheezy
url: http://archive.raspbian.org/raspbian
type: [source]
key_url: https://archive.raspbian.org/raspbian.public.key
debian-jessie:
distro: jessie
url: http://httpredir.debian.org/debian
type: [source]
key_url: http://my.repo.url/GPG-KEY-my.repo
perconap-repo:
distro: stable
url: http://repo.percona.com/apt
keyid: CD2EFD2A
keyserver: pool.sks-keyservers.net
comps: [main, contrib, non-free]
dropbox:
distro: jessie
url: http://linux.dropbox.com/debian
arch: [i386, amd64]
keyid: 1C61A2656FB57B7E4DE0F4C1FC918B335044912E
keyserver: pgp.mit.edu

preferences:
00-rspamd:
package: rspamd
pin: origin rspamd.com
priority: 650
01-all:
pin: release stable
priority: 610
02-all:
pin: release testing
priority: 600
03-all:
pin: release unstable
priority: 50


+ 48
- 0
test/integration/preferences/serverspec/preferences_spec.rb Datei anzeigen

@@ -0,0 +1,48 @@
require_relative '../../../kitchen/data/spec_helper'

describe 'apt.preferences' do

describe file('/etc/apt/preferences') do
it { should_not exist }
end

describe file('/etc/apt/preferences.d') do
it { should be_directory }
it { should be_mode 755 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/etc/apt/preferences.d/00-rspamd') do
it { should exist }
it { should be_mode 644 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content) { should match("Package: rspamd\nPin: origin rspamd.com\nPin-Priority: 650\n") }
end

describe file('/etc/apt/preferences.d/01-all') do
it { should exist }
it { should be_mode 644 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content) { should match("Package: *\nPin: release stable\nPin-Priority: 610\n") }
end

describe file('/etc/apt/preferences.d/02-all') do
it { should exist }
it { should be_mode 644 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content) { should match("Package: *\nPin: release testing\nPin-Priority: 600\n") }
end

describe file('/etc/apt/preferences.d/03-all') do
it { should exist }
it { should be_mode 644 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content) { should match("Package: *\nPin: release unstable\nPin-Priority: 50\n") }
end

end

+ 1
- 1
test/integration/repositories/serverspec/repositories_spec.rb Datei anzeigen

@@ -1,4 +1,4 @@
require 'spec_helper'
require_relative '../../../kitchen/data/spec_helper'

describe 'apt.repositories' do


test/integration/repositories/serverspec/spec_helper.rb → test/shared/spec_helper.rb Datei anzeigen


Laden…
Abbrechen
Speichern