diff --git a/.gitignore b/.gitignore index 5ced7545e..b20d4e97b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ /interface/static/js/ /interface/static/css/ /interface/static/img/ -/puppet/modules/ +/puppet/environment/development/modules_contrib/ /test/.cache /test/programmatic_interface/.cache /test/programmatic_interface/__pycache__ diff --git a/Vagrantfile b/Vagrantfile index 9c973d6ec..a78953e99 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -79,7 +79,6 @@ Vagrant.configure(2) do |config| puppet.manifests_path = 'puppet/environment/development/manifests' puppet.module_path = ['puppet/environment/development/modules_contrib', 'puppet/environment/development/modules'] puppet.manifest_file = 'vagrant_mounted.pp' - end ## Custom Manifest: install redis client / server # @@ -108,7 +107,6 @@ Vagrant.configure(2) do |config| puppet.manifests_path = 'puppet/environment/development/manifests' puppet.module_path = ['puppet/environment/development/modules_contrib', 'puppet/environment/development/modules'] puppet.manifest_file = 'configure_system.pp' - end ## Custom Manifest: define webcompilers # diff --git a/puppet/scripts/__init__.py b/puppet/environment/__init__.py similarity index 100% rename from puppet/scripts/__init__.py rename to puppet/environment/__init__.py diff --git a/puppet/Puppetfile b/puppet/environment/development/Puppetfile similarity index 97% rename from puppet/Puppetfile rename to puppet/environment/development/Puppetfile index 848bad856..3f4ffd0ec 100644 --- a/puppet/Puppetfile +++ b/puppet/environment/development/Puppetfile @@ -17,7 +17,7 @@ mod 'apt', ## Install Module: nodejs mod 'nodejs', :git => 'git@github.com:puppet-community/puppet-nodejs.git', - :ref => '1.2.0' + :ref => 'v1.3.0' ## Install Module: git mod 'git', diff --git a/puppet/environment/development/__init__.py b/puppet/environment/development/__init__.py new file mode 100644 index 000000000..e76630aea --- /dev/null +++ b/puppet/environment/development/__init__.py @@ -0,0 +1,4 @@ +"""@__init__ +This file allows the containing directory to be considered a python package, +consisting of python module(s). +""" diff --git a/puppet/environment/development/manifests/compile_asset.pp b/puppet/environment/development/manifests/compile_asset.pp new file mode 100644 index 000000000..11a4753e5 --- /dev/null +++ b/puppet/environment/development/manifests/compile_asset.pp @@ -0,0 +1,48 @@ +### compile_asset.pp: install, configure, and run initial compile against +### source files. +### +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### + +## install package dependencies +class dependencies { + contain package::webcompilers +} + +## configure webcompilers +class configure { + ## set dependency + require dependencies + + ## configure webcompilers + contain compiler::webcompilers +} + +## start webcompilers +class start { + ## set dependency + require dependencies + require configure + + ## start compiler(s) + contain compiler::start_sass + contain compiler::start_uglifyjs + contain compiler::start_browserify + contain compiler::start_imagemin +} + +## initial compile +class initiate { + ## set dependency + require dependencies + require configure + require start + + ## initial compile + contain compiler::initial_compile +} + +## initiate +include initiate \ No newline at end of file diff --git a/puppet/environment/development/manifests/configure_redis.pp b/puppet/environment/development/manifests/configure_redis.pp new file mode 100644 index 000000000..8353eedd9 --- /dev/null +++ b/puppet/environment/development/manifests/configure_redis.pp @@ -0,0 +1,12 @@ +### configure_redis.pp: install redis client, and redis server. +### +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### + +## install redis client +include redis::client + +## install redis-server +include redis::server \ No newline at end of file diff --git a/puppet/environment/development/manifests/configure_system.pp b/puppet/environment/development/manifests/configure_system.pp new file mode 100644 index 000000000..39bc187c8 --- /dev/null +++ b/puppet/environment/development/manifests/configure_system.pp @@ -0,0 +1,9 @@ +### configure_system.pp: configure system with general requirements. +### +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### + +## define system timezone +include system::set_timezone \ No newline at end of file diff --git a/puppet/environment/development/manifests/configure_webserver.pp b/puppet/environment/development/manifests/configure_webserver.pp new file mode 100644 index 000000000..0a92bd1c0 --- /dev/null +++ b/puppet/environment/development/manifests/configure_webserver.pp @@ -0,0 +1,12 @@ +### configure_webserver.pp: implement webserver, with necessary dependencies. +### +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### + +## create log directory +include system::log_directory + +## install webserver +include webserver::service \ No newline at end of file diff --git a/puppet/environment/development/manifests/install_packages.pp b/puppet/environment/development/manifests/install_packages.pp new file mode 100644 index 000000000..3b86b92f4 --- /dev/null +++ b/puppet/environment/development/manifests/install_packages.pp @@ -0,0 +1,39 @@ +### install_packages.pp: install general packages. +### +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### + +## nodejs, with npm: this cannot be wrapped into a module, and included, as +# needed. Puppet will only allow one instance of this class, regardless of +# of its implementation. +class install_nodejs { + ## set dependency + require apt + + ## install nodejs, with npm + class { 'nodejs': + repo_url_suffix => '5.x', + } + contain nodejs +} + +## general packages +class general_packages { + ## set dependency + require apt + require install_nodejs + + ## install packages + contain package::dos2unix + contain package::inotify_tools + contain package::react_presets + contain package::jsonschema + contain package::xmltodict + contain package::six + contain system::webcompiler_directories +} + +## initiate +include general_packages \ No newline at end of file diff --git a/puppet/environment/development/manifests/install_sklearn.pp b/puppet/environment/development/manifests/install_sklearn.pp new file mode 100644 index 000000000..c5eef6a4a --- /dev/null +++ b/puppet/environment/development/manifests/install_sklearn.pp @@ -0,0 +1,21 @@ +### install_sklearn.pp: install sklearn, with all necessary dependencies. +### +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### + +## create '/vagrant/build/' directory +include system::build_directory + +## install sklearn dependencies +include package::sklearn_dependencies + +## download scikit-learn +include package::sklearn + +## build scikit-learn +include sklearn::build_sklearn + +## install scikit-learn +include sklearn::install_sklearn \ No newline at end of file diff --git a/puppet/environment/development/manifests/setup_database.pp b/puppet/environment/development/manifests/setup_database.pp new file mode 100644 index 000000000..0e99946ef --- /dev/null +++ b/puppet/environment/development/manifests/setup_database.pp @@ -0,0 +1,19 @@ +### setup_database.pp: install client, server, bindings, and initialize +### database with required tables. +### +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### + +## install mariadb +include database::server + +## install mariadb client +include database::client + +## install mariad bindings +include database::bindings + +## create database tables +include database::database \ No newline at end of file diff --git a/puppet/environment/development/manifests/start_webserver.pp b/puppet/environment/development/manifests/start_webserver.pp new file mode 100644 index 000000000..fea34fdbb --- /dev/null +++ b/puppet/environment/development/manifests/start_webserver.pp @@ -0,0 +1,9 @@ +### start_webserver.pp: start webserver. +### +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### + +## start webservers +include webserver::start \ No newline at end of file diff --git a/puppet/environment/development/manifests/vagrant_mounted.pp b/puppet/environment/development/manifests/vagrant_mounted.pp new file mode 100644 index 000000000..1b748941b --- /dev/null +++ b/puppet/environment/development/manifests/vagrant_mounted.pp @@ -0,0 +1,17 @@ +### vagrant_mounted.pp: ensure 'vagrant-mounted' event fires, when '/vagrant' +### shared directory, is mounted within the guest virtual +### machine. +### +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### + +## install dos2unix +include package::dos2unix + +## configure service +include vagrant::service + +## start service +include vagrant::start \ No newline at end of file diff --git a/puppet/environment/development/modules/compiler/manifests/initial_compile.pp b/puppet/environment/development/modules/compiler/manifests/initial_compile.pp new file mode 100644 index 000000000..7ac0e7062 --- /dev/null +++ b/puppet/environment/development/modules/compiler/manifests/initial_compile.pp @@ -0,0 +1,34 @@ +### Note: the prefix 'compiler::::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class compiler::initial_compile { + $sources = [ + 'jsx', + 'img', + 'scss', + 'js' + ] + + $sources.each |String $source| { + ## variables + $check_files = "if [ \"$(ls -A /vagrant/src/${source}/)\" ];" + $touch_files = "then touch /vagrant/src/${source}/*; fi" + + ## touch source: ensure initial build compiles every source file. + # + # @touch, changes the modification time to the current system time. + # + # Note: the current inotifywait implementation watches close_write, move, + # and create. However, the source files will already exist before + # this 'inotifywait', since the '/vagrant' directory will already + # have been mounted on the initial build. + # + # Note: every 'command' implementation checks if directory is nonempty, + # then touch all files in the directory, respectively. + exec { "touch-${source}-files": + command => "${check_files} ${touch_files}", + provider => shell, + } + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/compiler/manifests/start_browserify.pp b/puppet/environment/development/modules/compiler/manifests/start_browserify.pp new file mode 100644 index 000000000..0652d05f8 --- /dev/null +++ b/puppet/environment/development/modules/compiler/manifests/start_browserify.pp @@ -0,0 +1,10 @@ +### Note: the prefix 'compiler::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class compiler::start_browserify { + service { 'browserify': + ensure => 'running', + enable => true, + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/compiler/manifests/start_imagemin.pp b/puppet/environment/development/modules/compiler/manifests/start_imagemin.pp new file mode 100644 index 000000000..f64c9e250 --- /dev/null +++ b/puppet/environment/development/modules/compiler/manifests/start_imagemin.pp @@ -0,0 +1,10 @@ +### Note: the prefix 'compiler::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class compiler::start_imagemin { + service { 'imagemin': + ensure => 'running', + enable => true, + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/compiler/manifests/start_sass.pp b/puppet/environment/development/modules/compiler/manifests/start_sass.pp new file mode 100644 index 000000000..076b35be5 --- /dev/null +++ b/puppet/environment/development/modules/compiler/manifests/start_sass.pp @@ -0,0 +1,10 @@ +### Note: the prefix 'compiler::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class compiler::start_sass { + service { 'sass': + ensure => 'running', + enable => true, + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/compiler/manifests/start_uglifyjs.pp b/puppet/environment/development/modules/compiler/manifests/start_uglifyjs.pp new file mode 100644 index 000000000..67c5f9817 --- /dev/null +++ b/puppet/environment/development/modules/compiler/manifests/start_uglifyjs.pp @@ -0,0 +1,10 @@ +### Note: the prefix 'compiler::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class compiler::start_uglifyjs { + service { 'uglifyjs': + ensure => 'running', + enable => true, + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/compiler/manifests/webcompilers.pp b/puppet/environment/development/modules/compiler/manifests/webcompilers.pp new file mode 100644 index 000000000..1061831dd --- /dev/null +++ b/puppet/environment/development/modules/compiler/manifests/webcompilers.pp @@ -0,0 +1,52 @@ +### Note: the prefix 'compiler::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class compiler::webcompilers { + ## variables + $environment = 'development' + + $compilers = [ + 'browserify', + 'imagemin', + 'sass', + 'uglifyjs' + ] + + $compilers.each |String $compiler| { + ## create startup script: for webcompilers, using puppet templating + file { "${compiler}-startup-script": + path => "/etc/init/${compiler}.conf", + ensure => 'present', + content => template("/vagrant/puppet/environment/${environment}/template/webcompilers.erb"), + notify => Exec["dos2unix-upstart-${compiler}"], + } + + ## dos2unix upstart: convert clrf (windows to linux) in case host machine + # is windows. + # + # @notify, ensure the webserver service is started. This is similar to an + # exec statement, where the 'refreshonly => true' would be implemented + # on the corresponding listening end point. But, the 'service' end + # point does not require the 'refreshonly' attribute. + exec { "dos2unix-upstart-${compiler}": + command => "dos2unix /etc/init/${compiler}.conf", + refreshonly => true, + notify => Exec["dos2unix-bash-${compiler}"], + path => '/usr/bin', + } + + ## dos2unix bash: convert clrf (windows to linux) in case host machine is + # windows. + # + # @notify, ensure the webserver service is started. This is similar to an + # exec statement, where the 'refreshonly => true' would be implemented + # on the corresponding listening end point. But, the 'service' end + # point does not require the 'refreshonly' attribute. + exec { "dos2unix-bash-${compiler}": + command => "dos2unix /vagrant/puppet/environment/${environment}/scripts/${compiler}", + refreshonly => true, + path => '/usr/bin', + } + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/database/manifests/bindings.pp b/puppet/environment/development/modules/database/manifests/bindings.pp new file mode 100644 index 000000000..97ae257d4 --- /dev/null +++ b/puppet/environment/development/modules/database/manifests/bindings.pp @@ -0,0 +1,9 @@ +### Note: the prefix 'database::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class database::bindings { + class {'::mysql::bindings': + python_enable => true, + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/database/manifests/client.pp b/puppet/environment/development/modules/database/manifests/client.pp new file mode 100644 index 000000000..161483b3b --- /dev/null +++ b/puppet/environment/development/modules/database/manifests/client.pp @@ -0,0 +1,10 @@ +### Note: the prefix 'database::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class database::client { + ## mysql::client: install, and configure mariadb-client + class {'::mysql::client': + package_name => 'mariadb-client', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/database/manifests/database.pp b/puppet/environment/development/modules/database/manifests/database.pp new file mode 100644 index 000000000..0003519d4 --- /dev/null +++ b/puppet/environment/development/modules/database/manifests/database.pp @@ -0,0 +1,18 @@ +### Note: the prefix 'database::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class database::database { + ## variables + $environment = 'development' + + ## define database tables + # + # @require, syntax involves 'Class Containment'. For more information, + # https://puppetlabs.com/blog/class-containment-puppet + exec {'create-database-tables': + command => 'python setup_tables.py', + cwd => "/vagrant/puppet/environment/${environment}/scripts/", + path => '/usr/bin', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/database/manifests/server.pp b/puppet/environment/development/modules/database/manifests/server.pp new file mode 100644 index 000000000..31eac08c7 --- /dev/null +++ b/puppet/environment/development/modules/database/manifests/server.pp @@ -0,0 +1,55 @@ +### Note: the prefix 'database::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class database::server { + ## mysql::server: install, and configure mariadb-server + # + # @password_hash, default password (can be adjusted via cli) + # @max_connections_per_hour, @max_queries_per_hour, @max_updates_per_hour, + # @max_user_connections, a zero value indicates no limit + class {'::mysql::server': + package_name => 'mariadb-server', + root_password => 'password', + users => { + 'authenticated@localhost' => { + ensure => 'present', + max_connections_per_hour => '0', + max_queries_per_hour => '0', + max_updates_per_hour => '0', + max_user_connections => '0', + password_hash => mysql_password('password'), + }, + 'provisioner@localhost' => { + ensure => 'present', + max_connections_per_hour => '1', + max_queries_per_hour => '0', + max_updates_per_hour => '0', + max_user_connections => '1', + password_hash => mysql_password('password'), + }, + }, + grants => { + 'authenticated@localhost/db_machine_learning.*' => { + ensure => 'present', + options => ['GRANT'], + privileges => ['INSERT', 'DELETE', 'UPDATE', 'SELECT'], + table => 'db_machine_learning.*', + user => 'authenticated@localhost', + }, + 'provisioner@localhost/db_machine_learning.*' => { + ensure => 'present', + options => ['GRANT'], + privileges => ['CREATE'], + table => 'db_machine_learning.*', + user => 'provisioner@localhost', + }, + }, + databases => { + 'db_machine_learning' => { + ensure => 'present', + charset => 'utf8', + }, + }, + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/package/manifests/dos2unix.pp b/puppet/environment/development/modules/package/manifests/dos2unix.pp new file mode 100644 index 000000000..17977fd1c --- /dev/null +++ b/puppet/environment/development/modules/package/manifests/dos2unix.pp @@ -0,0 +1,12 @@ +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class package::dos2unix { + ## update apt-get + include apt + + package { 'dos2unix': + ensure => 'installed', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/package/manifests/inotify_tools.pp b/puppet/environment/development/modules/package/manifests/inotify_tools.pp new file mode 100644 index 000000000..5bde39070 --- /dev/null +++ b/puppet/environment/development/modules/package/manifests/inotify_tools.pp @@ -0,0 +1,12 @@ +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class package::inotify_tools { + ## update apt-get + include apt + + package { 'inotify-tools': + ensure => 'installed', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/package/manifests/jsonschema.pp b/puppet/environment/development/modules/package/manifests/jsonschema.pp new file mode 100644 index 000000000..1c4a7ab57 --- /dev/null +++ b/puppet/environment/development/modules/package/manifests/jsonschema.pp @@ -0,0 +1,12 @@ +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class package::jsonschema { + include python + + package { 'jsonschema': + ensure => 'installed', + provider => 'pip', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/package/manifests/react_presets.pp b/puppet/environment/development/modules/package/manifests/react_presets.pp new file mode 100644 index 000000000..a5d62fd71 --- /dev/null +++ b/puppet/environment/development/modules/package/manifests/react_presets.pp @@ -0,0 +1,12 @@ +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class package::react_presets { + ## install babelify presets for reactjs (npm) + exec { 'install-babelify-presets': + command => 'npm install --no-bin-links', + cwd => '/vagrant/src/jsx/', + path => '/usr/bin', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/package/manifests/redis.pp b/puppet/environment/development/modules/package/manifests/redis.pp new file mode 100644 index 000000000..2ac38650a --- /dev/null +++ b/puppet/environment/development/modules/package/manifests/redis.pp @@ -0,0 +1,12 @@ +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class package::redis { + include python + + package { 'redis': + ensure => 'installed', + provider => 'pip', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/package/manifests/redis_server.pp b/puppet/environment/development/modules/package/manifests/redis_server.pp new file mode 100644 index 000000000..1ab6c8d9f --- /dev/null +++ b/puppet/environment/development/modules/package/manifests/redis_server.pp @@ -0,0 +1,9 @@ +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class package::redis { + package { 'redis-server': + ensure => 'installed', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/package/manifests/six.pp b/puppet/environment/development/modules/package/manifests/six.pp new file mode 100644 index 000000000..676a4f522 --- /dev/null +++ b/puppet/environment/development/modules/package/manifests/six.pp @@ -0,0 +1,12 @@ +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class package::six { + include python + + package { 'six': + ensure => 'installed', + provider => 'pip', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/package/manifests/sklearn.pp b/puppet/environment/development/modules/package/manifests/sklearn.pp new file mode 100644 index 000000000..be0c6d6b5 --- /dev/null +++ b/puppet/environment/development/modules/package/manifests/sklearn.pp @@ -0,0 +1,14 @@ +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class package::sklearn { + include git + + vcsrepo {'/vagrant/build/scikit-learn': + ensure => present, + provider => git, + source => 'https://github.com/scikit-learn/scikit-learn', + revision => '0.16.1', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/package/manifests/sklearn_dependencies.pp b/puppet/environment/development/modules/package/manifests/sklearn_dependencies.pp new file mode 100644 index 000000000..891d15b19 --- /dev/null +++ b/puppet/environment/development/modules/package/manifests/sklearn_dependencies.pp @@ -0,0 +1,20 @@ +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class package::sklearn_dependencies { + ## variables + $dependencies = [ + 'python-dev', + 'python-numpy', + 'python-numpy-dev', + 'python-scipy', + 'libatlas-dev', + 'g++', + 'python-matplotlib', + 'ipython' + ] + + ## install dependencies + ensure_packages( $dependencies ) +} \ No newline at end of file diff --git a/puppet/environment/development/modules/package/manifests/webcompilers.pp b/puppet/environment/development/modules/package/manifests/webcompilers.pp new file mode 100644 index 000000000..e860103cb --- /dev/null +++ b/puppet/environment/development/modules/package/manifests/webcompilers.pp @@ -0,0 +1,36 @@ +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class package::webcompilers { + ## variables + $webcompilers = [ + 'uglify-js', + 'imagemin', + 'node-sass', + 'babel-core', + 'browserify', + 'babelify' + ] + + ## print node / npm version + exec { 'echo-general-notice': + command => 'echo "installing npm packages with: "', + path => '/bin', + notify => Exec['echo-versions'], + logoutput => true, + } + exec { 'echo-versions': + command => 'npm -v && node -v', + path => '/usr/bin', + refreshonly => true, + before => Package[$webcompilers], + logoutput => true, + } + + ## packages: install general packages (npm) + package { $webcompilers: + ensure => 'present', + provider => 'npm', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/package/manifests/xmltodict.pp b/puppet/environment/development/modules/package/manifests/xmltodict.pp new file mode 100644 index 000000000..d53976f6f --- /dev/null +++ b/puppet/environment/development/modules/package/manifests/xmltodict.pp @@ -0,0 +1,12 @@ +### Note: the prefix 'package::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class package::xmltodict { + include python + + package { 'xmltodict': + ensure => 'installed', + provider => 'pip', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/redis/manifests/client.pp b/puppet/environment/development/modules/redis/manifests/client.pp new file mode 100644 index 000000000..8e4ddbdd2 --- /dev/null +++ b/puppet/environment/development/modules/redis/manifests/client.pp @@ -0,0 +1,12 @@ +### Note: the prefix 'redis::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class redis::client { + include python + + package { 'redis': + ensure => 'installed', + provider => 'pip', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/redis/manifests/server.pp b/puppet/environment/development/modules/redis/manifests/server.pp new file mode 100644 index 000000000..adb43f7b5 --- /dev/null +++ b/puppet/environment/development/modules/redis/manifests/server.pp @@ -0,0 +1,11 @@ +### Note: the prefix 'redis::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class redis::server { + include python + + package { 'redis-server': + ensure => 'installed', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/sklearn/manifests/build_sklearn.pp b/puppet/environment/development/modules/sklearn/manifests/build_sklearn.pp new file mode 100644 index 000000000..57c12a4b4 --- /dev/null +++ b/puppet/environment/development/modules/sklearn/manifests/build_sklearn.pp @@ -0,0 +1,11 @@ +### Note: the prefix 'sklearn::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class sklearn::build_sklearn { + exec {'build-sklearn': + command => 'python setup.py build', + cwd => '/vagrant/build/scikit-learn/', + path => '/usr/bin', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/sklearn/manifests/install_sklearn.pp b/puppet/environment/development/modules/sklearn/manifests/install_sklearn.pp new file mode 100644 index 000000000..5060a1178 --- /dev/null +++ b/puppet/environment/development/modules/sklearn/manifests/install_sklearn.pp @@ -0,0 +1,14 @@ +### Note: the prefix 'sklearn::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class sklearn::install_sklearn { + ## set dependency + require python + + exec {'install-sklearn': + command => 'python setup.py install', + cwd => '/vagrant/build/scikit-learn/', + path => '/usr/bin', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/system/manifests/build_directory.pp b/puppet/environment/development/modules/system/manifests/build_directory.pp new file mode 100644 index 000000000..e01796c65 --- /dev/null +++ b/puppet/environment/development/modules/system/manifests/build_directory.pp @@ -0,0 +1,9 @@ +### Note: the prefix 'system::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class system::build_directory { + file {'/vagrant/build/': + ensure => 'directory', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/system/manifests/log_directory.pp b/puppet/environment/development/modules/system/manifests/log_directory.pp new file mode 100644 index 000000000..f06b48744 --- /dev/null +++ b/puppet/environment/development/modules/system/manifests/log_directory.pp @@ -0,0 +1,9 @@ +### Note: the prefix 'system::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class system::log_directory { + file {'/vagrant/log/': + ensure => 'directory', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/system/manifests/set_timezone.pp b/puppet/environment/development/modules/system/manifests/set_timezone.pp new file mode 100644 index 000000000..f7a607e75 --- /dev/null +++ b/puppet/environment/development/modules/system/manifests/set_timezone.pp @@ -0,0 +1,10 @@ +### Note: the prefix 'system::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class system::set_timezone { + class { 'timezone': + region => 'America', + locality => 'New_York', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/system/manifests/webcompiler_directories.pp b/puppet/environment/development/modules/system/manifests/webcompiler_directories.pp new file mode 100644 index 000000000..c30efb6dc --- /dev/null +++ b/puppet/environment/development/modules/system/manifests/webcompiler_directories.pp @@ -0,0 +1,48 @@ +### Note: the prefix 'system::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class system::webcompiler_directories { + $directories = { + browserify => { + src => 'jsx', + asset => 'js', + asset_dir => true, + src_dir => true, + }, + imagemin => { + src => 'img', + asset => 'img', + asset_dir => true, + src_dir => true, + }, + sass => { + src => 'scss', + asset => 'css', + asset_dir => true, + src_dir => true, + }, + uglifyjs => { + src => 'js', + asset => 'js', + asset_dir => false, + src_dir => false, + } + } + + $directories.each |String $directory, Hash $type| { + ## create asset directories (if not exist) + if ($type['asset_dir']) { + file { "/vagrant/interface/static/${type['asset']}/": + ensure => 'directory', + } + } + + ## create src directories (if not exist) + if ($type['src_dir']) { + file { "/vagrant/src/${type['src']}/": + ensure => 'directory', + } + } + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/vagrant/manifests/service.pp b/puppet/environment/development/modules/vagrant/manifests/service.pp new file mode 100644 index 000000000..d7f18c946 --- /dev/null +++ b/puppet/environment/development/modules/vagrant/manifests/service.pp @@ -0,0 +1,30 @@ +### Note: the prefix 'vagrant::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class vagrant::service { + ## variables + $mountpoint = '/vagrant/' + $environment = 'development' + + ## create startup script: for 'vagrant-mounted' event + file { 'vagrant-startup-script': + path => '/etc/init/workaround-vagrant-bug-6074.conf', + ensure => 'present', + content => template("/vagrant/puppet/environment/${environment}/template/vagrant_mounted.erb"), + notify => Exec['dos2unix-upstart-vagrant'], + } + + ## dos2unix upstart: convert clrf (windows to linux) in case host machine + # is windows. + # + # @notify, ensure the webserver service is started. This is similar to an + # exec statement, where the 'refreshonly => true' would be implemented + # on the corresponding listening end point. But, the 'service' end point + # does not require the 'refreshonly' attribute. + exec { 'dos2unix-upstart-vagrant': + command => 'dos2unix /etc/init/workaround-vagrant-bug-6074.conf', + refreshonly => true, + path => '/usr/bin', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/vagrant/manifests/start.pp b/puppet/environment/development/modules/vagrant/manifests/start.pp new file mode 100644 index 000000000..ac19ae7dd --- /dev/null +++ b/puppet/environment/development/modules/vagrant/manifests/start.pp @@ -0,0 +1,10 @@ +### Note: the prefix 'vagrant::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class vagrant::start { + service {'workaround-vagrant-bug-6074': + ensure => 'running', + enable => true, + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/webserver/manifests/service.pp b/puppet/environment/development/modules/webserver/manifests/service.pp new file mode 100644 index 000000000..3f97fce79 --- /dev/null +++ b/puppet/environment/development/modules/webserver/manifests/service.pp @@ -0,0 +1,34 @@ +### Note: the prefix 'webserver::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class webserver::service { + ## variables + $environment = 'development' + + ## include webserver dependencies + include python + include python::flask + include python::requests + + ## define webserver + file { 'server-startup-script': + path => '/etc/init/flask.conf', + ensure => 'present', + content => template("/vagrant/puppet/environment/${environment}/template/webserver.erb"), + notify => Exec['dos2unix-flask'], + } + + ## convert clrf (windows to linux) in case host machine is windows. + # + # @notify, ensure the webserver service is started. This is similar + # to an exec statement, where the 'refreshonly => true' would be + # implemented on the corresponding listening end point. But, the + # 'service' end point does not require the 'refreshonly' + # attribute. + exec { 'dos2unix-flask': + command => 'dos2unix /etc/init/flask.conf', + refreshonly => true, + path => '/usr/bin/', + } +} \ No newline at end of file diff --git a/puppet/environment/development/modules/webserver/manifests/start.pp b/puppet/environment/development/modules/webserver/manifests/start.pp new file mode 100644 index 000000000..9dbcdd2c3 --- /dev/null +++ b/puppet/environment/development/modules/webserver/manifests/start.pp @@ -0,0 +1,11 @@ +### Note: the prefix 'vagrant::', corresponds to a puppet convention: +### +### https://github.com/jeff1evesque/machine-learning/issues/2349 +### +class webserver::start { + ## start webserver + service { 'flask': + ensure => 'running', + enable => true, + } +} \ No newline at end of file diff --git a/puppet/scripts/Puppetfile b/puppet/environment/development/scripts/Puppetfile similarity index 100% rename from puppet/scripts/Puppetfile rename to puppet/environment/development/scripts/Puppetfile diff --git a/puppet/environment/development/scripts/__init__.py b/puppet/environment/development/scripts/__init__.py new file mode 100644 index 000000000..e76630aea --- /dev/null +++ b/puppet/environment/development/scripts/__init__.py @@ -0,0 +1,4 @@ +"""@__init__ +This file allows the containing directory to be considered a python package, +consisting of python module(s). +""" diff --git a/puppet/scripts/browserify b/puppet/environment/development/scripts/browserify similarity index 100% rename from puppet/scripts/browserify rename to puppet/environment/development/scripts/browserify diff --git a/puppet/scripts/imagemin b/puppet/environment/development/scripts/imagemin similarity index 100% rename from puppet/scripts/imagemin rename to puppet/environment/development/scripts/imagemin diff --git a/puppet/scripts/puppet_updater.sh b/puppet/environment/development/scripts/puppet_updater.sh similarity index 100% rename from puppet/scripts/puppet_updater.sh rename to puppet/environment/development/scripts/puppet_updater.sh diff --git a/puppet/scripts/sass b/puppet/environment/development/scripts/sass similarity index 100% rename from puppet/scripts/sass rename to puppet/environment/development/scripts/sass diff --git a/puppet/scripts/setup_tables.py b/puppet/environment/development/scripts/setup_tables.py similarity index 100% rename from puppet/scripts/setup_tables.py rename to puppet/environment/development/scripts/setup_tables.py diff --git a/puppet/scripts/uglifyjs b/puppet/environment/development/scripts/uglifyjs similarity index 100% rename from puppet/scripts/uglifyjs rename to puppet/environment/development/scripts/uglifyjs diff --git a/puppet/template/enable_multiverse_1.erb b/puppet/environment/development/template/enable_multiverse_1.erb similarity index 100% rename from puppet/template/enable_multiverse_1.erb rename to puppet/environment/development/template/enable_multiverse_1.erb diff --git a/puppet/template/enable_multiverse_2.erb b/puppet/environment/development/template/enable_multiverse_2.erb similarity index 100% rename from puppet/template/enable_multiverse_2.erb rename to puppet/environment/development/template/enable_multiverse_2.erb diff --git a/puppet/template/vagrant_mounted.erb b/puppet/environment/development/template/vagrant_mounted.erb similarity index 100% rename from puppet/template/vagrant_mounted.erb rename to puppet/environment/development/template/vagrant_mounted.erb diff --git a/puppet/template/webcompilers.erb b/puppet/environment/development/template/webcompilers.erb similarity index 95% rename from puppet/template/webcompilers.erb rename to puppet/environment/development/template/webcompilers.erb index 0655e9f15..fec541c49 100644 --- a/puppet/template/webcompilers.erb +++ b/puppet/environment/development/template/webcompilers.erb @@ -25,7 +25,7 @@ expect fork ## start upstart job # # @chdir, change the current working directory -chdir /vagrant/puppet/scripts/ +chdir /vagrant/puppet/environment/development/scripts exec ./<%= @compiler %> ## log start-up date diff --git a/puppet/template/webserver.erb b/puppet/environment/development/template/webserver.erb similarity index 100% rename from puppet/template/webserver.erb rename to puppet/environment/development/template/webserver.erb diff --git a/puppet/manifests/compile_asset.pp b/puppet/manifests/compile_asset.pp deleted file mode 100644 index 204f1181e..000000000 --- a/puppet/manifests/compile_asset.pp +++ /dev/null @@ -1,117 +0,0 @@ -## define $PATH for all execs, and packages -Exec {path => ['/usr/bin/', '/sbin/', '/bin/', '/usr/share/']} - -## variables -# -# @asset_dir, indicate whether to create corresponding asset directory. -# -# @src_dir, indicate whether to create corresponding source directory. -# -# Note: hash iteration is done alphabetically. -$compilers = { - browserify => { - src => 'jsx', - asset => 'js', - asset_dir => true, - src_dir => true, - }, - imagemin => { - src => 'img', - asset => 'img', - asset_dir => true, - src_dir => true, - }, - sass => { - src => 'scss', - asset => 'css', - asset_dir => true, - src_dir => true, - }, - uglifyjs => { - src => 'js', - asset => 'js', - asset_dir => false, - src_dir => false, - } -} - -## dynamically create compilers -$compilers.each |String $compiler, Hash $resource| { - ## variables - $check_files = "if [ \"$(ls -A /vagrant/src/${resource['src']}/)\" ];" - $touch_files = "then touch /vagrant/src/${resource['src']}/*; fi" - - ## create asset directories (if not exist) - if ($resource['asset_dir']) { - file {"/vagrant/interface/static/${resource['asset']}/": - ensure => 'directory', - before => File["${compiler}-startup-script"], - } - } - - ## create src directories (if not exist) - if ($resource['src_dir']) { - file {"/vagrant/src/${resource['src']}/": - ensure => 'directory', - before => File["${compiler}-startup-script"], - } - } - - ## create startup script: for webcompilers, using puppet templating - file {"${compiler}-startup-script": - path => "/etc/init/${compiler}.conf", - ensure => 'present', - content => template('/vagrant/puppet/template/webcompilers.erb'), - notify => Exec["dos2unix-upstart-${compiler}"], - } - - ## dos2unix upstart: convert clrf (windows to linux) in case host machine - # is windows. - # - # @notify, ensure the webserver service is started. This is similar to an - # exec statement, where the 'refreshonly => true' would be implemented - # on the corresponding listening end point. But, the 'service' end - # point does not require the 'refreshonly' attribute. - exec {"dos2unix-upstart-${compiler}": - command => "dos2unix /etc/init/${compiler}.conf", - refreshonly => true, - notify => Exec["dos2unix-bash-${compiler}"], - } - - ## dos2unix bash: convert clrf (windows to linux) in case host machine is - # windows. - # - # @notify, ensure the webserver service is started. This is similar to an - # exec statement, where the 'refreshonly => true' would be implemented - # on the corresponding listening end point. But, the 'service' end - # point does not require the 'refreshonly' attribute. - exec {"dos2unix-bash-${compiler}": - command => "dos2unix /vagrant/puppet/scripts/${compiler}", - refreshonly => true, - notify => Service[$compiler], - } - - ## start ${compiler} service - service {$compiler: - ensure => 'running', - enable => true, - notify => Exec["touch-${resource['src']}-files"], - } - - ## touch source: ensure initial build compiles every source file. - # - # @touch, changes the modification time to the current system time. - # - # Note: the current inotifywait implementation watches close_write, move, - # and create. However, the source files will already exist before - # this 'inotifywait', since the '/vagrant' directory will already - # have been mounted on the initial build. - # - # Note: every 'command' implementation checks if directory is nonempty, - # then touch all files in the directory, respectively. - exec {"touch-${resource['src']}-files": - command => "${check_files} ${touch_files}", - refreshonly => true, - provider => shell, - } -} \ No newline at end of file diff --git a/puppet/manifests/configure_system.pp b/puppet/manifests/configure_system.pp deleted file mode 100644 index 96ccb32e0..000000000 --- a/puppet/manifests/configure_system.pp +++ /dev/null @@ -1,8 +0,0 @@ -## define $PATH for all execs, and packages -Exec {path => ['/usr/bin/']} - -## define system timezone -class {'timezone': - region => 'America', - locality => 'New_York', -} \ No newline at end of file diff --git a/puppet/manifests/install_packages.pp b/puppet/manifests/install_packages.pp deleted file mode 100644 index a6e95bd8f..000000000 --- a/puppet/manifests/install_packages.pp +++ /dev/null @@ -1,98 +0,0 @@ -## include puppet modules: this (also) runs 'apt-get update' -include python -include apt - -class { 'nodejs': - repo_url_suffix => 'node_5.x', -} - -## variables -case $::osfamily { - 'redhat': { - $packages_general = ['dos2unix', 'inotify-tools', 'ruby-devel'] - } - 'debian': { - $packages_general = ['dos2unix', 'inotify-tools', 'ruby-dev'] - } - default: { - } -} - -$packages_build_dep = ['matplotlib', 'scikit-learn'] -$packages_general_pip = [ - 'redis', - 'jsonschema', - 'xmltodict', - 'six', - 'matplotlib' -] -$packages_general_npm = [ - 'uglify-js', - 'imagemin', - 'node-sass', - 'babel-core', - 'browserify', - 'babelify' -] -$packages_build_size = size($packages_build_dep) - 1 - -## define $PATH for all execs, and packages -Exec { - path => ['/usr/bin/', '/bin/', '/usr/local', '/usr/sbin/', '/sbin/'], -} - -## enable 'multiverse' repository (part 1, replace line) -exec {'enable-multiverse-repository-1': - command => template('/vagrant/puppet/template/enable_multiverse_1.erb'), - notify => Exec["build-package-dependencies-${packages_build_size}"], -} - -## enable 'multiverse' repository (part 2, replace line) -exec {'enable-multiverse-repository-2': - command => template('/vagrant/puppet/template/enable_multiverse_2.erb'), - notify => Exec["build-package-dependencies-${packages_build_size}"], -} - -## build package dependencies -each($packages_build_dep) |$index, $package| { - exec {"build-package-dependencies-${index}": - command => "apt-get build-dep ${package} -y", - before => Package[$packages_general], - refreshonly => true, - timeout => 1400, - } -} - -## packages: install general packages (apt, yum) -package {$packages_general: - ensure => 'installed', - before => Package[$packages_general_pip], -} - -## packages: install general packages (pip) -package {$packages_general_pip: - ensure => 'installed', - provider => 'pip', - before => Package[$packages_general_npm], -} - -## packages: install general packages (npm) -package {$packages_general_npm: - ensure => 'present', - provider => 'npm', - notify => Exec['install-babelify-presets'], - require => Package['npm'], -} - -## packages: install babelify presets for reactjs (npm) -exec {'install-babelify-presets': - command => 'npm install --no-bin-links', - cwd => '/vagrant/src/jsx/', - before => Package['redis-server'], - refreshonly => true, -} - -## package: install redis-server -package {'redis-server': - ensure => 'installed', -} \ No newline at end of file diff --git a/puppet/manifests/install_sklearn.pp b/puppet/manifests/install_sklearn.pp deleted file mode 100644 index b98951000..000000000 --- a/puppet/manifests/install_sklearn.pp +++ /dev/null @@ -1,36 +0,0 @@ -## include puppet modules: this (also) runs 'apt-get update' -include git - -## define $PATH for all execs -Exec {path => ['/usr/bin/']} - -## create '/vagrant/build/' directory -file {'/vagrant/build/': - ensure => 'directory', - before => Vcsrepo['/vagrant/build/scikit-learn'], -} - -## download scikit-learn -vcsrepo {'/vagrant/build/scikit-learn': - ensure => present, - provider => git, - source => 'https://github.com/scikit-learn/scikit-learn', - revision => '0.16.1', - before => Exec['build-sklearn'], - notify => Exec['build-sklearn'], -} - -## build scikit-learn -exec {'build-sklearn': - command => 'python setup.py build', - cwd => '/vagrant/build/scikit-learn/', - notify => Exec['install-sklearn'], - refreshonly => true, -} - -## install scikit-learn -exec {'install-sklearn': - command => 'python setup.py install', - cwd => '/vagrant/build/scikit-learn/', - refreshonly => true, -} \ No newline at end of file diff --git a/puppet/manifests/setup_database.pp b/puppet/manifests/setup_database.pp deleted file mode 100644 index 8871bd3b1..000000000 --- a/puppet/manifests/setup_database.pp +++ /dev/null @@ -1,74 +0,0 @@ -## define $PATH for all execs, and packages -Exec {path => ['/usr/bin/']} - -## mysql::server: install, and configure mariadb-server -# -# @password_hash, default password (can be adjusted via cli) -# @max_connections_per_hour, @max_queries_per_hour, @max_updates_per_hour, -# @max_user_connections, a zero value indicates no limit -class {'::mysql::server': - package_name => 'mariadb-server', - root_password => 'password', - users => { - 'authenticated@localhost' => { - ensure => 'present', - max_connections_per_hour => '0', - max_queries_per_hour => '0', - max_updates_per_hour => '0', - max_user_connections => '0', - password_hash => mysql_password('password'), - }, - 'provisioner@localhost' => { - ensure => 'present', - max_connections_per_hour => '1', - max_queries_per_hour => '0', - max_updates_per_hour => '0', - max_user_connections => '1', - password_hash => mysql_password('password'), - }, - }, - grants => { - 'authenticated@localhost/db_machine_learning.*' => { - ensure => 'present', - options => ['GRANT'], - privileges => ['INSERT', 'DELETE', 'UPDATE', 'SELECT'], - table => 'db_machine_learning.*', - user => 'authenticated@localhost', - }, - 'provisioner@localhost/db_machine_learning.*' => { - ensure => 'present', - options => ['GRANT'], - privileges => ['CREATE'], - table => 'db_machine_learning.*', - user => 'provisioner@localhost', - }, - }, - databases => { - 'db_machine_learning' => { - ensure => 'present', - charset => 'utf8', - }, - } -} - -## mysql::client: install, and configure mariadb-client -class {'::mysql::client': - package_name => 'mariadb-client', - require => Class['::mysql::server'], -} - -## mysql::bindings: install python-mariadb bindings -class {'::mysql::bindings': - python_enable => true, - require => [Class['::mysql::client'], Class['::mysql::server']], -} - -## define database tables -# -# @require, syntax involves 'Class Containment'. For more information, -# https://puppetlabs.com/blog/class-containment-puppet -exec {'create-database-tables': - command => 'python setup_tables.py', - cwd => '/vagrant/puppet/scripts/', - require => Class['::mysql::bindings::python'], -} \ No newline at end of file diff --git a/puppet/manifests/start_webserver.pp b/puppet/manifests/start_webserver.pp deleted file mode 100644 index 448ad7fa5..000000000 --- a/puppet/manifests/start_webserver.pp +++ /dev/null @@ -1,48 +0,0 @@ -include python -include python::flask -include python::requests - -## define $PATH for all execs, and packages -Exec {path => ['/usr/bin/']} - -## create log directory -file {'/vagrant/log/': - ensure => 'directory', - before => File['server-startup-script'], -} - -## detect os family: create startup script, start flask server -case $::osfamily { - 'redhat': { - } - 'debian': { - ## create startup script (heredoc syntax) - file {'server-startup-script': - path => '/etc/init/flask.conf', - ensure => 'present', - content => template('/vagrant/puppet/template/webserver.erb'), - notify => Exec['dos2unix-flask'], - } - - ## convert clrf (windows to linux) in case host machine is windows. - # - # @notify, ensure the webserver service is started. This is similar - # to an exec statement, where the 'refreshonly => true' would be - # implemented on the corresponding listening end point. But, the - # 'service' end point does not require the 'refreshonly' - # attribute. - exec {'dos2unix-flask': - command => 'dos2unix /etc/init/flask.conf', - refreshonly => true, - notify => Service['flask'], - } - - ## start webserver - service {'flask': - ensure => 'running', - enable => true, - } - } - default: { - } -} \ No newline at end of file diff --git a/puppet/manifests/vagrant_mounted.pp b/puppet/manifests/vagrant_mounted.pp deleted file mode 100644 index f0902c9fe..000000000 --- a/puppet/manifests/vagrant_mounted.pp +++ /dev/null @@ -1,32 +0,0 @@ -## variables -$mountpoint = '/vagrant/' - -## define $PATH for all execs, and packages -Exec {path => ['/usr/bin/']} - -## create startup script: for 'vagrant-mounted' event -file {'vagrant-startup-script': - path => '/etc/init/workaround-vagrant-bug-6074.conf', - ensure => 'present', - content => template('/vagrant/puppet/template/vagrant_mounted.erb'), - notify => Exec['dos2unix-upstart-vagrant'], -} - -## dos2unix upstart: convert clrf (windows to linux) in case host machine -# is windows. -# -# @notify, ensure the webserver service is started. This is similar to an -# exec statement, where the 'refreshonly => true' would be implemented -# on the corresponding listening end point. But, the 'service' end point -# does not require the 'refreshonly' attribute. -exec {'dos2unix-upstart-vagrant': - command => 'dos2unix /etc/init/workaround-vagrant-bug-6074.conf', - refreshonly => true, - notify => Service['workaround-vagrant-bug-6074'], -} - -## start 'workaround-vagrant-bug-6074' service -service {'workaround-vagrant-bug-6074': - ensure => 'running', - enable => true, -} \ No newline at end of file diff --git a/puppet/scripts/flask_server b/puppet/scripts/flask_server deleted file mode 100644 index 5e7668efe..000000000 --- a/puppet/scripts/flask_server +++ /dev/null @@ -1,55 +0,0 @@ -#!upstart -description 'start flask server' - -## start job defined in this file after system services, and processes have -# already loaded (to prevent conflict). -# -# @vagrant-mounted, an event that executes after the shared folder is mounted -# -# @[2345], represents all configuration states with general linux, -# and networking access -start on (vagrant-mounted and runlevel [2345]) -## stop upstart job -stop on runlevel [!2345] -## restart upstart job continuously -respawn - -## start job defined in this file after system services, and processes -# have already loaded (to prevent conflict). -# -# @vagrant-mounted, an event that executes after the shared folder is -# mounted. -# @[2345], represents all configuration states with general linux, and -# networking access. -start on (vagrant-mounted and runlevel [2345]) - -## stop upstart job -stop on runlevel [!2345] - -## restart upstart job continuously -respawn - -# required for permission to write to '/vagrant/' files -setuid vagrant -setgid vagrant - -## run upstart job as a background process -expect fork - -## start upstart job -exec python '/vagrant/app.py' - -## log start-up date -# -# @[`date`], current date script executed -pre-start script - echo "[`date`] flask server starting" >> /vagrant/log/flask_server.log -end script - -## log shut-down date, then remove process id from log before -# '/vagrant' is unmounted. -# -# @[`date`], current date script executed -pre-stop script - echo "[`date`] flask server stopping" >> /vagrant/log/flask_server.log -end script \ No newline at end of file