Skip to content

Commit

Permalink
Feature 9 - Test Odoo 9 & 10 features (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
dallinb committed Dec 28, 2016
1 parent e899517 commit dcd9b8b
Show file tree
Hide file tree
Showing 15 changed files with 423 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
fixtures:
symlinks:
odoo9: "#{source_dir}"
odoo: "#{source_dir}"
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# odoo9
# odoo

[![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)
Expand All @@ -8,9 +8,9 @@
## 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)
Expand All @@ -28,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`.
Expand All @@ -37,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
Expand All @@ -54,14 +54,14 @@ server:

```puppet
class { 'postgresql::server':
before => Class['odoo9']
before => Class['odoo']
}
class { '::odoo9::repo':
before => Class['odoo9']
class { '::odoo::repo':
before => Class['odoo']
}
class { '::odoo9':
class { '::odoo':
install_wkhtmltopdf => true,
settings => {
'options' => {
Expand Down
4 changes: 2 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.hostname = 'node0'
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'
config.vm.synced_folder '.', '/etc/puppet/modules/odoo'
metadata_json_file = "#{File.dirname(__FILE__)}/metadata.json"
if File.exist?(metadata_json_file)
JSON.parse(
Expand All @@ -24,7 +24,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
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
config.vm.network 'forwarded_port', guest: 8069, host: 8069
config.vm.provider 'virtualbox' do |vb|
Expand Down
33 changes: 33 additions & 0 deletions examples/odoo10.pp
Original file line number Diff line number Diff line change
@@ -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,
}
11 changes: 6 additions & 5 deletions examples/init.pp → examples/odoo9.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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' => {
Expand All @@ -29,5 +30,5 @@
'addons_path' => '/usr/lib/python2.7/dist-packages/openerp/addons',
}
},
version => '9.0c.20161009',
version => present,
}
29 changes: 22 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# Class: odoo
# Install and configure Odoo Community.
# @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 odoo9 (
# @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,
Expand All @@ -21,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'],
}
Expand Down
80 changes: 80 additions & 0 deletions manifests/repo10.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Install a repository to install an Odoo 10 package from.
#
# @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")
}
}
}
7 changes: 5 additions & 2 deletions manifests/repo.pp → manifests/repo9.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
# 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 odoo9::repo (
class odoo::repo9 (
$ensure = present,
$descr = 'Odoo Nightly repository',
$key_id = '5D134C924CB06330DCEFE2A1DEF2A2198183CBB5',
$key_url = 'https://nightly.odoo.com/odoo.key',
Expand All @@ -24,7 +25,7 @@
}

yumrepo { 'odoo':
ensure => present,
ensure => $ensure,
descr => $descr,
baseurl => $baseurl,
enabled => 1,
Expand All @@ -36,6 +37,7 @@
include apt::update

apt::key {'odookey':
ensure => $ensure,
id => $key_id,
source => $key_url,
before => Apt::Source['odoo'],
Expand All @@ -48,6 +50,7 @@
}

apt::source {'odoo':
ensure => $ensure,
location => $location,
comment => $descr,
release => $release,
Expand Down
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "locp-odoo9",
"name": "locp-odoo",
"version": "0.1.2",
"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",
Expand Down
Loading

0 comments on commit dcd9b8b

Please sign in to comment.