Make puppet pull releases from Pypi
This commit merges api.pp and app.pp into one file to remove duplication and for easier dependency chaining. This commit also makes puppet pull new RefStack releases from pypi so we don't have to keep bumping versions in puppet-refstack. Change-Id: Ic6f5e30ea46d3c053c49b8a45168001bcbd2b46e
This commit is contained in:
parent
70a1c4af19
commit
92ad5a7b0e
@ -19,12 +19,11 @@
|
|||||||
#
|
#
|
||||||
class refstack::apache::http () {
|
class refstack::apache::http () {
|
||||||
require ::refstack::params
|
require ::refstack::params
|
||||||
require ::refstack::api
|
|
||||||
require ::refstack::app
|
require ::refstack::app
|
||||||
|
|
||||||
# Pull various variables into this module, for slightly saner templates.
|
# Pull various variables into this module, for slightly saner templates.
|
||||||
$install_www_root = $::refstack::params::install_www_root
|
$install_www_root = $::refstack::params::install_www_root
|
||||||
$src_www_root = $::refstack::params::src_www_root
|
$src_root = $::refstack::params::src_root
|
||||||
$hostname = $::refstack::params::hostname
|
$hostname = $::refstack::params::hostname
|
||||||
$user = $::refstack::params::user
|
$user = $::refstack::params::user
|
||||||
$group = $::refstack::params::group
|
$group = $::refstack::params::group
|
||||||
@ -41,9 +40,9 @@ class refstack::apache::http () {
|
|||||||
owner => $::httpd::params::user,
|
owner => $::httpd::params::user,
|
||||||
group => $::httpd::params::group,
|
group => $::httpd::params::group,
|
||||||
mode => '0644',
|
mode => '0644',
|
||||||
source => "${src_www_root}/refstack/api/app.wsgi",
|
source => "${src_root}/refstack/api/app.wsgi",
|
||||||
require => [
|
require => [
|
||||||
Class['refstack::api']
|
Class['refstack::app']
|
||||||
],
|
],
|
||||||
notify => Service['httpd'],
|
notify => Service['httpd'],
|
||||||
}
|
}
|
||||||
@ -53,7 +52,7 @@ class refstack::apache::http () {
|
|||||||
ensure => directory,
|
ensure => directory,
|
||||||
owner => $::httpd::params::user,
|
owner => $::httpd::params::user,
|
||||||
group => $::httpd::params::group,
|
group => $::httpd::params::group,
|
||||||
source => "${src_www_root}/refstack-ui/app",
|
source => "${src_root}/refstack-ui/app",
|
||||||
recurse => true,
|
recurse => true,
|
||||||
purge => true,
|
purge => true,
|
||||||
force => true,
|
force => true,
|
||||||
|
@ -19,12 +19,11 @@
|
|||||||
#
|
#
|
||||||
class refstack::apache::https () {
|
class refstack::apache::https () {
|
||||||
require ::refstack::params
|
require ::refstack::params
|
||||||
require ::refstack::api
|
|
||||||
require ::refstack::app
|
require ::refstack::app
|
||||||
|
|
||||||
# Pull various variables into this module, for slightly saner templates.
|
# Pull various variables into this module, for slightly saner templates.
|
||||||
$install_www_root = $::refstack::params::install_www_root
|
$install_www_root = $::refstack::params::install_www_root
|
||||||
$src_www_root = $::refstack::params::src_www_root
|
$src_root = $::refstack::params::src_root
|
||||||
$hostname = $::refstack::params::hostname
|
$hostname = $::refstack::params::hostname
|
||||||
$user = $::refstack::params::user
|
$user = $::refstack::params::user
|
||||||
$group = $::refstack::params::group
|
$group = $::refstack::params::group
|
||||||
@ -48,9 +47,9 @@ class refstack::apache::https () {
|
|||||||
owner => $::httpd::params::user,
|
owner => $::httpd::params::user,
|
||||||
group => $::httpd::params::group,
|
group => $::httpd::params::group,
|
||||||
mode => '0644',
|
mode => '0644',
|
||||||
source => "${src_www_root}/refstack/api/app.wsgi",
|
source => "${src_root}/refstack/api/app.wsgi",
|
||||||
require => [
|
require => [
|
||||||
Class['refstack::api']
|
Class['refstack::app']
|
||||||
],
|
],
|
||||||
notify => Service['httpd'],
|
notify => Service['httpd'],
|
||||||
}
|
}
|
||||||
@ -90,7 +89,7 @@ class refstack::apache::https () {
|
|||||||
ensure => directory,
|
ensure => directory,
|
||||||
owner => $::httpd::params::user,
|
owner => $::httpd::params::user,
|
||||||
group => $::httpd::params::group,
|
group => $::httpd::params::group,
|
||||||
source => "${src_www_root}/refstack-ui/app",
|
source => "${src_root}/refstack-ui/app",
|
||||||
recurse => true,
|
recurse => true,
|
||||||
purge => true,
|
purge => true,
|
||||||
force => true,
|
force => true,
|
||||||
|
102
manifests/api.pp
102
manifests/api.pp
@ -1,102 +0,0 @@
|
|||||||
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
# == Class: refstack::api
|
|
||||||
#
|
|
||||||
# This class installs the RefStack API so that it may be run via wsgi.
|
|
||||||
#
|
|
||||||
class refstack::api () {
|
|
||||||
require ::refstack::params
|
|
||||||
require ::refstack::user
|
|
||||||
|
|
||||||
# Import parameters into local scope.
|
|
||||||
$src_api_root = $::refstack::params::src_api_root
|
|
||||||
$user = $::refstack::params::user
|
|
||||||
$group = $::refstack::params::group
|
|
||||||
|
|
||||||
# Ensure Git is present
|
|
||||||
if !defined(Package['git']) {
|
|
||||||
package { 'git':
|
|
||||||
ensure => present
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Ensure python-dev is present
|
|
||||||
if !defined(Package['python-dev']) {
|
|
||||||
package { 'python-dev':
|
|
||||||
ensure => present
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Ensure OpenSSL is present
|
|
||||||
if !defined(Package['libssl-dev']) {
|
|
||||||
package { 'libssl-dev':
|
|
||||||
ensure => present
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create the RefStack configuration directory.
|
|
||||||
file { '/etc/refstack':
|
|
||||||
ensure => directory,
|
|
||||||
owner => $user,
|
|
||||||
group => $group,
|
|
||||||
mode => '0755',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Configure the RefStack API.
|
|
||||||
file { '/etc/refstack/refstack.conf':
|
|
||||||
ensure => present,
|
|
||||||
owner => $user,
|
|
||||||
group => $group,
|
|
||||||
mode => '0644',
|
|
||||||
content => template('refstack/refstack.conf.erb'),
|
|
||||||
require => [
|
|
||||||
File['/etc/refstack']
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
# Download the latest RefStack Source.
|
|
||||||
vcsrepo { $src_api_root:
|
|
||||||
ensure => present,
|
|
||||||
provider => git,
|
|
||||||
revision => $refstack::params::release_revision,
|
|
||||||
source => 'https://git.openstack.org/openstack/refstack/',
|
|
||||||
require => Package['git']
|
|
||||||
}
|
|
||||||
|
|
||||||
# Install RefStack using pip.
|
|
||||||
exec { 'install-refstack':
|
|
||||||
command => "pip install ${src_api_root}",
|
|
||||||
path => '/usr/local/bin:/usr/bin:/bin',
|
|
||||||
refreshonly => true,
|
|
||||||
require => Vcsrepo[$src_api_root],
|
|
||||||
subscribe => Vcsrepo[$src_api_root],
|
|
||||||
notify => Service['httpd'],
|
|
||||||
}
|
|
||||||
|
|
||||||
# Migrate the database.
|
|
||||||
exec { 'migrate-refstack-db':
|
|
||||||
command => 'refstack-manage --config-file /etc/refstack/refstack.conf upgrade --revision head',
|
|
||||||
path => '/usr/local/bin:/usr/bin:/bin',
|
|
||||||
refreshonly => true,
|
|
||||||
subscribe => [
|
|
||||||
Exec['install-refstack'],
|
|
||||||
File['/etc/refstack/refstack.conf'],
|
|
||||||
],
|
|
||||||
require => [
|
|
||||||
Exec['install-refstack'],
|
|
||||||
File['/etc/refstack/refstack.conf'],
|
|
||||||
],
|
|
||||||
}
|
|
||||||
}
|
|
127
manifests/app.pp
127
manifests/app.pp
@ -14,25 +14,28 @@
|
|||||||
|
|
||||||
# == Class: refstack::app
|
# == Class: refstack::app
|
||||||
#
|
#
|
||||||
# This class installs the RefStack JavaScript Webclient (or app).
|
# This class installs the RefStack application (API and UI) so that it may be
|
||||||
#
|
# run via wsgi.
|
||||||
# Much of this module is duplicated in ::refstack::api, however it's separated
|
|
||||||
# here so that any future project splits (api vs. client) can be treated
|
|
||||||
# similarly in the puppet module.
|
|
||||||
#
|
#
|
||||||
class refstack::app () {
|
class refstack::app () {
|
||||||
require ::refstack::params
|
require ::refstack::params
|
||||||
require ::refstack::user
|
require ::refstack::user
|
||||||
|
|
||||||
# Import parameters into local scope.
|
# Import parameters into local scope.
|
||||||
$src_www_root = $::refstack::params::src_www_root
|
$src_root = $::refstack::params::src_root
|
||||||
$install_www_root = $::refstack::params::install_www_root
|
|
||||||
$user = $::refstack::params::user
|
$user = $::refstack::params::user
|
||||||
$group = $::refstack::params::group
|
$group = $::refstack::params::group
|
||||||
|
|
||||||
# Ensure Git is present
|
# Ensure python-dev is present
|
||||||
if !defined(Package['git']) {
|
if !defined(Package['python-dev']) {
|
||||||
package { 'git':
|
package { 'python-dev':
|
||||||
|
ensure => present
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ensure OpenSSL is present
|
||||||
|
if !defined(Package['libssl-dev']) {
|
||||||
|
package { 'libssl-dev':
|
||||||
ensure => present
|
ensure => present
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,42 +46,111 @@ class refstack::app () {
|
|||||||
ensure => present
|
ensure => present
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !defined(Package['nodejs']) {
|
if !defined(Package['nodejs']) {
|
||||||
package { 'nodejs':
|
package { 'nodejs':
|
||||||
ensure => present
|
ensure => present
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !defined(Package['nodejs-legacy']) {
|
if !defined(Package['nodejs-legacy']) {
|
||||||
package { 'nodejs-legacy':
|
package { 'nodejs-legacy':
|
||||||
ensure => present
|
ensure => present
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Download the latest RefStack Source.
|
# Create the RefStack configuration directory.
|
||||||
vcsrepo { $src_www_root:
|
file { '/etc/refstack':
|
||||||
ensure => present,
|
ensure => directory,
|
||||||
owner => $user,
|
owner => $user,
|
||||||
group => $group,
|
group => $group,
|
||||||
provider => git,
|
mode => '0755',
|
||||||
revision => $refstack::params::release_revision,
|
}
|
||||||
source => 'https://git.openstack.org/openstack/refstack/',
|
|
||||||
require => Package['git']
|
file { $src_root:
|
||||||
|
ensure => 'directory',
|
||||||
|
owner => $user,
|
||||||
|
group => $group,
|
||||||
|
mode => '0755',
|
||||||
|
}
|
||||||
|
|
||||||
|
# Configure the RefStack API.
|
||||||
|
file { '/etc/refstack/refstack.conf':
|
||||||
|
ensure => present,
|
||||||
|
owner => $user,
|
||||||
|
group => $group,
|
||||||
|
mode => '0644',
|
||||||
|
content => template('refstack/refstack.conf.erb'),
|
||||||
|
require => [
|
||||||
|
File['/etc/refstack']
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Download the RefStack tar.gz source distribution from pypi only if a new
|
||||||
|
# one is available.
|
||||||
|
exec { 'download-refstack':
|
||||||
|
command => 'pip install refstack -d /tmp --no-deps --no-binary :all:',
|
||||||
|
path => '/usr/local/bin:/usr/bin:/bin',
|
||||||
|
user => $user,
|
||||||
|
group => $group,
|
||||||
|
onlyif => 'pip list --outdated | grep -c refstack || test `pip freeze | grep -c refstack` -eq 0'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Untar the source contents.
|
||||||
|
exec { 'untar-refstack' :
|
||||||
|
command => "tar -xvzf /tmp/refstack-*.tar.gz -C ${src_root} --strip-components=1",
|
||||||
|
path => '/usr/local/bin:/usr/bin:/bin',
|
||||||
|
refreshonly => true,
|
||||||
|
user => $user,
|
||||||
|
group => $group,
|
||||||
|
require => File[$src_root],
|
||||||
|
subscribe => Exec['download-refstack']
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove tar.gz file after extracting.
|
||||||
|
exec { 'remove-tar':
|
||||||
|
command => 'rm -f /tmp/refstack-*.tar.gz',
|
||||||
|
path => '/usr/local/bin:/usr/bin:/bin',
|
||||||
|
refreshonly => true,
|
||||||
|
subscribe => Exec['untar-refstack']
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install RefStack using pip.
|
||||||
|
exec { 'install-refstack':
|
||||||
|
command => "pip install -U ${src_root}",
|
||||||
|
path => '/usr/local/bin:/usr/bin:/bin',
|
||||||
|
refreshonly => true,
|
||||||
|
require => File[$src_root],
|
||||||
|
subscribe => Exec['untar-refstack'],
|
||||||
|
notify => Service['httpd']
|
||||||
|
}
|
||||||
|
|
||||||
|
# Migrate the database.
|
||||||
|
exec { 'migrate-refstack-db':
|
||||||
|
command => 'refstack-manage --config-file /etc/refstack/refstack.conf upgrade --revision head',
|
||||||
|
path => '/usr/local/bin:/usr/bin:/bin',
|
||||||
|
refreshonly => true,
|
||||||
|
subscribe => [
|
||||||
|
Exec['install-refstack'],
|
||||||
|
File['/etc/refstack/refstack.conf'],
|
||||||
|
],
|
||||||
|
require => [
|
||||||
|
Exec['install-refstack'],
|
||||||
|
File['/etc/refstack/refstack.conf'],
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run NPM Install.
|
# Run NPM Install.
|
||||||
exec { 'npm install':
|
exec { 'npm install':
|
||||||
command => 'npm install',
|
command => 'npm install',
|
||||||
path => '/usr/local/bin:/usr/bin:/bin/',
|
path => '/usr/local/bin:/usr/bin:/bin/',
|
||||||
cwd => $src_www_root,
|
cwd => $src_root,
|
||||||
user => $user,
|
user => $user,
|
||||||
group => $group,
|
group => $group,
|
||||||
refreshonly => true,
|
refreshonly => true,
|
||||||
subscribe => [
|
subscribe => Exec['untar-refstack'],
|
||||||
Vcsrepo[$src_www_root],
|
|
||||||
],
|
|
||||||
require => [
|
require => [
|
||||||
Package['npm'],
|
Package['npm'],
|
||||||
Vcsrepo[$src_www_root],
|
|
||||||
],
|
],
|
||||||
environment => [
|
environment => [
|
||||||
# This is not automatically set by exec.
|
# This is not automatically set by exec.
|
||||||
@ -87,9 +159,12 @@ class refstack::app () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Create config.json file.
|
# Create config.json file.
|
||||||
file { "${src_www_root}/refstack-ui/app/config.json":
|
file { "${src_root}/refstack-ui/app/config.json":
|
||||||
ensure => file,
|
ensure => file,
|
||||||
content => '{"refstackApiUrl": "/api/v1"}',
|
content => '{"refstackApiUrl": "/api/v1"}',
|
||||||
require => Vcsrepo[$src_www_root],
|
require => [
|
||||||
|
File[$src_root],
|
||||||
|
Exec['untar-refstack'],
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,6 @@ class refstack (
|
|||||||
|
|
||||||
include ::refstack::mysql
|
include ::refstack::mysql
|
||||||
include ::refstack::app
|
include ::refstack::app
|
||||||
include ::refstack::api
|
|
||||||
|
|
||||||
if $protocol == 'https' {
|
if $protocol == 'https' {
|
||||||
include ::refstack::apache::https
|
include ::refstack::apache::https
|
||||||
|
@ -18,12 +18,8 @@
|
|||||||
#
|
#
|
||||||
class refstack::params (
|
class refstack::params (
|
||||||
|
|
||||||
# Current release revision
|
|
||||||
$release_revision = '1.0.0',
|
|
||||||
|
|
||||||
# Source and install directories.
|
# Source and install directories.
|
||||||
$src_api_root = '/opt/refstack-api',
|
$src_root = '/opt/refstack',
|
||||||
$src_www_root = '/opt/refstack-www',
|
|
||||||
$install_www_root = '/var/www/refstack-www',
|
$install_www_root = '/var/www/refstack-www',
|
||||||
|
|
||||||
# The user under which refstack will run.
|
# The user under which refstack will run.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user