diff --git a/.sync.yml b/.sync.yml index 0d4818c..db98567 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,10 +1,9 @@ --- .travis.yml: secure: "SDpX6jzritODonEQBqy9g0NbOmk2a9dBfAtZLrvHwM8BTpM2W0Y1daqzIbpzxFiqlNX+6r2GSq9SV70N0A9Ko/uPV9aG/XZx7MsBR9DNVjgqjJSl7+aF88VJfRpOv4PAyTM33JMx91nLFxM/ql61YX+2DXGXrhUkBsMZcdBgQnk=" docker_sets: - set: ubuntu1604-64 - set: ubuntu1804-64 - set: centos7-64 - - set: debian8-64 - set: debian9-64 - set: debian10-64 diff --git a/.travis.yml b/.travis.yml index 6685341..a8db339 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,95 +1,87 @@ --- dist: bionic language: ruby cache: bundler before_install: - yes | gem update --system - bundle --version script: - 'bundle exec rake $CHECK' matrix: fast_finish: true include: - rvm: 2.4.4 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=test - rvm: 2.5.3 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 6.0" CHECK=test_with_coveralls - rvm: 2.5.3 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 6.0" CHECK=rubocop - rvm: 2.4.4 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes - rvm: 2.5.3 bundler_args: --without development release env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian8-64 BEAKER_HYPERVISOR=docker CHECK=beaker - services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian8-64 BEAKER_HYPERVISOR=docker CHECK=beaker - services: docker - rvm: 2.5.3 bundler_args: --without development release env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian9-64 BEAKER_HYPERVISOR=docker CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian9-64 BEAKER_HYPERVISOR=docker CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian10-64 BEAKER_HYPERVISOR=docker CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian10-64 BEAKER_HYPERVISOR=docker CHECK=beaker services: docker branches: only: - master - /^v\d/ notifications: email: false webhooks: https://voxpupu.li/incoming/travis irc: on_success: always on_failure: always channels: - "chat.freenode.org#voxpupuli-notifications" deploy: provider: puppetforge user: puppet password: secure: "SDpX6jzritODonEQBqy9g0NbOmk2a9dBfAtZLrvHwM8BTpM2W0Y1daqzIbpzxFiqlNX+6r2GSq9SV70N0A9Ko/uPV9aG/XZx7MsBR9DNVjgqjJSl7+aF88VJfRpOv4PAyTM33JMx91nLFxM/ql61YX+2DXGXrhUkBsMZcdBgQnk=" on: tags: true # all_branches is required to use tags all_branches: true # Only publish the build marked with "DEPLOY_TO_FORGE" condition: "$DEPLOY_TO_FORGE = yes" diff --git a/Gemfile b/Gemfile index 688de4d..ac4aad4 100644 --- a/Gemfile +++ b/Gemfile @@ -1,69 +1,69 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" def location_for(place, fake_version = nil) if place =~ /^(git[:@][^#]*)#(.*)/ [fake_version, { :git => $1, :branch => $2, :require => false }].compact elsif place =~ /^file:\/\/(.*)/ ['>= 0', { :path => File.expand_path($1), :require => false }] else [place, { :require => false }] end end group :test do - gem 'voxpupuli-test', '>= 1.0.0', :require => false + gem 'voxpupuli-test', '>= 1.4.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'rspec-puppet-facts', :require => false, :git => 'https://github.com/mcanevet/rspec-puppet-facts', :ref => '9541292d4fc35db3be1badace673c1108154b571' end group :development do gem 'travis', :require => false gem 'travis-lint', :require => false gem 'guard-rake', :require => false gem 'overcommit', '>= 0.39.1', :require => false end group :system_tests do gem 'winrm', :require => false if beaker_version = ENV['BEAKER_VERSION'] gem 'beaker', *location_for(beaker_version) else gem 'beaker', '>= 4.2.0', :require => false end if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] gem 'beaker-rspec', *location_for(beaker_rspec_version) else gem 'beaker-rspec', :require => false end gem 'serverspec', :require => false gem 'beaker-hostgenerator', '>= 1.1.22', :require => false gem 'beaker-docker', :require => false gem 'beaker-puppet', :require => false gem 'beaker-puppet_install_helper', :require => false gem 'beaker-module_install_helper', :require => false gem 'rbnacl', '>= 4', :require => false gem 'rbnacl-libsodium', :require => false gem 'bcrypt_pbkdf', :require => false gem 'ed25519', :require => false end group :release do gem 'github_changelog_generator', :require => false, :git => 'https://github.com/voxpupuli/github-changelog-generator', :branch => 'voxpupuli_essential_fixes' gem 'puppet-blacksmith', :require => false gem 'voxpupuli-release', :require => false gem 'puppet-strings', '>= 2.2', :require => false end if facterversion = ENV['FACTER_GEM_VERSION'] gem 'facter', facterversion.to_s, :require => false, :groups => [:test] else gem 'facter', :require => false, :groups => [:test] end ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 6.0' : puppetversion = ENV['PUPPET_VERSION'].to_s gem 'puppet', puppetversion, :require => false, :groups => [:test] # vim: syntax=ruby diff --git a/manifests/params.pp b/manifests/params.pp index 066cc3f..c93164d 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,249 +1,248 @@ # Class: nginx::params # ==================== # # nginx default settings and according to operating system # class nginx::params { ### Operating System Configuration ## This is my hacky... no hiera system. Oh well. :) $_module_defaults = { 'conf_dir' => '/etc/nginx', 'daemon_user' => 'nginx', 'pid' => '/var/run/nginx.pid', 'root_group' => 'root', 'log_dir' => '/var/log/nginx', 'log_user' => 'nginx', 'log_group' => 'root', 'log_mode' => '0750', 'run_dir' => '/var/nginx', 'package_name' => 'nginx', 'passenger_package_name' => 'passenger', 'manage_repo' => false, 'include_modules_enabled' => false, 'mime_types' => { 'text/html' => 'html htm shtml', 'text/css' => 'css', 'text/xml' => 'xml', 'image/gif' => 'gif', 'image/jpeg' => 'jpeg jpg', 'application/javascript' => 'js', 'application/atom+xml' => 'atom', 'application/rss+xml' => 'rss', 'text/mathml' => 'mml', 'text/plain' => 'txt', 'text/vnd.sun.j2me.app-descriptor' => 'jad', 'text/vnd.wap.wml' => 'wml', 'text/x-component' => 'htc', 'image/png' => 'png', 'image/tiff' => 'tif tiff', 'image/vnd.wap.wbmp' => 'wbmp', 'image/x-icon' => 'ico', 'image/x-jng' => 'jng', 'image/x-ms-bmp' => 'bmp', 'image/svg+xml' => 'svg svgz', 'image/webp' => 'webp', 'application/font-woff' => 'woff', 'application/java-archive' => 'jar war ear', 'application/json' => 'json', 'application/mac-binhex40' => 'hqx', 'application/msword' => 'doc', 'application/pdf' => 'pdf', 'application/postscript' => 'ps eps ai', 'application/rtf' => 'rtf', 'application/vnd.apple.mpegurl' => 'm3u8', 'application/vnd.ms-excel' => 'xls', 'application/vnd.ms-fontobject' => 'eot', 'application/vnd.ms-powerpoint' => 'ppt', 'application/vnd.wap.wmlc' => 'wmlc', 'application/vnd.google-earth.kml+xml' => 'kml', 'application/vnd.google-earth.kmz' => 'kmz', 'application/x-7z-compressed' => '7z', 'application/x-cocoa' => 'cco', 'application/x-java-archive-diff' => 'jardiff', 'application/x-java-jnlp-file' => 'jnlp', 'application/x-makeself' => 'run', 'application/x-perl' => 'pl pm', 'application/x-pilot' => 'prc pdb', 'application/x-rar-compressed' => 'rar', 'application/x-redhat-package-manager' => 'rpm', 'application/x-sea' => 'sea', 'application/x-shockwave-flash' => 'swf', 'application/x-stuffit' => 'sit', 'application/x-tcl' => 'tcl tk', 'application/x-x509-ca-cert' => 'der pem crt', 'application/x-xpinstall' => 'xpi', 'application/xhtml+xml' => 'xhtml', 'application/xspf+xml' => 'xspf', 'application/zip' => 'zip', 'application/octet-stream' => 'bin exe dll deb dmg iso img msi msp msm', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'pptx', 'audio/midi' => 'mid midi kar', 'audio/mpeg' => 'mp3', 'audio/ogg' => 'ogg', 'audio/x-m4a' => 'm4a', 'audio/x-realaudio' => 'ra', 'video/3gpp' => '3gpp 3gp', 'video/mp2t' => 'ts', 'video/mp4' => 'mp4', 'video/mpeg' => 'mpeg mpg', 'video/quicktime' => 'mov', 'video/webm' => 'webm', 'video/x-flv' => 'flv', 'video/x-m4v' => 'm4v', 'video/x-mng' => 'mng', 'video/x-ms-asf' => 'asx asf', 'video/x-ms-wmv' => 'wmv', 'video/x-msvideo' => 'avi', }, } case $facts['os']['family'] { 'ArchLinux': { $_module_os_overrides = { 'pid' => false, 'daemon_user' => 'http', 'log_user' => 'http', 'log_group' => 'log', 'package_name' => 'nginx-mainline', } } 'Debian': { if ($facts['os']['name'] == 'ubuntu' and $facts['os']['distro']['codename'] in ['bionic']) or ($facts['os']['name'] == 'debian' and $facts['os']['release']['major'] in ['9', '10']) { $_module_os_overrides = { 'manage_repo' => true, 'daemon_user' => 'www-data', 'log_user' => 'root', 'log_group' => 'adm', 'log_mode' => '0755', 'run_dir' => '/run/nginx', 'passenger_package_name' => 'libnginx-mod-http-passenger', 'include_modules_enabled' => true, } - } elsif ($facts['os']['name'] == 'ubuntu' and $facts['os']['distro']['codename'] in ['lucid', 'precise', 'trusty', 'xenial']) - or ($facts['os']['name'] == 'debian' and $facts['os']['release']['major'] in ['6', '7', '8']) { + } elsif ($facts['os']['name'] == 'ubuntu' and $facts['os']['distro']['codename'] in ['lucid', 'precise', 'trusty', 'xenial']) { $_module_os_overrides = { 'manage_repo' => true, 'daemon_user' => 'www-data', 'log_user' => 'root', 'log_group' => 'adm', 'log_mode' => '0755', 'run_dir' => '/run/nginx', } } else { $_module_os_overrides = { 'daemon_user' => 'www-data', 'log_user' => 'root', 'log_group' => 'adm', 'log_mode' => '0755', 'run_dir' => '/run/nginx', } } } 'DragonFly', 'FreeBSD': { $_module_os_overrides = { 'conf_dir' => '/usr/local/etc/nginx', 'daemon_user' => 'www', 'root_group' => 'wheel', 'log_group' => 'wheel', 'log_user' => 'root', } } 'Gentoo': { $_module_os_overrides = { 'package_name' => 'www-servers/nginx', } } 'RedHat': { if ($facts['os']['name'] in ['RedHat', 'CentOS', 'Oracle', 'virtuozzolinux'] and $facts['os']['release']['major'] in ['6', '7']) { $_module_os_overrides = { 'manage_repo' => true, 'log_group' => 'nginx', } } else { $_module_os_overrides = { 'log_group' => 'nginx', } } } 'Solaris': { case $facts['os']['name'] { 'SmartOS': { $_module_os_overrides = { 'conf_dir' => '/opt/local/etc/nginx', 'daemon_user' => 'www', 'log_user' => 'www', 'log_group' => 'root', } } default: { $_module_os_overrides = { 'daemon_user' => 'webservd', 'package_name' => undef, } } } } 'OpenBSD': { $_module_os_overrides = { 'daemon_user' => 'www', 'root_group' => 'wheel', 'log_dir' => '/var/www/logs', 'log_user' => 'www', 'log_group' => 'wheel', 'run_dir' => '/var/www', } } 'AIX': { $_module_os_overrides = { 'daemon_user' => 'nginx', 'root_group' => 'system', 'conf_dir' => '/opt/freeware/etc/nginx/', 'log_dir' => '/opt/freeware/var/log/nginx/', 'log_group' => 'system', 'run_dir' => '/opt/freeware/share/nginx/html', } } default: { ## For cases not covered in $::osfamily case $facts['os']['name'] { default: { $_module_os_overrides = {} } } } } $_module_parameters = merge($_module_defaults, $_module_os_overrides) ### END Operating System Configuration ### Referenced Variables $conf_dir = $_module_parameters['conf_dir'] $snippets_dir = "${conf_dir}/snippets" $log_dir = $_module_parameters['log_dir'] $log_user = $_module_parameters['log_user'] $log_group = $_module_parameters['log_group'] $log_mode = $_module_parameters['log_mode'] $run_dir = $_module_parameters['run_dir'] $temp_dir = '/tmp' $pid = $_module_parameters['pid'] $include_modules_enabled = $_module_parameters['include_modules_enabled'] $client_body_temp_path = "${run_dir}/client_body_temp" $daemon_user = $_module_parameters['daemon_user'] $global_owner = 'root' $global_group = $_module_parameters['root_group'] $global_mode = '0644' $http_access_log_file = 'access.log' $manage_repo = $_module_parameters['manage_repo'] $mime_types = $_module_parameters['mime_types'] $nginx_error_log_file = 'error.log' $root_group = $_module_parameters['root_group'] $package_name = $_module_parameters['package_name'] $passenger_package_name = $_module_parameters['passenger_package_name'] $proxy_temp_path = "${run_dir}/proxy_temp" $sites_available_owner = 'root' $sites_available_group = $_module_parameters['root_group'] $sites_available_mode = '0644' $super_user = true ### END Referenced Variables } diff --git a/metadata.json b/metadata.json index 6efa132..e967397 100644 --- a/metadata.json +++ b/metadata.json @@ -1,88 +1,87 @@ { "name": "puppet-nginx", "version": "1.1.1-rc0", "author": "Vox Pupuli", "summary": "Puppet NGINX management module", "license": "MIT", "source": "https://github.com/voxpupuli/puppet-nginx.git", "project_page": "http://github.com/voxpupuli/puppet-nginx", "issues_url": "https://github.com/voxpupuli/puppet-nginx/issues", "dependencies": [ { "name": "puppetlabs/concat", "version_requirement": ">= 4.1.0 < 7.0.0" }, { "name": "puppetlabs/stdlib", "version_requirement": ">= 5.0.0 < 7.0.0" } ], "requirements": [ { "name": "puppet", "version_requirement": ">= 5.5.8 < 7.0.0" } ], "operatingsystem_support": [ { "operatingsystem": "Debian", "operatingsystemrelease": [ - "8", "9", "10" ] }, { "operatingsystem": "OpenBSD" }, { "operatingsystem": "RedHat", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "VirtuozzoLinux", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "SLES" }, { "operatingsystem": "Solaris" }, { "operatingsystem": "AIX" }, { "operatingsystem": "FreeBSD" }, { "operatingsystem": "DragonFly" }, { "operatingsystem": "NetBSD" }, { "operatingsystem": "Archlinux" }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "16.04", "18.04" ] } ] } diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 54f757b..a255f17 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -1,87 +1,78 @@ require 'spec_helper_acceptance' describe 'nginx class:' do case fact('osfamily') when 'RedHat' pkg_cmd = 'yum info nginx | grep "^From repo"' pkg_remove_cmd = 'yum -y remove nginx nginx-filesystem passenger' pkg_match = %r{passenger} when 'Debian' pkg_cmd = 'dpkg -s nginx | grep ^Maintainer' pkg_remove_cmd = 'apt-get -y purge nginx nginx-common' pkg_match = case fact('operatingsystemmajrelease') when '9', '10' %r{Debian Nginx Maintainers} when '18.04' %r{Ubuntu Developers} else %r{Phusion} end end context 'default parameters' do it 'runs successfully' do pp = "class { 'nginx': }" # Run it twice and test for idempotency apply_manifest(pp, catch_failures: true) expect(apply_manifest(pp, catch_failures: true).exit_code).to be_zero end describe package('nginx') do it { is_expected.to be_installed } end describe service('nginx') do it { is_expected.to be_running } it { is_expected.to be_enabled } end end context 'nginx with package_source passenger' do - # TODO: also test for (expected) failure on 5 - unless fact('osfamily') == 'RedHat' && fact('operatingsystemmajrelease') == '5' - it 'runs successfully' do - shell(pkg_remove_cmd) - pp = <<-EOS - class { 'nginx': - package_source => 'passenger' - } - EOS - - apply_manifest(pp, catch_failures: true) - apply_manifest(pp, catch_changes: true) - end + it 'runs successfully' do + shell(pkg_remove_cmd) + pp = <<-EOS + class { 'nginx': + package_source => 'passenger' + } + EOS - describe package('nginx') do - it { is_expected.to be_installed } - it 'comes from the expected source' do - pkg_output = shell(pkg_cmd) - expect(pkg_output.stdout).to match pkg_match - end - end + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + end - if fact('os.family') == 'Debian' && fact('os.release.major') == '8' - describe package('nginx-extras') do - it { is_expected.to be_installed } - end + describe package('nginx') do + it { is_expected.to be_installed } + it 'comes from the expected source' do + pkg_output = shell(pkg_cmd) + expect(pkg_output.stdout).to match pkg_match end + end - describe package('passenger') do - it { is_expected.to be_installed } - end + describe package('passenger') do + it { is_expected.to be_installed } + end - describe service('nginx') do - it { is_expected.to be_running } - it { is_expected.to be_enabled } - end + describe service('nginx') do + it { is_expected.to be_running } + it { is_expected.to be_enabled } end end context 'reset to default parameters' do it 'runs successfully' do shell(pkg_remove_cmd) pp = "class { 'nginx': }" apply_manifest(pp, catch_failures: true) end end end