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 entrymaster
*.swp | *.swp | ||||
.kitchen |
provisioner: | provisioner: | ||||
name: salt_solo | name: salt_solo | ||||
salt_version: 2015.8.8 | salt_version: 2015.8.8 | ||||
data_path: test/shared | |||||
is_file_root: true | is_file_root: true | ||||
pillars-from-files: | |||||
apt.sls: pillar.example | |||||
pillars: | |||||
top.sls: | |||||
base: | |||||
'*': | |||||
- apt | |||||
grains: | grains: | ||||
os_family: Debian | os_family: Debian | ||||
'*': | '*': | ||||
- apt.repositories | - apt.repositories | ||||
- apt.update | - 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 |
Runs ``apt-get upgrade``. | Runs ``apt-get upgrade``. | ||||
``apt.repositories`` | ``apt.repositories`` | ||||
--------------- | |||||
-------------------- | |||||
Allows you to configure and manage repositories from pillar. Check ``pillar.example`` | 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 | to see possible values. If used and no repositories are provided, sane default | ||||
Check https://wiki.debian.org/SourcesList for an explanation about the resulting | Check https://wiki.debian.org/SourcesList for an explanation about the resulting | ||||
files structure. | 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`` | ``apt.ppa`` | ||||
------------- | |||||
----------- | |||||
Installs ``python-software-properties`` | Installs ``python-software-properties`` | ||||
(``$ /usr/bin/apt-add-repository ppa:user/repository``). | (``$ /usr/bin/apt-add-repository ppa:user/repository``). | ||||
'sources_list_dir': '/etc/apt/sources.list.d', | 'sources_list_dir': '/etc/apt/sources.list.d', | ||||
'remove_sources_list': false, | 'remove_sources_list': false, | ||||
'clean_sources_list_d': 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/', | 'default_url': 'http://httpredir.debian.org/debian/', | ||||
'repositories': { | 'repositories': { | ||||
'sane_default': { | 'sane_default': { |
{% 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 %} |
remove_sources_list: true | remove_sources_list: true | ||||
clean_sources_list_d: true | clean_sources_list_d: true | ||||
remove_preferences: true | |||||
clean_preferences_d: true | |||||
unattended: | unattended: | ||||
allowed_origins: | allowed_origins: | ||||
- origin1 | - origin1 | ||||
distro: stable-updates | distro: stable-updates | ||||
url: http://httpredir.debian.org/debian/ | url: http://httpredir.debian.org/debian/ | ||||
comps: [main, contrib, non-free] | 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] | 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 | |||||
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 |
require 'spec_helper' | |||||
require_relative '../../../kitchen/data/spec_helper' | |||||
describe 'apt.repositories' do | describe 'apt.repositories' do | ||||