1
0
Fork 0
mirror of synced 2024-12-21 13:41:08 -05:00

Merge pull request #36 from netmanagers/master

Make sure dependencies are installed if required, fix tests
This commit is contained in:
Niels Abspoel 2018-10-26 19:02:24 +02:00 committed by GitHub
commit 8ee4d19eb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 173 additions and 20 deletions

103
.gitignore vendored Normal file
View file

@ -0,0 +1,103 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a packager
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.kitchen
.kitchen.local.yml
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# dotenv
.env
# virtualenv
.venv
venv/
ENV/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/

View file

@ -8,4 +8,13 @@ services:
before_install: before_install:
- bundle install - bundle install
script: bundle exec kitchen verify env:
matrix:
- INSTANCE: default-debian-9
- INSTANCE: default-ubuntu-1804
- INSTANCE: default-fedora-27
- INSTANCE: default-centos-7
script:
- bundle exec kitchen verify ${INSTANCE}

View file

@ -3,6 +3,7 @@
{% from "logrotate/map.jinja" import logrotate with context %} {% from "logrotate/map.jinja" import logrotate with context %}
{% set pkgs = [logrotate.pkg] if logrotate.pkg is string else logrotate.pkg %}
logrotate-pkg: logrotate-pkg:
pkg.installed: pkg.installed:
- name: {{ logrotate.pkg }} - pkgs: {{ pkgs }}

View file

@ -2,23 +2,56 @@
# vim: ft=jinja # vim: ft=jinja
{% import_yaml 'logrotate/defaults.yaml' as default_settings %} {% import_yaml 'logrotate/defaults.yaml' as default_settings %}
{% import_yaml "logrotate/osfamilymap.yaml" as os_family_map %}
{% import_yaml "logrotate/osmap.yaml" as os_map %}
{% set osfam = salt['grains.filter_by']( {% set os_family_map = salt['grains.filter_by']({
os_family_map, 'Arch': {
grain='os_family', 'service': 'logrotate.timer',
) or {} %} 'default_config': {
{% set os = salt['grains.filter_by']( 'tabooext': '+ .pacorig .pacnew .pacsave',
os_map, },
grain='os', },
) or {} %} 'Debian': {
'default_config': {
'compress': True,
},
},
'RedHat': {
'pkg': [
'logrotate',
'cronie'
],
'service': 'crond',
'default_config': {
'dateext': True,
},
},
'Suse': {
'login_records_jobs': False,
'default_config': {
'dateext': True,
'compresscmd': '/usr/bin/xz',
'uncompresscmd': '/usr/bin/xzdec',
},
},
},
grain="os_family",
merge=salt['pillar.get']('logrotate:lookup')) or {}
%}
{% do salt['defaults.merge'](default_settings['logrotate'], osfam) %} {% set os_map = salt['grains.filter_by']({
{% do salt['defaults.merge'](default_settings['logrotate'], os) %} 'Ubuntu': {
'default_config': {
'su': 'root syslog'
},
},
},
grain="os",
merge=os_family_map) or {}
%}
{% set logrotate = salt['pillar.get']( {% set logrotate = salt['grains.filter_by'](
'logrotate:lookup', default_settings,
default=default_settings['logrotate'], merge=os_map,
merge=True, base='logrotate',
) %} )
%}

View file

@ -20,7 +20,14 @@ describe file('/etc/logrotate.d') do
its('mode') { should cmp '0755' } its('mode') { should cmp '0755' }
end end
describe service('cron') do case os[:name]
when 'redhat', 'centos', 'fedora'
service = 'crond'
else
service = 'cron'
end
describe service(service) do
it { should be_installed } it { should be_installed }
it { should be_enabled } it { should be_enabled }
it { should be_running } it { should be_running }