example code: python2 and python3 install modules, script generators and ctf vulnerability/challenge module wrappers

This commit is contained in:
ts
2018-08-03 15:32:13 +01:00
parent 990d15a4c9
commit a6ff9c508b
79 changed files with 3796 additions and 2 deletions

View File

@@ -0,0 +1,61 @@
CONFIG = {
<% if @mode == 'django' -%>
'mode': 'django',
<% else -%>
'mode': 'wsgi',
<% end -%>
<% if @virtualenv -%>
'environment': {
<% if @osenv -%><% @osenv.sort.each do |key, value| -%>
'<%= key %>': '<%= value %>',
<% end -%><% end -%>
<% if @environment -%>
'ENVIRONMENT': '<%= @environment %>',
<% end -%>
'PYTHONPATH': '<%= @virtualenv %>'
},
<% end -%>
'working_dir': '<%= @dir %>',
'user': '<%= @owner %>',
'group': '<%= @group %>',
<% if @virtualenv -%>
'python': '<%= @virtualenv %>/bin/python',
<% else -%>
'python': '/usr/bin/python',
<% end -%>
'args': (
<% if @args.any? -%>
<% for arg in @args do -%>
'<%= arg %>',
<% end -%>
<% end -%>
<% if !@virtualenv and !@bind -%>
'--bind=unix:/tmp/gunicorn-<%= @name %>.socket',
<% elsif @virtualenv and !@bind -%>
'--bind=unix:<%= @virtualenv %>/<%= @name %>.socket',
<% else -%>
'--bind=<%= @bind %>',
<% end -%>
<% if @workers -%>
'--workers=<%= @workers %>',
<% else -%>
'--workers=<%= @processorcount.to_i*2 + 1 %>',
<% end -%>
'--timeout=<%= @timeout %>',
<% if @access_log_format -%>
'--access-logformat=<%= @access_log_format %>',
<% end -%>
<% if @accesslog -%>
'--access-logfile=<%= @accesslog %>',
<% end -%>
<% if @errorlog -%>
'--error-logfile=<%= @errorlog %>',
<% end -%>
<% if @log_level %>
'--log-level=<%= @log_level %>',
<% end -%>
<% if @mode != 'django' -%>
'<%= @appmodule %>',
<% end -%>
),
}

View File

@@ -0,0 +1,8 @@
# this file is managed by puppet
<%- @config.sort.map do |section,conf| -%>
[<%= section -%>]
<%- conf.sort.map do |key,value| -%>
<%= key %> = <%= value %>
<%- end -%>
<%- end -%>

View File

@@ -0,0 +1,20 @@
class { 'python':
version => 'system',
dev => true,
virtualenv => true,
}
python::gunicorn { 'vhost':
ensure => present,
virtualenv => '/var/www/project1',
mode => 'wsgi',
dir => '/var/www/project1/current',
bind => 'unix:/tmp/gunicorn.socket',
environment => 'prod',
appmodule => 'app:app',
osenv => {
'DBHOST' => 'dbserver.example.com'
},
timeout => 30,
template => 'python/gunicorn.erb',
}

View File

@@ -0,0 +1,5 @@
class { 'python':
version => 'system',
dev => true,
virtualenv => true,
}

View File

@@ -0,0 +1,10 @@
class { 'python':
version => 'system',
dev => true,
virtualenv => true,
}
python::pip { 'flask':
virtualenv => '/var/www/project1',
proxy => 'http://proxy.domain.com:3128',
}

View File

@@ -0,0 +1,12 @@
class { 'python':
pip => false,
version => '3',
}
python::pyvenv { '/opt/uwsgi':
}
python::pip { 'uwsgi':
ensure => 'latest',
virtualenv => '/opt/uwsgi'
}

View File

@@ -0,0 +1,16 @@
class { 'python':
version => 'system',
dev => true,
virtualenv => true,
}
python::requirements { '/var/www/project1/requirements.txt':
virtualenv => '/var/www/project1',
proxy => 'http://proxy.domain.com:3128',
}
python::requirements { '/var/www/project1/requirements.txt':
virtualenv => 'system',
proxy => 'http://proxy.domain.com:3128',
timeout => 2400,
}

View File

@@ -0,0 +1,13 @@
class { 'python':
version => 'system',
dev => true,
virtualenv => true,
}
python::virtualenv { '/var/www/project1':
ensure => present,
version => 'system',
requirements => '/var/www/project1/requirements.txt',
proxy => 'http://proxy.domain.com:3128',
systempkgs => true,
}