Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
4e48dad
* Change owner of directories to project user
jonjhallettuob Oct 7, 2016
c9b71d4
Puppet insists that uid and gid are strings in a concat section.
jonjhallettuob Oct 7, 2016
50c2eb7
* Backslash quote backslashes to prevent Puppet complaining about \. …
jonjhallettuob Oct 7, 2016
4388dc5
Use Puppet heredoc for complicated Apache config line...
jonjhallettuob Oct 7, 2016
d7ff480
Revert "Use Puppet heredoc for complicated Apache config line..."
jonjhallettuob Oct 7, 2016
ca70ee2
Try adding reset-perms to the sudo list.
jonjhallettuob Oct 7, 2016
a0d1898
Move the sudo::conf into the project definition...
jonjhallettuob Oct 7, 2016
8885ee9
Allow NOPASSWD for reset-perms. I hope this is a good idea...
jonjhallettuob Oct 7, 2016
8fdf88a
* create apache and apache/conf
jonjhallettuob Oct 13, 2016
60185d8
* add dependencies for apache sub directories
jonjhallettuob Oct 14, 2016
e86041d
* typo - added commas to ends of lines
jonjhallettuob Oct 14, 2016
f3a1733
* add group write to subdirectories in project directory
jonjhallettuob Oct 14, 2016
a5e06d7
* move apache directory creation to apache manifest
jonjhallettuob Oct 17, 2016
068472b
* Move creation of project .ssh directory from Vagrantfile to Puppet
jonjhallettuob Oct 17, 2016
7c7b58f
* Fix quotes to enable interpolation
jonjhallettuob Oct 17, 2016
2423f7e
* Remove redundant requires
jonjhallettuob Oct 17, 2016
f157e77
* remove apache dir from project root - this is the Debian structure. We
jonjhallettuob Oct 20, 2016
35c6544
* fix up SELinux types
jonjhallettuob Oct 20, 2016
5f9797e
* include Apache headers module
jonjhallettuob Oct 21, 2016
6d93264
* allow no password for apachectl from bos2
jonjhallettuob Oct 21, 2016
875ca4b
Make sure mod_wsgi is loaded
kierenpitts Oct 24, 2016
ef93660
Added use_optional_includes to fix No matches for the wildcard '*.con…
mysysadmin-ltd Oct 25, 2016
2894329
Merge pull request #1 from mysysadmin-ltd/patch-1
kierenpitts Oct 25, 2016
61f2a90
* add SELinux config to allow httpd to connect to database and send m…
jonjhallettuob Oct 31, 2016
ff9f611
Merge branch 'bosfeatures' of github.com:/ilrt/puppet-projects into b…
jonjhallettuob Oct 31, 2016
f720a4c
* tidy up names and titles for SELinux booleans
jonjhallettuob Oct 31, 2016
2bf3234
* use ensure_resource syntax for SELinux booleans - selboolean fails …
jonjhallettuob Oct 31, 2016
2d4aeb3
* Update SELinux type for ~/var to allow writes
jonjhallettuob Oct 31, 2016
054ef7a
* create ~/.settings and set the SELinux context for httpd
jonjhallettuob Oct 31, 2016
37d3942
Ensure httpd starts after reboot.
jonjhallettuob Nov 1, 2016
fe43fdf
Add a possibly redundant but explanatory option to enable httpd at boot.
jonjhallettuob Nov 1, 2016
3f9f040
Ensure keys are in place before httpd service starts.
jonjhallettuob Nov 1, 2016
9d8ce00
Vhosts now accept a certificate name rather than default to the vhost…
jonjhallettuob Nov 1, 2016
705fadc
Ensure consistent use of vhost_name for conf files.
jonjhallettuob Nov 1, 2016
f591866
Don't create keys if they already exist and use ensure_resource to set
jonjhallettuob Nov 1, 2016
3132fdc
Don't auto generate certs...
jonjhallettuob Nov 1, 2016
61b5352
Logrotation is handled by rotatelog pipe
jonjhallettuob Nov 7, 2016
935c1fd
Add link to cert as certificate chain
jonjhallettuob Nov 15, 2016
85d51e0
Change SELinux context of lib to allow pyc files to be created
jonjhallettuob Nov 15, 2016
37e5611
Revert "Change SELinux context of lib to allow pyc files to be created"
jonjhallettuob Nov 15, 2016
d4cf290
Ensure Apache uses only strong ciphers
jonjhallettuob Nov 17, 2016
fa2be9f
Move SSL Cipher config to Hiera
jonjhallettuob Nov 17, 2016
2746082
Add security settings for Apache
jonjhallettuob Nov 17, 2016
7cb8b83
Move server stuff to apache module from vhost
jonjhallettuob Nov 17, 2016
62329fa
Tidy up indentation
jonjhallettuob Nov 18, 2016
3b818c4
Turn on SELinux boolean for httpd to get to memcache
jonjhallettuob Nov 18, 2016
9e12f0f
Allow worker as an MPM option
jonjhallettuob Mar 21, 2017
da6648a
Give other access to the project Apache logs
jonjhallettuob Apr 3, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 57 additions & 13 deletions manifests/project.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,70 @@
group => $title
}

