Skip to content

Example profile::odoo

Romain Tartière edited this page Aug 19, 2020 · 1 revision

Example profile::odoo class for a control-repo:

class profile::odoo (
  Enum['11.0', '12.0', '13.0'] $version,
  Sensitive $admin_passwd,
  Optional[String] $dbfilter = undef,
  Boolean $list_db = false,
  Integer $workers = 2 * $facts.get('processors.count') + 1,
  Optional[String] $enterprise_commit = undef,
) {
  $enterprise_path = '...'

  if $list_db == false and $dbfilter == undef {
    $real_dbfilter = '^%h$'
  } else {
    $real_dbfilter = $dbfilter
  }

  $base_addons_path = $version ? {
    '10.0' => '/usr/lib/python2.7/dist-packages/odoo/addons',
    '11.0' => '/usr/lib/python3/dist-packages/odoo/addons',
    '12.0' => '/usr/lib/python3/dist-packages/odoo/addons',
    '13.0' => '/usr/lib/python3/dist-packages/odoo/addons',
  }

  $addons_path = [
    $base_addons_path,
    $enterprise_path,
  ]

  if $enterprise_commit {
    vcsrepo { $enterprise_path:
      ensure   => present,
      provider => 'git',
      source   => '...',
      revision => $enterprise_commit,
      notify   => Class['odoo::service'],
      force    => true,
    }
  } else {
    file { $enterprise_path:
      ensure => directory,
      owner  => 'root',
      group  => 'root',
      mode   => '0755',
      notify => Class['odoo::service'],
    }
  }

  class { 'odoo':
    version         => $version,
    package_ensure  => present,
    package_mark    => 'hold',
    admin_passwd    => $admin_passwd,
    dbfilter        => $real_dbfilter,
    list_db         => $list_db,
    limit_time_real => 360,
    addons_path     => $addons_path,
    db_maxconn      => 10,
    http_interface  => '127.0.0.1',
    proxy_mode      => true,
    workers         => $workers,
    logfile         => '/var/log/odoo/odoo-server.log',
  }
}
Clone this wiki locally