From 01f5231b2e07e94a346b9d30a6c1b6f766f96675 Mon Sep 17 00:00:00 2001 From: Ben Dalling Date: Fri, 30 Dec 2016 08:19:18 +0000 Subject: [PATCH] Release 0.2.0 (#15) * Feature 7 (#11) Work on #7, but fixes #10. * Feature 9 - Test Odoo 9 & 10 features (#13) * Release 0.2.0 (#14). --- .fixtures.yml | 2 +- .gitignore | 4 +- .rubocop.yml | 3 + .travis.yml | 21 +++ CHANGELOG.md | 21 +++ Gemfile | 35 +++-- LICENCE.md | 201 ++++++++++++++++++++++++ README.md | 112 ++++++------- Rakefile | 91 +++++++++++ Vagrantfile | 126 +-------------- circle.yml | 14 +- examples/odoo10.pp | 33 ++++ examples/{init.pp => odoo9.pp} | 11 +- manifests/init.pp | 26 ++- manifests/repo10.pp | 82 ++++++++++ manifests/{repo.pp => repo9.pp} | 21 ++- metadata.json | 12 +- spec/acceptance/nodesets/centos7.yml | 15 ++ spec/acceptance/nodesets/default.yml | 13 -- spec/acceptance/nodesets/ubuntu1404.yml | 13 ++ spec/acceptance/odoo9_spec.rb | 41 ----- spec/acceptance/odoo_spec.rb | 118 ++++++++++++++ spec/classes/init_spec.rb | 30 +++- spec/classes/repo10_spec.rb | 73 +++++++++ spec/classes/repo9_spec.rb | 73 +++++++++ spec/classes/repo_spec.rb | 31 ---- spec/spec_helper.rb | 9 +- spec/spec_helper_acceptance.rb | 2 +- 28 files changed, 919 insertions(+), 314 deletions(-) create mode 100644 .rubocop.yml create mode 100644 .travis.yml create mode 100644 CHANGELOG.md create mode 100644 LICENCE.md create mode 100644 examples/odoo10.pp rename examples/{init.pp => odoo9.pp} (82%) create mode 100644 manifests/repo10.pp rename manifests/{repo.pp => repo9.pp} (58%) create mode 100644 spec/acceptance/nodesets/centos7.yml delete mode 100644 spec/acceptance/nodesets/default.yml create mode 100644 spec/acceptance/nodesets/ubuntu1404.yml delete mode 100644 spec/acceptance/odoo9_spec.rb create mode 100644 spec/acceptance/odoo_spec.rb create mode 100644 spec/classes/repo10_spec.rb create mode 100644 spec/classes/repo9_spec.rb delete mode 100644 spec/classes/repo_spec.rb diff --git a/.fixtures.yml b/.fixtures.yml index e715c99..3a64031 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,4 +1,4 @@ --- fixtures: symlinks: - odoo9: "#{source_dir}" + odoo: "#{source_dir}" diff --git a/.gitignore b/.gitignore index 4cad460..6b50d60 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,14 @@ .bundle/ coverage/ +doc/ Gemfile.lock .idea/ *.iml +log/ pkg/ spec/fixtures/ *.swn *.swo *.swp vendor/ -log/ +.yardoc/ diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..d25556a --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,3 @@ +--- +Metrics/LineLength: + Enabled: false diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..97655a5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +--- +env: + - "PUPPET_VERSION='~> 4.5' BEAKER_set=centos7" + - "PUPPET_VERSION='~> 4.5' BEAKER_set=ubuntu1404" +language: ruby +rvm: + - 2.3.1 +cache: bundler +before_install: rm Gemfile.lock || true +bundler_args: --without development --with acceptance +dist: trusty +sudo: required +script: + - "bundle exec rake metadata_lint" + - "bundle exec rubocop" + - "bundle exec rake lint" + - "bundle exec rake validate" + - "bundle exec rake spec SPEC_OPTS='--format documentation'" + - "bundle exec rake acceptance" +notifications: + email: false diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0eba1e4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,21 @@ +# locp-odoo + +##2016-12-30 - Release 0.2.0 ([diff](https://github.com/locp/puppet-odoo/compare/0.1.2...0.2.0)) + +* Rename of the module from locp-odoo9 to locp-odoo. +* Now supports Odoo 10. +* Added support for CentOS 7. +* Implemented better acceptance tests. +* Specified that the licence is Apache 2. + +##2016-12-23 - Release 0.1.2 ([diff](https://github.com/locp/puppet-odoo/compare/0.1.1...0.1.2)) + +Announce that the module has been renamed from locp-odoo9 to locp-odoo. + +##2016-10-09 - Release 0.1.1 ([diff](https://github.com/locp/puppet-odoo/compare/0.1.0...0.1.1)) + +Corrected metadata for the module. + +##2016-10-09 - Release 0.1.0 + +Initial release. diff --git a/Gemfile b/Gemfile index dd92732..9777aef 100644 --- a/Gemfile +++ b/Gemfile @@ -1,22 +1,33 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' - puppetversion = ENV.key?('PUPPET_VERSION') ? ENV['PUPPET_VERSION'] : ['>= 3.3'] -gem 'coveralls' -gem 'metadata-json-lint' -gem 'puppet', puppetversion -gem 'puppet-blacksmith' -gem 'puppetlabs_spec_helper', '>= 1.0.0' -gem 'puppet-lint', '>= 1.0.0' -gem 'facter', '>= 1.7.0' -gem 'rspec_junit_formatter' -gem 'rspec-puppet' -gem 'rspec-puppet-utils' +group :test do + gem 'coveralls' + gem 'facter', '>= 1.7.0' + gem 'git', '1.3.0' + gem 'httparty' + gem 'metadata-json-lint' + gem 'puppet', puppetversion + gem 'puppet-blacksmith' + gem 'puppet-lint', '>= 1.0.0' + gem 'puppet-strings' + gem 'puppetlabs_spec_helper', '>= 1.0.0' + gem 'rspec-puppet' + gem 'rspec-puppet-utils' + gem 'rspec_junit_formatter' +end + +group :acceptance do + gem 'beaker' + gem 'beaker-puppet_install_helper' + gem 'beaker-rspec' + gem 'pry' +end # rspec must be v2 for ruby 1.8.7 if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9' - gem 'rspec', '~> 2.0' gem 'rake', '~> 10.0' + gem 'rspec', '~> 2.0' else # rubocop requires ruby >= 1.9 gem 'rubocop' diff --git a/LICENCE.md b/LICENCE.md new file mode 100644 index 0000000..36fb164 --- /dev/null +++ b/LICENCE.md @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2016 League of Crafty Programmers Ltd. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 7b1ef08..86c709b 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,16 @@ -# odoo9 +# odoo -#### Table of Contents +[![CircleCI](https://circleci.com/gh/locp/puppet-odoo/tree/master.svg?style=svg)](https://circleci.com/gh/locp/puppet-odoo/tree/master) +[![Build Status](https://travis-ci.org/locp/puppet-odoo.png?branch=master)](https://travis-ci.org/locp/puppet-odoo) +[![Coverage Status](https://coveralls.io/repos/github/locp/puppet-odoo/badge.svg?branch=master)](https://coveralls.io/github/locp/puppet-odoo?branch=master) +[![Join the chat at https://gitter.im/locp/puppet-odoo](https://badges.gitter.im/locp/puppet-odoo.svg)](https://gitter.im/locp/puppet-odoo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +## Table of Contents 1. [Description](#description) -1. [Setup - The basics of getting started with odoo9](#setup) - * [What odoo9 affects](#what-odoo9-affects) - * [Beginning with odoo9](#beginning-with-odoo9) +1. [Setup - The basics of getting started with odoo](#setup) + * [What odoo affects](#what-odoo-affects) + * [Beginning with odoo](#beginning-with-odoo) 1. [Usage - Configuration options and additional functionality](#usage) 1. [Reference - An under-the-hood peek at what the module is doing and how](#reference) 1. [Limitations - OS compatibility, etc.](#limitations) @@ -13,7 +18,7 @@ ## Description -Install Odoo 9 Communinty edition in a manner similar to that described in +Install Odoo Communinty edition in a manner similar to that described in *[Installing Odoo](https://www.odoo.com/documentation/9.0/setup/install.html)*. This module has now been renamed to locp-odoo. Please see the following: @@ -23,7 +28,7 @@ This module has now been renamed to locp-odoo. Please see the following: ## Setup -### What odoo9 affects +### What odoo affects * Installs the `odoo` package from the Odoo repository. * Configures `/etc/odoo/openerp-server.conf`. @@ -32,10 +37,10 @@ This module has now been renamed to locp-odoo. Please see the following: the Odoo nightly builds. * Optionally installs the `wkhtmltopdf` package from the Odoo repository. -### Beginning with odoo9 +### Beginning with odoo ```puppet -include ::odoo9 +include ::odoo ``` ## Usage @@ -43,20 +48,20 @@ include ::odoo9 The following example will install a basic PostgreSQL database on the node (using `[puppetlabs-postgresql](https://forge.puppet.com/puppetlabs/postgresql)`) -it then configures the the Odoo repositories. It then installs the +it then configures the the Odoo 9 repositories. It then installs the `odoo` and `wkhtmltopdf` packages with some settings for the Odoo server: ```puppet class { 'postgresql::server': - before => Class['odoo9'] + before => Class['odoo'] } -class { '::odoo9::repo': - before => Class['odoo9'] +class { '::odoo::repo9': + before => Class['odoo'] } -class { '::odoo9': +class { '::odoo': install_wkhtmltopdf => true, settings => { 'options' => { @@ -68,69 +73,50 @@ class { '::odoo9': 'addons_path' => '/usr/lib/python2.7/dist-packages/openerp/addons', } }, - version => '9.0c.20161009', } ``` -## Reference - -### Attributes - -#### Class odoo9 - -##### `install_wkhtmltopdf` -Whether or not to install the optional `wkhtmltopdf` package from the Odoo -repository. -Default value **false**. - -##### `settings` -A hash of settings to be passed to the `create_ini_settings` (see -https://forge.puppet.com/puppetlabs/inifile#manage-multiple-ini_settings -for details). The following defaults are provided: +To do the same for Odoo 10: ```puppet -{ - path => '/etc/odoo/openerp-server.conf', - require => Package['odoo'], - notify => Service['odoo'], +# +class { 'postgresql::server': + before => Class['odoo'] } -``` - -##### `version` -The version of the `odoo` package to be installed. Valid values are -**present**, **latest** or the version of the version of the package to be -installed ('i.e. *9.0c.20161009*). -#### Class odoo9::repo - -##### `descr` -The name of the repository to be configured. -Default value 'Odoo Nightly repository' +class { '::odoo::repo10': + before => Class['odoo'] +} -##### `key_id` -The key for the Debian APT repository. This option is ignored on the -Red Hat family. -Default value '5D134C924CB06330DCEFE2A1DEF2A2198183CBB5' +class { '::odoo': + install_wkhtmltopdf => true, + settings => { + 'options' => { + 'admin_passwd' => 'XXX_TOP_SECRET_XXX', + 'db_host' => 'False', + 'db_port' => 'False', + 'db_user' => 'odoo', + 'db_password' => 'False', + 'addons_path' => '/usr/lib/python2.7/dist-packages/odoo/addons', + } + }, +} +``` -##### `pkg_url` -The URL to the package on the repository. It defaults to -**http://nightly.odoo.com/9.0/nightly/rpm/** on the Red Hat family and -**http://nightly.odoo.com/9.0/nightly/deb/**. +## Reference -##### `pkg_url` -The release for the Debian APT repository. This option is ignored on the -Red Hat family. -Default value './' +### Public Classes -##### `repos` -The repos for the Debian APT repository. This option is ignored on the -Red Hat family. -Default value '' +* [odoo] + (http://locp.github.io/puppet-odoo/puppet_classes/odoo.html) +* [odoo::repo9] + (http://locp.github.io/puppet-odoo/puppet_classes/odoo_3A_3Arepo9.html) +* [odoo::repo10] + (http://locp.github.io/puppet-odoo/puppet_classes/odoo_3A_3Arepo10.html) ## Limitations -At the moment this module has only been tested against Ubuntu 14. Also this -module does not in anyway configure PostgreSQL. +This module does not in anyway configure PostgreSQL. ## Development diff --git a/Rakefile b/Rakefile index 4d65cb0..17f70ca 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,99 @@ require 'rubygems' require 'puppetlabs_spec_helper/rake_tasks' require 'puppet_blacksmith/rake_tasks' +require 'puppet-strings/tasks' +require 'httparty' +require 'json' +require 'yaml' +require 'git' # Use a custom pattern with git tag. %s is replaced with the version number. Blacksmith::RakeTask.new do |t| t.tag_pattern = '%s' end + +desc '[CI Only] Run beaker, but only for pull requests or for release branches.' +task :acceptance do + skip = true + travis_branch = ENV['TRAVIS_BRANCH'] + travis_event_type = ENV['TRAVIS_EVENT_TYPE'] + + if travis_event_type == 'pull_request' + skip = false + elsif travis_event_type == 'push' + skip = false if travis_branch =~ /^release-/ || travis_branch =~ /^hotfix-/ + end + + if skip + puts 'Skipping acceptance tests.' + exit(0) + else + Rake::Task['beaker'].invoke + end +end + +desc '[CI Only] Tag, build and push the module to PuppetForge.' +task :deploy do + abort('Only deploy from master.') unless ENV['CIRCLE_BRANCH'] == 'master' + + # Find out what the local version of the module is. + file = File.read('metadata.json') + data_hash = JSON.parse(file) + local_version = data_hash['version'] + abort('Unable to find local module version.') unless local_version + puts "Module version (local): #{local_version}" + + Rake::Task['deploy:tag'].invoke(local_version) + Rake::Task['deploy:forge'].invoke(local_version) +end + +namespace :deploy do + desc 'Deploy module to Puppet Forge if required.' + task :forge, [:version] do |_t, args| + local_version = args[:version] + + # Find out what the forge version of the module is. + response = HTTParty.get('https://forgeapi.puppetlabs.com/v3/modules/locp-cassandra') + data_hash = JSON.parse(response.body) + forge_version = data_hash['current_release']['version'] + abort('Unable to find out the forge version.') unless forge_version + puts "Module version (forge): #{forge_version}" + exit 0 unless local_version != forge_version + + # Build the module. + puts "Build and deploy version #{local_version}." + Rake::Task['module:clean'].invoke + Rake::Task['build'].invoke + + # Now see if we can push this baby to the forge. + PUPPET_FORGE_CREDENTIALS_FILE = ENV['HOME'] + '/' + '.puppetforge.yml' + username = ENV['CIRCLE_PROJECT_USERNAME'] + password = ENV['PUPPET_FORGE_PASSWORD'] + abort("Not enough data to populate #{PUPPET_FORGE_CREDENTIALS_FILE}") unless username && password + puts "Populating #{PUPPET_FORGE_CREDENTIALS_FILE}" + credentials = { 'username' => username, 'password' => password } + File.open(PUPPET_FORGE_CREDENTIALS_FILE, 'w') { |f| f.write credentials.to_yaml } + Rake::Task['module:push'].invoke + end +end + +namespace :deploy do + desc 'Deploy tag for the module' + task :tag, [:version] do |_t, args| + tagname = args[:version] + # Find out if a tag is available for this version. + log = Logger.new(STDOUT) + log.level = Logger::WARN + git = Git.open('.', log: log) + + begin + git.tag(tagname) + rescue Git::GitTagNameDoesNotExist + puts "Creating tag: #{tagname}" + git.add_tag(tagname, 'master', message: 'tagged by RubyAutoDeployTest', f: true) + git.push('origin', "refs/tags/#{tagname}", f: true) + else + puts "Tag: #{tagname} already exists." + end + end +end diff --git a/Vagrantfile b/Vagrantfile index 17a815a..4b952ba 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -6,146 +6,28 @@ require 'json' VAGRANTFILE_API_VERSION = '2'.freeze Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - # All Vagrant configuration is done here. The most common configuration - # options are documented and commented below. For a complete reference, - # please see the online documentation at vagrantup.com. - - # Every Vagrant virtual environment requires a box to build off of. config.vm.hostname = 'node0' - # config.vm.box = 'puppetlabs/centos-7.0-64-nocm' config.vm.box = 'puppetlabs/ubuntu-14.04-64-nocm' config.puppet_install.puppet_version = '3.8.2' - config.vm.synced_folder '.', '/etc/puppet/modules/odoo9' - - # Enable provisioning with Puppet stand alone. Puppet manifests - # are contained in a directory path relative to this Vagrantfile. - # You will need to create the manifests directory and a manifest in - # the file default.pp in the manifests_path directory. - # - # generate list of puppet modules to be installed from metadata.json + config.vm.synced_folder '.', '/etc/puppet/modules/odoo' metadata_json_file = "#{File.dirname(__FILE__)}/metadata.json" if File.exist?(metadata_json_file) JSON.parse( File.read(metadata_json_file) )['dependencies'].each do |key, _value| module_name = key['name'].to_s - config.vm.provision 'shell', - inline: "puppet module install #{module_name}" + config.vm.provision 'shell', inline: "puppet module install #{module_name}" end else puts 'metadata.json not found; skipping install of dependencies' end - - config.vm.provision 'shell', - inline: 'puppet module install puppetlabs-postgresql' - + config.vm.provision 'shell', inline: 'puppet module install puppetlabs-postgresql' config.vm.provision 'puppet' do |puppet| puppet.manifests_path = 'examples' - puppet.manifest_file = 'init.pp' + puppet.manifest_file = 'odoo10.pp' end - - # Have something like the following in puppet/manifests/local.pp: - # node default { - # require '::base' - # include '::foobar' - # } - # - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # config.vm.network "forwarded_port", guest: 80, host: 8080 config.vm.network 'forwarded_port', guest: 8069, host: 8069 - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # If true, then any SSH connections made will enable agent forwarding. - # Default value: false - # config.ssh.forward_agent = true - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # config.vm.provider 'virtualbox' do |vb| - # Don't boot with headless mode - # vb.gui = true - - # Use VBoxManage to customize the VM. For example to change memory: vb.customize ['modifyvm', :id, '--memory', '2048'] end - # - # View the documentation for the provider you're using for more - # information on available options. - - # Enable provisioning with CFEngine. CFEngine Community packages are - # automatically installed. For example, configure the host as a - # policy server and optionally a policy file to run: - # - # config.vm.provision "cfengine" do |cf| - # cf.am_policy_hub = true - # # cf.run_file = "motd.cf" - # end - # - # You can also configure and bootstrap a client to an existing - # policy server: - # - # config.vm.provision "cfengine" do |cf| - # cf.policy_server_address = "10.0.2.15" - # end - - # Enable provisioning with chef solo, specifying a cookbooks path, roles - # path, and data_bags path (all relative to this Vagrantfile), and adding - # some recipes and/or roles. - # - # config.vm.provision "chef_solo" do |chef| - # chef.cookbooks_path = "../my-recipes/cookbooks" - # chef.roles_path = "../my-recipes/roles" - # chef.data_bags_path = "../my-recipes/data_bags" - # chef.add_recipe "mysql" - # chef.add_role "web" - # - # # You may also specify custom JSON attributes: - # chef.json = { mysql_password: "foo" } - # end - - # Enable provisioning with chef server, specifying the chef server URL, - # and the path to the validation key (relative to this Vagrantfile). - # - # The Opscode Platform uses HTTPS. Substitute your organization for - # ORGNAME in the URL and validation key. - # - # If you have your own Chef Server, use the appropriate URL, which may be - # HTTP instead of HTTPS depending on your configuration. Also change the - # validation key to validation.pem. - # - # config.vm.provision "chef_client" do |chef| - # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" - # chef.validation_key_path = "ORGNAME-validator.pem" - # end - # - # If you're using the Opscode platform, your validator client is - # ORGNAME-validator, replacing ORGNAME with your organization name. - # - # If you have your own Chef Server, the default validation client name is - # chef-validator, unless you changed the configuration. - # - # chef.validation_client_name = "ORGNAME-validator" end diff --git a/circle.yml b/circle.yml index dbd1617..a3aa72e 100644 --- a/circle.yml +++ b/circle.yml @@ -2,24 +2,28 @@ dependencies: bundler: without: [development] - cache_directories: - - "~/.rvm/gems" override: - - bundle install --without development: + - bundle install --without acceptance development: timeout: 240 environment: PUPPET_GEM_VERSION: '~> 4.0' STRICT_VARIABLES: yes post: - rvm cleanup all +deployment: + master: + branch: master + commands: + - git config --global user.email "info@locp.co.uk" + - git config --global user.name "CircleCI" + - bundle exec rake strings:gh_pages:update + - bundle exec rake deploy machine: environment: PUPPET_GEM_VERSION: '~> 4.0' STRICT_VARIABLES: yes ruby: version: 2.1.6 - services: - - docker notify: webhooks: - diff --git a/examples/odoo10.pp b/examples/odoo10.pp new file mode 100644 index 0000000..8c93ddd --- /dev/null +++ b/examples/odoo10.pp @@ -0,0 +1,33 @@ +# The baseline for module testing used by Puppet Labs is that each manifest +# should have a corresponding test manifest that declares that class or defined +# type. +# +# Tests are then run by using puppet apply --noop (to check for compilation +# errors and view a log of events) or by fully applying the test in a virtual +# environment (to compare the resulting system state to the desired state). +# +# Learn more about module testing here: +# https://docs.puppet.com/guides/tests_smoke.html +# +class { 'postgresql::server': + before => Class['odoo'] +} + +class { '::odoo::repo10': + before => Class['odoo'] +} + +class { '::odoo': + install_wkhtmltopdf => true, + settings => { + 'options' => { + 'admin_passwd' => 'XXX_TOP_SECRET_XXX', + 'db_host' => 'False', + 'db_port' => 'False', + 'db_user' => 'odoo', + 'db_password' => 'False', + 'addons_path' => '/usr/lib/python2.7/dist-packages/odoo/addons', + } + }, + version => present, +} diff --git a/examples/init.pp b/examples/odoo9.pp similarity index 82% rename from examples/init.pp rename to examples/odoo9.pp index ae565bc..1a0f349 100644 --- a/examples/init.pp +++ b/examples/odoo9.pp @@ -10,14 +10,15 @@ # https://docs.puppet.com/guides/tests_smoke.html # class { 'postgresql::server': - before => Class['odoo9'] + before => Class['odoo'] } -class { '::odoo9::repo': - before => Class['odoo9'] +class { '::odoo::repo9': + before => Class['odoo'] } -class { '::odoo9': +class { '::odoo': + config_file => '/etc/odoo/openerp-server.conf', install_wkhtmltopdf => true, settings => { 'options' => { @@ -29,5 +30,5 @@ 'addons_path' => '/usr/lib/python2.7/dist-packages/openerp/addons', } }, - version => '9.0c.20161009', + version => present, } diff --git a/manifests/init.pp b/manifests/init.pp index 9e2cab3..eca8e14 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,5 +1,18 @@ -# Class: odoo9 -class odoo9 ( +# Class: odoo +# Install and configure Odoo Community. +# @param config_file [string] The Odoo configuration file. Will need to be +# changed to `/etc/odoo/openerp-server.conf` for Odoo 9. +# @param install_wkhtmltopdf [boolean] Whether or not to install the optional +# `wkhtmltopdf` package. +# @param settings [hash] A hash of settings to be passed to the +# `create_ini_settings` (see +# https://forge.puppet.com/puppetlabs/inifile#manage-multiple-ini_settings +# for details). +# @param version [string] The version of the `odoo` package to be installed. +# Valid values are **present**, **latest** or the version of the version of +# the package to be installed (i.e. '9.0c.20161009'). +class odoo ( + $config_file = '/etc/odoo/odoo.conf', $install_wkhtmltopdf = false, $settings = {}, $version = present, @@ -16,8 +29,15 @@ notify => Service['odoo'] } + if $::osfamily == 'RedHat' { + exec { '/usr/bin/systemctl daemon-reload': + refreshonly => true, + subscribe => Package['odoo'], + } + } + $defaults = { - path => '/etc/odoo/openerp-server.conf', + path => $config_file, require => Package['odoo'], notify => Service['odoo'], } diff --git a/manifests/repo10.pp b/manifests/repo10.pp new file mode 100644 index 0000000..a059455 --- /dev/null +++ b/manifests/repo10.pp @@ -0,0 +1,82 @@ +# Install a repository to install an Odoo 10 package from. +# +# @param ensure [absent | present] Ensure the the repository is either +# absent or present. +# @param descr [string] A string to describe the repository. +# @param key_id [string] The key for the Debian APT repository. This option +# is ignored on the Red Hat family. +# @param key_url [string] A URL to the key for the Debian APT repository. +# This option is ignored on the Red Hat family. +# @param pkg_url [string] The URL to a package. This defaults to +# 'http://nightly.odoo.com/10.0/nightly/rpm/' on the Red +# Hat family and 'http://nightly.odoo.com/9.0/nightly/deb/' on Debian. +# @param release [string] The release for the Debian APT repository. This +# option is ignored on the Red Hat family. +# @param repos [string] The repos for the Debian APT repository. This option +# is ignored on the Red Hat family. +class odoo::repo10 ( + $ensure = present, + $descr = 'Odoo Nightly repository', + $key_id = '5D134C924CB06330DCEFE2A1DEF2A2198183CBB5', + $key_url = 'https://nightly.odoo.com/odoo.key', + $pkg_url = undef, + $release = './', + $repos = '', + ) { + case $::osfamily { + 'RedHat': { + if $pkg_url != undef { + $baseurl = $pkg_url + } else { + $baseurl = 'http://nightly.odoo.com/10.0/nightly/rpm/' + } + + yumrepo { 'odoo': + ensure => $ensure, + descr => $descr, + baseurl => $baseurl, + enabled => 1, + gpgcheck => 0, + } + } + 'Debian': { + include apt + include apt::update + + apt::key {'odookey': + ensure => $ensure, + id => $key_id, + source => $key_url, + before => Apt::Source['odoo'], + } + + if $pkg_url != undef { + $location = $pkg_url + } else { + $location = 'http://nightly.odoo.com/10.0/nightly/deb/' + } + + apt::source {'odoo': + ensure => $ensure, + location => $location, + comment => $descr, + release => $release, + repos => $repos, + include => { + 'src' => false, + }, + notify => Exec['update-odoo-repos'], + } + + # Required to wrap apt_update + exec {'update-odoo-repos': + refreshonly => true, + command => '/bin/true', + require => Exec['apt_update'], + } + } + default: { + warning("OS family ${::osfamily} not supported") + } + } +} diff --git a/manifests/repo.pp b/manifests/repo9.pp similarity index 58% rename from manifests/repo.pp rename to manifests/repo9.pp index dc97a00..febb817 100644 --- a/manifests/repo.pp +++ b/manifests/repo9.pp @@ -1,9 +1,16 @@ -# == Class: odoo9::repo +# Install a repository to install an Odoo 9 package from. # -# Please see the README for this module for full details of what this class -# does as part of the module and how to use it. -# -class odoo9::repo ( +# @param ensure [absent | present] Ensure the the repository is either +# absent or present. +# @param descr [string] A string to describe the repository. +# @param key_id [string] The key for the Debian APT repository. This option is ignored on the Red Hat family. +# @param key_url [string] A URL to the key for the Debian APT repository. This option is ignored on the Red Hat family. +# @param pkg_url [string] The URL to a package. This defaults to 'http://nightly.odoo.com/9.0/nightly/rpm/' on the Red +# Hat family and 'http://nightly.odoo.com/9.0/nightly/deb/' on Debian. +# @param release [string] The release for the Debian APT repository. This option is ignored on the Red Hat family. +# @param repos [string] The repos for the Debian APT repository. This option is ignored on the Red Hat family. +class odoo::repo9 ( + $ensure = present, $descr = 'Odoo Nightly repository', $key_id = '5D134C924CB06330DCEFE2A1DEF2A2198183CBB5', $key_url = 'https://nightly.odoo.com/odoo.key', @@ -20,7 +27,7 @@ } yumrepo { 'odoo': - ensure => present, + ensure => $ensure, descr => $descr, baseurl => $baseurl, enabled => 1, @@ -32,6 +39,7 @@ include apt::update apt::key {'odookey': + ensure => $ensure, id => $key_id, source => $key_url, before => Apt::Source['odoo'], @@ -44,6 +52,7 @@ } apt::source {'odoo': + ensure => $ensure, location => $location, comment => $descr, release => $release, diff --git a/metadata.json b/metadata.json index 6f5eb74..f76bb9c 100644 --- a/metadata.json +++ b/metadata.json @@ -1,8 +1,8 @@ { - "name": "locp-odoo9", - "version": "0.1.2", + "name": "locp-odoo", + "version": "0.2.0", "author": "locp", - "summary": "Puppet module to install Odoo 9.0 Community.", + "summary": "Puppet module to install Odoo Community.", "license": "Apache-2.0", "source": "https://github.com/locp/puppet-odoo", "project_page": "https://github.com/locp/puppet-odoo", @@ -37,6 +37,12 @@ "operatingsystemrelease": [ "14.04" ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "7" + ] } ], "data_provider": null diff --git a/spec/acceptance/nodesets/centos7.yml b/spec/acceptance/nodesets/centos7.yml new file mode 100644 index 0000000..5ef717f --- /dev/null +++ b/spec/acceptance/nodesets/centos7.yml @@ -0,0 +1,15 @@ +--- +HOSTS: + centos7: + roles: + - master + platform: el-7-x86_64 + image: centos:7 + hypervisor: docker + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'yum -y install systemd-container initscripts epel-release' + - 'yum clean all' +CONFIG: + type: foss + log_level: notice diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml deleted file mode 100644 index b2abdeb..0000000 --- a/spec/acceptance/nodesets/default.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -HOSTS: - debian7: - roles: - - debian7 - platform: debian-7-amd64 - image: debian:7 - hypervisor: docker - docker_image_commands: - - 'apt-get install -y sudo ufw wget' -CONFIG: - type: foss - log_level: notice diff --git a/spec/acceptance/nodesets/ubuntu1404.yml b/spec/acceptance/nodesets/ubuntu1404.yml new file mode 100644 index 0000000..d65972d --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu1404.yml @@ -0,0 +1,13 @@ +--- +HOSTS: + ubuntu1404: + roles: + - master + platform: ubuntu-14.04-x64 + image: ubuntu:14.04 + hypervisor: docker + docker_image_commands: + - 'apt-get install -y sudo' +CONFIG: + type: foss + log_level: notice diff --git a/spec/acceptance/odoo9_spec.rb b/spec/acceptance/odoo9_spec.rb deleted file mode 100644 index 9d80f84..0000000 --- a/spec/acceptance/odoo9_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'odoo9 class' do - odoo_pp = <<-EOS - class { 'postgresql::server': - before => Class['odoo9'] - } - - class { '::odoo9::repo': - before => Class['odoo9'] - } - - class { '::odoo9': - install_wkhtmltopdf => true, - settings => { - 'options' => { - 'admin_passwd' => 'XXX_TOP_SECRET_XXX', - 'db_host' => 'False', - 'db_port' => 'False', - 'db_user' => 'odoo', - 'db_password' => 'False', - 'addons_path' => '/usr/lib/python2.7/dist-packages/openerp/addons', - } - }, - version => '9.0c.20161009', - } - EOS - - describe 'Odoo 9 installation.' do - it 'should work with no errors' do - apply_manifest(odoo_pp, catch_failures: true) - expect(apply_manifest(odoo_pp, - catch_failures: true).exit_code).to be_zero - end - end - - describe service('odoo') do - it { is_expected.to be_running } - it { is_expected.to be_enabled } - end -end diff --git a/spec/acceptance/odoo_spec.rb b/spec/acceptance/odoo_spec.rb new file mode 100644 index 0000000..b0fc306 --- /dev/null +++ b/spec/acceptance/odoo_spec.rb @@ -0,0 +1,118 @@ +require 'spec_helper_acceptance' + +describe 'odoo module' do + install_odoo9_pp = <<-EOS + class { 'postgresql::server': + before => Class['odoo'] + } + + class { '::odoo::repo9': + before => Class['odoo'] + } + + class { '::odoo': + config_file => '/etc/odoo/openerp-server.conf', + install_wkhtmltopdf => true, + settings => { + 'options' => { + 'admin_passwd' => 'XXX_TOP_SECRET_XXX_9', + 'db_host' => 'False', + 'db_port' => 'False', + 'db_user' => 'odoo', + 'db_password' => 'False', + 'addons_path' => '/usr/lib/python2.7/dist-packages/openerp/addons', + } + }, + version => present, + } + EOS + + describe 'Odoo 9 installation.' do + it 'should work with no errors' do + apply_manifest(install_odoo9_pp, catch_failures: true) + end + + it 'should be idempotent' do + expect(apply_manifest(install_odoo9_pp, + catch_failures: true).exit_code).to be_zero + end + end + + describe package('odoo') do + it { is_expected.to be_installed } + end + + describe service('odoo') do + it { is_expected.to be_running } + it { is_expected.to be_enabled } + end + + uninstall_odoo9_pp = <<-EOS + service { 'odoo': + ensure => stopped, + } -> + package { 'odoo': + ensure => purged, + } -> + class { 'odoo::repo9': + ensure => absent, + } + + if $::osfamily == 'RedHat' { + exec { '/usr/bin/yum clean all': + before => Class['odoo::repo9'], + } + } + EOS + + describe 'Uninstall Odoo 9.' do + it 'should work with no errors' do + apply_manifest(uninstall_odoo9_pp, catch_failures: true) + end + end + + install_odoo10_pp = <<-EOS + class { 'postgresql::server': + before => Class['odoo'] + } + + class { '::odoo::repo10': + before => Class['odoo'] + } + + class { '::odoo': + install_wkhtmltopdf => true, + settings => { + 'options' => { + 'admin_passwd' => 'XXX_TOP_SECRET_XXX_10', + 'db_host' => 'False', + 'db_port' => 'False', + 'db_user' => 'odoo', + 'db_password' => 'False', + 'addons_path' => '/usr/lib/python2.7/dist-packages/odoo/addons', + } + }, + version => present, + } + EOS + + describe 'Odoo 10 installation.' do + it 'should work with no errors' do + apply_manifest(install_odoo10_pp, catch_failures: true) + end + + it 'should be idempotent' do + expect(apply_manifest(install_odoo10_pp, + catch_failures: true).exit_code).to be_zero + end + end + + describe package('odoo') do + it { is_expected.to be_installed } + end + + describe service('odoo') do + it { is_expected.to be_running } + it { is_expected.to be_enabled } + end +end diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 485ad47..8750d72 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe 'odoo9' do +describe 'odoo' do let(:pre_condition) do [ 'define ini_setting($ensure = nil, @@ -16,12 +16,36 @@ end end - context 'with defaults for all parameters' do + context 'with defaults for all parameters (debian)' do + let :facts do + { + osfamily: 'Debian' + } + end + + it do + should compile + should have_resource_count(2) + should contain_class('odoo') + should contain_package('odoo') + should contain_service('odoo') + end + end + + context 'with defaults for all parameters (red hat)' do + let :facts do + { + osfamily: 'RedHat' + } + end + it do should compile - should contain_class('odoo9') + should have_resource_count(3) + should contain_class('odoo') should contain_package('odoo') should contain_service('odoo') + should contain_exec('/usr/bin/systemctl daemon-reload') end end end diff --git a/spec/classes/repo10_spec.rb b/spec/classes/repo10_spec.rb new file mode 100644 index 0000000..3c199e3 --- /dev/null +++ b/spec/classes/repo10_spec.rb @@ -0,0 +1,73 @@ +require 'spec_helper' +describe 'odoo::repo10' do + let(:pre_condition) do + [ + 'class apt() {}', + 'define apt::key($ensure, $id, $source) {}', + 'define apt::source($ensure, $location, $comment, $release, $repos, $include) {}', + 'class apt::update() {}' + ] + end + + let!(:stdlib_stubs) do + MockFunction.new('create_ini_settings', type: :statement) do |_f| + end + end + + context 'with defaults for all parameters (Debian)' do + let :facts do + { + osfamily: 'Debian' + } + end + + it do + should contain_class('odoo::repo10').only_with( + ensure: 'present', + descr: 'Odoo Nightly repository', + key_id: '5D134C924CB06330DCEFE2A1DEF2A2198183CBB5', + key_url: 'https://nightly.odoo.com/odoo.key', + pkg_url: nil, + release: './', + repos: '' + ) + + should contain_apt__key('odookey').with( + ensure: 'present', + id: '5D134C924CB06330DCEFE2A1DEF2A2198183CBB5', + source: 'https://nightly.odoo.com/odoo.key' + ) + + should contain_apt__source('odoo').with( + ensure: 'present', + location: 'http://nightly.odoo.com/10.0/nightly/deb/', + comment: 'Odoo Nightly repository', + release: './', + include: { 'src' => false } + ) + + should contain_exec('update-odoo-repos').with( + refreshonly: true, + command: '/bin/true' + ) + end + end + + context 'with defaults for all parameters (RedHat)' do + let :facts do + { + osfamily: 'RedHat' + } + end + + it do + should contain_yumrepo('odoo').with( + ensure: 'present', + descr: 'Odoo Nightly repository', + baseurl: 'http://nightly.odoo.com/10.0/nightly/rpm/', + enabled: 1, + gpgcheck: 0 + ) + end + end +end diff --git a/spec/classes/repo9_spec.rb b/spec/classes/repo9_spec.rb new file mode 100644 index 0000000..1880f84 --- /dev/null +++ b/spec/classes/repo9_spec.rb @@ -0,0 +1,73 @@ +require 'spec_helper' +describe 'odoo::repo9' do + let(:pre_condition) do + [ + 'class apt() {}', + 'define apt::key($ensure, $id, $source) {}', + 'define apt::source($ensure, $location, $comment, $release, $repos, $include) {}', + 'class apt::update() {}' + ] + end + + let!(:stdlib_stubs) do + MockFunction.new('create_ini_settings', type: :statement) do |_f| + end + end + + context 'with defaults for all parameters (Debian)' do + let :facts do + { + osfamily: 'Debian' + } + end + + it do + should contain_class('odoo::repo9').only_with( + ensure: 'present', + descr: 'Odoo Nightly repository', + key_id: '5D134C924CB06330DCEFE2A1DEF2A2198183CBB5', + key_url: 'https://nightly.odoo.com/odoo.key', + pkg_url: nil, + release: './', + repos: '' + ) + + should contain_apt__key('odookey').with( + ensure: 'present', + id: '5D134C924CB06330DCEFE2A1DEF2A2198183CBB5', + source: 'https://nightly.odoo.com/odoo.key' + ) + + should contain_apt__source('odoo').with( + ensure: 'present', + location: 'http://nightly.odoo.com/9.0/nightly/deb/', + comment: 'Odoo Nightly repository', + release: './', + include: { 'src' => false } + ) + + should contain_exec('update-odoo-repos').with( + refreshonly: true, + command: '/bin/true' + ) + end + end + + context 'with defaults for all parameters (RedHat)' do + let :facts do + { + osfamily: 'RedHat' + } + end + + it do + should contain_yumrepo('odoo').with( + ensure: 'present', + descr: 'Odoo Nightly repository', + baseurl: 'http://nightly.odoo.com/9.0/nightly/rpm/', + enabled: 1, + gpgcheck: 0 + ) + end + end +end diff --git a/spec/classes/repo_spec.rb b/spec/classes/repo_spec.rb deleted file mode 100644 index edde300..0000000 --- a/spec/classes/repo_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper' -describe 'odoo9::repo' do - let(:pre_condition) do - [ - 'class apt() {}', - 'define apt::key($id, $source) {}', - 'define apt::source($location, $comment, $release, $repos, $include) {}', - 'class apt::update() {}' - ] - end - - let!(:stdlib_stubs) do - MockFunction.new('create_ini_settings', type: :statement) do |_f| - end - end - - context 'with defaults for all parameters' do - let :facts do - { - osfamily: 'Debian' - } - end - - it do - should contain_class('odoo9::repo') - should contain_apt__key('odookey') - should contain_apt__source('odoo') - should contain_exec('update-odoo-repos') - end - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fd6d314..9b1f149 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,16 +1,17 @@ -require 'coveralls' require 'rspec-puppet' require 'rspec-puppet-utils' require 'puppetlabs_spec_helper/module_spec_helper' require 'simplecov' +require 'coveralls' unless ENV['TRAVIS'] == 'true' +Coveralls.wear! unless ENV['TRAVIS'] == 'true' fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) RSpec.configure do |c| c.module_path = File.join(fixture_path, 'modules') c.manifest_dir = File.join(fixture_path, 'manifests') c.environmentpath = File.join(Dir.pwd, 'spec') + c.after(:suite) do + exit(1) if RSpec::Puppet::Coverage.report!(100) + end end - -Coveralls.wear! -at_exit { RSpec::Puppet::Coverage.report! } diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 893708a..4041448 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -22,7 +22,7 @@ # Configure all nodes in nodeset c.before :suite do # Install module - puppet_module_install(source: module_root, module_name: 'odoo9') + puppet_module_install(source: module_root, module_name: 'odoo') hosts.each do |host| on host, puppet('module', 'install', 'puppetlabs-apt'), acceptable_exit_codes: [0, 1]