file { [ "$::projects::basedir/$title",
"$::projects::basedir/$title/var",
"$::projects::basedir/$title/lib",
file { [
"$::projects::basedir/$title",
] :
ensure => directory,
owner => $uid,
group => $gid,
mode => '0755',
}

file { "$::projects::basedir/$title/.ssh":
ensure => 'directory',
owner => $uid,
group => $gid,
mode => '700',
seltype => 'ssh_home_t',
}

file { "$::projects::basedir/$title/.settings":
ensure => 'directory',
owner => $uid,
group => $gid,
mode => '775',
seltype => 'httpd_sys_content_t',
}

file { [
"$::projects::basedir/$title/etc",
] :
ensure => directory,
owner => root,
group => $title,
mode => '0775'
owner => $uid,
group => $gid,
mode => '0775',
}

file { [
"$::projects::basedir/$title/var",
] :
ensure => directory,
owner => $uid,
group => $gid,
seltype => 'httpd_sys_rw_content_t',
mode => '0775',
}

file { [
"$::projects::basedir/$title/lib",
] :
ensure => directory,
owner => $uid,
group => $gid,
mode => '0775',
seltype => 'httpd_sys_content_t',
}

file { "$::projects::basedir/$title/var/log":
ensure => directory,
owner => root,
group => $title,
mode => '0750',
seltype => 'var_log_t',
require => File["$::projects::basedir/$title/var"],
owner => $uid,
group => $gid,
mode => '0755',
seltype => 'httpd_log_t',
}

concat { "${::projects::basedir}/${title}/README":
owner => 'root',
owner => $title,
group => $title,
mode => '0640',
}
Expand Down Expand Up @@ -93,6 +134,10 @@
grant => pick($mysql[grant],['ALL']),
}
}

sudo::conf { "${title}-reset-perms":
content => "%${title} ALL=(ALL) NOPASSWD: /usr/local/bin/reset-perms"
}
}

define project_user (
Expand All @@ -102,4 +147,3 @@
groups +> $group,
}
}

111 changes: 32 additions & 79 deletions manifests/project/apache.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@
ensure_resource('class', '::apache', {
default_vhost => true,
use_optional_includes => true,
mpm_module => false
mpm_module => false,
service_ensure => running,
service_enable => true,
server_signature => 'Off',
server_tokens => 'Prod',
})
include ::apache::mod::proxy
include ::apache::mod::alias
include ::apache::mod::proxy_http
include ::apache::mod::proxy_ajp
include ::apache::mod::headers
include ::apache::mod::wsgi
class {'::apache::mod::authnz_ldap':
verifyServerCert => false
}
Expand All @@ -24,6 +30,10 @@

if defined(Class['::selinux']) {
ensure_resource('selinux::boolean', 'httpd_can_connect_ldap', {'ensure' => 'on'})
ensure_resource('selinux::boolean', 'httpd_can_network_connect_db', {'ensure' => 'on'})
ensure_resource('selinux::boolean', 'httpd_can_network_connect', {'ensure' => 'on'})
ensure_resource('selinux::boolean', 'httpd_can_sendmail', {'ensure' => 'on'})
ensure_resource('selinux::boolean', 'httpd_can_network_memcache', {'ensure' => 'on'})
}


Expand All @@ -42,6 +52,8 @@

if $apache_common['mpm'] == 'event' {
include ::apache::mod::event
} elsif $apache_common['mpm'] == 'worker' {
include ::apache::mod::worker
} else {
include ::apache::mod::prefork
}
Expand All @@ -52,19 +64,15 @@
owner => $apache_user,
group => $title,
mode => '0750',
seltype => 'var_log_t',
seltype => 'httpd_log_t',
require => File["${::projects::basedir}/${title}/var/log"],
}

file { "/etc/logrotate.d/httpd-$title":
ensure => present,
content => template('projects/apache/logrotate.erb'),
}

file { "${::projects::basedir}/${title}/etc/apache":
ensure => directory,
owner => $title,
group => $title,
seltype => 'httpd_config_t',
require => File["${::projects::basedir}/${title}/etc"],
}

Expand All @@ -81,6 +89,7 @@
ensure => directory,
owner => $title,
group => $title,
seltype => 'cert_t',
require => File["${::projects::basedir}/${title}/etc"],
}

Expand All @@ -95,7 +104,7 @@
}

sudo::conf { "${title}-apache":
content => "%${title} ALL= (ALL) /sbin/apachectl"
content => "%${title} ALL= (ALL) NOPASSWD: /sbin/apachectl"
}

create_resources('::projects::project::apache::vhost', $vhosts, {
Expand All @@ -116,7 +125,8 @@
$php = false,
$apache_user = 'apache',
$altnames = [],
$ip = undef
$ip = undef,
$cert_name = $vhost_name,
) {

if ($ip) {
Expand Down Expand Up @@ -151,21 +161,25 @@
ssl => $ssl,
docroot => "${::projects::basedir}/${projectname}/var/${docroot}",
logroot => "${::projects::basedir}/${projectname}/var/log/httpd",
use_optional_includes => "true",
additional_includes =>
["${::projects::basedir}/${projectname}/etc/apache/conf.d/*.conf",
"${::projects::basedir}/${projectname}/etc/apache/conf.d/${title}/*.conf"],
ssl_cert =>
"${::projects::basedir}/${projectname}/etc/ssl/certs/${vhost_name}.crt",
"${::projects::basedir}/${projectname}/etc/ssl/certs/${cert_name}.crt",
ssl_chain =>
"${::projects::basedir}/${projectname}/etc/ssl/certs/${cert_name}.crt",
ssl_key =>
"${::projects::basedir}/${projectname}/etc/ssl/private/${vhost_name}.key",
"${::projects::basedir}/${projectname}/etc/ssl/private/${cert_name}.key",
serveraliases => $altnames,
access_log_env_var => "!forwarded",
custom_fragment => "LogFormat \"%{X-Forwarded-For}i %l %u %t \\\"%r\\\" %s %b \\\"%{Referer}i\\\" \\\"%{User-Agent}i\\\"\" proxy
SetEnvIf X-Forwarded-For \"^.*\..*\..*\..*\" forwarded
SetEnvIf X-Forwarded-For \"^.*\\..*\\..*\\..*\" forwarded
CustomLog \"${::projects::basedir}/${projectname}/var/log/httpd/${title}_access.log\" proxy env=forwarded",
ip => $ip,
ip_based => $ip_based,
add_listen => false,
headers => 'Set Strict-Transport-Security "max-age=63072000; includeSubdomains;"',
}

if !defined(Apache::Listen["$port"]) {
Expand All @@ -183,73 +197,12 @@
}
}

if $ssl == true {
$country= hiera('projects::ssl::country','GB')
if (hiera('projects::ssl::state','') != '') {
$state = hiera('projects::ssl::state')
}
if (hiera('projects::ssl::locality','') != '') {
$locality = hiera('projects::ssl::locality')
}
$organization = hiera('projects::ssl::organization','ACME')
if (hiera('projects::ssl::unit','') != '') {
$unit = hiera('projects::ssl::unit',nil)
}
$commonname = $vhost_name
if (hiera('projects::ssl::email','') != '') {
$email = hiera('projects::ssl::email',nil)
}
file {"${::projects::basedir}/${projectname}/etc/ssl/conf/${vhost_name}.cnf":
content => template('openssl/cert.cnf.erb'),
require => File["${::projects::basedir}/${projectname}/etc/ssl/conf"],

}

ssl_pkey { "${::projects::basedir}/${projectname}/etc/ssl/private/${vhost_name}.auto.key" :
ensure => present,
require => File["${::projects::basedir}/${projectname}/etc/ssl/private"],
}

x509_request { "${::projects::basedir}/${projectname}/etc/ssl/csrs/${vhost_name}.auto.csr" :
ensure => present,
template => "${::projects::basedir}/${projectname}/etc/ssl/conf/${vhost_name}.cnf",
private_key => "${::projects::basedir}/${projectname}/etc/ssl/private/${vhost_name}.auto.key",
require => [Ssl_pkey["${::projects::basedir}/${projectname}/etc/ssl/private/${vhost_name}.auto.key"],File["${::projects::basedir}/${projectname}/etc/ssl/conf/${vhost_name}.cnf"]],
}

x509_cert { "${::projects::basedir}/${projectname}/etc/ssl/certs/${vhost_name}.auto.crt":
ensure => present,
template => "${::projects::basedir}/${projectname}/etc/ssl/conf/${vhost_name}.cnf",
private_key => "${::projects::basedir}/${projectname}/etc/ssl/private/${vhost_name}.auto.key",
days => 4536,
require => [Ssl_pkey["${::projects::basedir}/${projectname}/etc/ssl/private/${vhost_name}.auto.key"],File["${::projects::basedir}/${projectname}/etc/ssl/conf/${vhost_name}.cnf"]],
}

exec { "deploy ${vhost_name}.key" :
command => "/bin/cp ${::projects::basedir}/${projectname}/etc/ssl/private/${vhost_name}.auto.key ${::projects::basedir}/${projectname}/etc/ssl/private/${vhost_name}.key",
onlyif => "/bin/test ! -f ${::projects::basedir}/${projectname}/etc/ssl/private/${vhost_name}.key",
require => Ssl_pkey["${::projects::basedir}/${projectname}/etc/ssl/private/${vhost_name}.auto.key"],
}

file { "${::projects::basedir}/${projectname}/etc/ssl/private/${vhost_name}.key":
replace => 'no',
seltype => 'cert_t',
require => Exec["deploy ${vhost_name}.key"],
}

exec { "deploy ${vhost_name}.crt" :
command => "/bin/cp ${::projects::basedir}/${projectname}/etc/ssl/certs/${vhost_name}.auto.crt ${::projects::basedir}/${projectname}/etc/ssl/certs/${vhost_name}.crt",
onlyif => "/bin/test ! -f ${::projects::basedir}/${projectname}/etc/ssl/certs/${vhost_name}.crt",
require => X509_cert["${::projects::basedir}/${projectname}/etc/ssl/certs/${vhost_name}.auto.crt"],
}

file { "${::projects::basedir}/${projectname}/etc/ssl/certs/${vhost_name}.crt":
replace => 'no',
seltype => 'cert_t',
require => Exec["deploy ${vhost_name}.crt"],
}
}

ensure_resource('file', [
"${::projects::basedir}/${projectname}/etc/ssl/certs/${cert_name}.crt",
"${::projects::basedir}/${projectname}/etc/ssl/private/${cert_name}.key"
],
{ seltype => 'cert_t' }
)

if !defined(Firewall["050 accept Apache ${port}"]) {
firewall { "050 accept Apache ${port}":
Expand Down
10 changes: 0 additions & 10 deletions templates/apache/logrotate.erb

This file was deleted.