Initial implementation of TLS plugin for Fuel

Change-Id: I45db29ce60925e90629c7fa92333b026a4656430
This commit is contained in:
sbartel 2015-05-07 17:02:45 +02:00
parent 0bbeac3d51
commit 93228988ed
27 changed files with 974 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.tox
.build
*.pyc

202
LICENSE Normal file
View File

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
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.

167
README.md Normal file
View File

@ -0,0 +1,167 @@
TLS plugin for Fuel
===================
TLS plugin
---------------
Overview
--------
By default the openstack environment is configured with Http protocol. This plugin allows to configure Horizon, and novnc to use Https connexion by using Transport LAyer security (TLS) protocol to improve security.
This repo contains all necessary files to build Https Fuel plugin.
Requirements
------------
| Requirement | Version/Comment |
|----------------------------------|---------------------------------------------------------|
| Mirantis Openstack compatibility | 6.0 |
|----------------------------------|---------------------------------------------------------|
| Crt & Key files | You have a crt & key files to provide before deployment |
Recommendations
---------------
None.
Limitations
-----------
Securing apis is not yet implemented. Scope of the plugin only openstack dashboard and novnc for now
Installation Guide
==================
Https plugin installation
----------------------------
1. Clone the fuel-plugin repo from: https://github.com/stackforge/fuel-plugin-tls.git
``git clone``
2. Install the Fuel Plugin Builder:
``pip install fuel-plugin-builder``
3. Build nova-nfs Fuel plugin:
``fpb --build fuel-plugin-tls/``
4. The tls-<x.x.x>.fp file will be created in the plugin folder (fuel-plugin-tls)
5. Move this file to the Fuel Master node with secure copy (scp):
``scp tls-<x.x.x>.fp root@:<the_Fuel_Master_node_IP address>:/tmp``
``cd /tmp``
6. Install the nova-nfs plugin:
``fuel plugins --install tls-<x.x.x>.fp``
6. Plugin is ready to use and can be enabled on the Settings tab of the Fuel web UI.
User Guide
==========
https plugin configuration
-----------------------------
1. Create a new environment with the Fuel UI wizard
2. Add a node with the "Compute" role.
3. Click on the settings tab of the Fuel web UI
4. Scroll down the page, select the "Https plugin" checkbox
and fill-in the requiered fields
- the certificate .crt content
- the certificate .key content
You must pass your .crt and .key files via fuel UI (settings tab)
When you pass the content of the files in fuel ui, some "space" characters will appear, don't care about this puppet will remove it.
CRT file must be in the following format :
-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIJAJHydV1v41XIMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV
BAYTAkZSMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
aWRnaXRzIFB0eSBMdGQwHhcNMTUwMTMwMTAyNDU3WhcNMTYwMTMwMTAyNDU3WjBF
MQswCQYDVQQGEwJGUjETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
CgKCAQEAqwHssa1A2alSVh8ZZvKffGaix7mSFMDsFjUgPShqbAZ8xGQynvrHPel9
A8E6ml0sGzHDwk8gobpu7k1wuMhcs7Np88xu5GtR1DhZWQ8MUGWHfflyjguMjtzF
pZg4j0M14SE2INwwsRRtvC0/aeV1/q7HqfTk7+y01g/N4OKvYwndNp2lbSjBZZF4
qbL9QD5iesOptxRryJ8tcm47i6hC4LTunz9pgVI13rtlOoqtXjf07ytMydBbzpeR
4joaPAjbPf5ywf+I/n8XFxy6QPC9qAm2H3Gpo/5bb7+9S8AOhYqvWEKNotvyX1E8
aiDLV+LHkL45Xpx47YBty6L8qNuejwIDAQABo1AwTjAdBgNVHQ4EFgQUVQNmpJDO
w5eVB3yjU80NUZSKZlcwHwYDVR0jBBgwFoAUVQNmpJDOw5eVB3yjU80NUZSKZlcw
DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAqadjZT7kMXRf5bp14nfI
20m6G/i5aHBo+0v+6lRtmk5wD/D6VsOh+R/HjjDDo68y/WEWXxQbuOYX+HZCABpf
VTA4oLvY4t3gtzt9Q21VtK/l5e3yyxo2JBnsPqc5wmWDlNO8aImF+QrvovkuyTV5
mX6suZgby4eTllmVzBNK/+FMuPlsSPwB8SxEbu04aOIcwbn4LCCZJZEG6INVGSS8
SRg1iER8mu2Jf45JKkMFDqUhCUp/ejM2t686O7olqKtmF53rDSBnzhtabdgTIx3F
RjCb281gwvwSgyFfUgt5TIIq1o/kci2N33zuxaifFVz6DtDxKegoZg73bUMg/OA2
bg==
-----END CERTIFICATE-----
KEY file must be in the following format :
-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCrAeyxrUDZqVJW
Hxlm8p98ZqLHuZIUwOwWNSA9KGpsBnzEZDKe+sc96X0DwTqaXSwbMcPCTyChum7u
TXC4yFyzs2nzzG7ka1HUOFlZDwxQZYd9+XKOC4yO3MWlmDiPQzXhITYg3DCxFG28
LT9p5XX+rsep9OTv7LTWD83g4q9jCd02naVtKMFlkXipsv1APmJ6w6m3FGvIny1y
bjuLqELgtO6fP2mBUjXeu2U6iq1eN/TvK0zJ0FvOl5HiOho8CNs9/nLB/4j+fxcX
HLpA8L2oCbYfcamj/ltvv71LwA6Fiq9YQo2i2/JfUTxqIMtX4seQvjlenHjtgG3L
ovyo256PAgMBAAECggEAD3iAGl7rNAXefg4YNTkT9qQua9U9AwWlFik+PmounpFD
rlzGO53CcrZx6eoMTDTLrbYl2Klh8V+1c3esD/uIb3V2y2ieS6nt4D4szyLOYWOe
C2aK15Dx6WbNtrp7u3JAKJrhk7135j1L5C9PwlvQ/fZ/979BCvemMIuDe6nmZhYz
eZ69glGwDqCWtJpKX767ivfpylkWKc2hWIdOmxBsa4PQ4KGEjxl62MCGTAxLkHhB
YsBzyIV4h2NLPoMrSZYY8ImndUNEWqvg9g1kZFR2lI9dlosf/A4F+K5v8Le3wLLJ
bkRISLeEX31iWV1/XlQI98V2fLyveNfgpeU+Sy7v8QKBgQDaW7XYr2ig4wYPUh+z
Dh8jYGVg+Mht/Dnfa3ND3zYQwuoGp8p2n2yDroM/PGlU0X9+Vrjz8fQoxLdbpnMG
o2VH5TpTtuCUOh/bzSBuZHWIX83n0V0Ff8M/bLdNHYc07oC6p+7DlVljy8YEvAUc
lfZ2LajSCrrkBluH+V1D1NyP9wKBgQDIfJimT4J0AHc7sfI9Bmv17gxi++qlom+e
KHU9mvU4CMxQZNoQACm/C5a0ilh1DptIDLsfEp0obEkFEAVY6CfOTMe/lNN/iuR+
WMe64gOnOhLd+36IdPkA3aqsO+GGSE2F75hJ0Ll5l3vEUgRVxqe9NbqA7GCDyCCl
JrBy57fwKQKBgGw8C05F3CHrhiRv+6CAfnTFolrH1mmWHYWeODtLV/xE8UWtRBE6
gspe5VWh90AAvCZ+jBz3MKRIpe56+gcvVNOnTxsRyg4PJZ2I9uthRlT70A95WpeQ
NdKpa86AtXVKR2q+NP6jd/ScnCHapNn/h3Qau9SpVuwSLqqes1kdGNsPAoGAG0pi
mRjvoAzELjsNx2LNZV+vDfZOvZc77GKDewxR3vvLnBHuYQk0pY3VSOQgIGcJmigp
fJRTEkKTOf4xTCXl7T4kXp7Kn2zvp4c8QOMtLiFImjD2y2pozsZdyi4oh9flvZqc
t0eTR8roDRRBBNAS2z2qEoyaorWmQ/TdRfbm4ekCgYALU22vbyuPX5AVPdD0vWv4
zLL+l0MMMRviMu1NSa9L95vVdc/C0cGaLEZ7U4x2pd+J54q+DjjIRMn2knrbBZQf
X43ceACVpWiv5DmBtEUrB8dbwxEJFaoPGqEswwdh1FDxzfsPdapyqGI5B8zRjnpa
SR2QEYok/8lZeDgUOhXkGg==
-----END PRIVATE KEY-----
Here is a screenshot of the fields
![tls fields](./figures/tls-plugin.png "tls-fields")
Deployment details
------------------
Configure Horizon to use tls option
Configure apache to use Https connexions, and set certificate files
Restart Apache
Configure Nova with novnc https option
Restart Nova
For HA deployment add horizon tls to haproxy configuration
and restart ha_proxy
Known issues
------------
None.
Release Notes
-------------
**1.0.0**
* Initial release of the plugin

View File

@ -0,0 +1,30 @@
$fuel_settings = parseyaml(file('/etc/astute.yaml'))
$tls_hash = $::fuel_settings['tls']
$horizon_crt = $tls_hash['horizon_crt']
$horizon_key = $tls_hash['horizon_key']
$nodes_hash = $::fuel_settings['nodes']
if ($::fuel_settings['deployment_mode'] == 'multinode') {
$controller = filter_nodes($nodes_hash,'role','controller')
$controller_node_public = $controller[0]['public_address']
class { 'tls::controller':
horizon_crt => $horizon_crt,
horizon_key => $horizon_key,
external_ip => $controller_node_public,
bind_address => $controller_node_public
}
}
else {
$controllers = concat(filter_nodes($nodes_hash,'role','primary-controller'), filter_nodes($nodes_hash,'role','controller'))
$public_virtual_ip = $::fuel_settings['public_vip']
$internal_virtual_ip = $::fuel_settings['management_vip']
class { 'tls::controller_ha':
controllers => $controllers,
public_virtual_ip => $public_virtual_ip,
internal_virtual_ip => $internal_virtual_ip,
horizon_crt => $horizon_crt,
horizon_key => $horizon_key,
external_ip => $public_virtual_ip
}
}

View File

@ -0,0 +1,19 @@
$fuel_settings = parseyaml(file('/etc/astute.yaml'))
$tls_hash = $::fuel_settings['tls']
$horizon_crt = $tls_hash['horizon_crt']
$horizon_key = $tls_hash['horizon_key']
$nodes_hash = $::fuel_settings['nodes']
if ($::fuel_settings['deployment_mode'] == 'multinode') {
$controller = filter_nodes($nodes_hash,'role','controller')
$internal_ip = $controller[0]['internal_address']
$public_ip = $controller[0]['public_address']
}
else {
$public_ip = $::fuel_settings['public_vip']
$internal_ip = $::fuel_settings['management_vip']
}
class { 'tls::compute':
public_virtual_ip => $public_ip,
internal_virtual_ip => $internal_ip,
}

View File

@ -0,0 +1,26 @@
#!/bin/bash
CRT=$1
KEY=$2
SSL_PATH=$3
############################################################################################################################
# Horizon part
############################################################################################################################
echo "-----BEGIN CERTIFICATE-----" > $SSL_PATH/horizon.crt
echo $CRT | awk -F "-----" '{ print $3}' | sed 's/ /\n/g' | sed '/^$/d' >> $SSL_PATH/horizon.crt
echo "-----END CERTIFICATE-----" >> $SSL_PATH/horizon.crt
echo "-----BEGIN PRIVATE KEY-----" > $SSL_PATH/horizon.key
echo $KEY | awk -F "-----" '{ print $3}' | sed 's/ /\n/g' | sed '/^$/d' >> $SSL_PATH/horizon.key
echo "-----END PRIVATE KEY-----" >> $SSL_PATH/horizon.key
############################################################################################################################
# Nova part
############################################################################################################################
echo "-----BEGIN CERTIFICATE-----" > /etc/nova/tls/nova.crt
echo $CRT | awk -F "-----" '{ print $3}' | sed 's/ /\n/g' | sed '/^$/d' >> /etc/nova/tls/nova.crt
echo "-----END CERTIFICATE-----" >> /etc/nova/tls/nova.crt
echo "-----BEGIN PRIVATE KEY-----" > /etc/nova/tls/nova.key
echo $KEY | awk -F "-----" '{ print $3}' | sed 's/ /\n/g' | sed '/^$/d' >> /etc/nova/tls/nova.key
echo "-----END PRIVATE KEY-----" >> /etc/nova/tls/nova.key

View File

@ -0,0 +1,12 @@
class tls::compute(
$public_virtual_ip,
$internal_virtual_ip,
) {
include tls::params
class { 'tls::nova::novnc_compute':
public_virtual_ip => $public_virtual_ip,
internal_virtual_ip => $internal_virtual_ip,
nova_compute_service => $tls::params::nova_compute_service
}
}

View File

@ -0,0 +1,52 @@
class tls::controller(
$horizon_crt,
$horizon_key,
$external_ip,
$bind_address
) {
$server_hostname = $external_ip
include tls::params
$apache_tls_path = $tls::params::apache_tls_path
#format crt and key files
file { "$apache_tls_path" :
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
}
file { '/etc/nova/tls' :
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
before => Exec['format.sh']
}
file {'format.sh':
path =>'/usr/bin/format.sh',
mode => '0744',
owner => root,
group => root,
source => "puppet:///modules/tls/format.sh",
require => File["$apache_tls_path"]
}
exec {'format.sh':
command => "bash -c \"format.sh \'${horizon_crt}\' \'${horizon_key}\' \'${apache_tls_path}\'\"",
path => '/usr/sbin:/usr/bin:/sbin:/bin',
require => File['format.sh'],
before => File['openstack-dashboard.conf'],
}
class { 'tls::horizon::horizon':
horizon_crt => $horizon_crt,
horizon_key => $horizon_key,
bind_address => $bind_address
}
class { 'tls::nova::novnc_controller':
server_hostname => $server_hostname,
novnc_service => $tls::params::nova_novnc_service,
httpd_service => $tls::params::httpd_service_name
}
}

View File

@ -0,0 +1,29 @@
class tls::controller_ha(
$controllers,
$public_virtual_ip,
$internal_virtual_ip,
$horizon_crt,
$horizon_key,
$external_ip
) {
$nodes_hash = $::fuel_settings['nodes']
$node = filter_nodes($nodes_hash,'name',$::hostname)
$internal_address = $node[0]['internal_address']
$bind_address = $internal_address
class { 'tls::controller':
horizon_crt => $horizon_crt,
horizon_key => $horizon_key,
external_ip => $external_ip,
bind_address => $bind_address
}
class { 'tls::horizon::horizon_ha':
controllers => $controllers,
public_virtual_ip => $public_virtual_ip,
internal_virtual_ip => $internal_virtual_ip,
}
exec { "ha_proxy_restart":
command => "/usr/sbin/crm resource restart p_haproxy",
require => Class['tls::horizon::horizon_ha'],
}
}

View File

@ -0,0 +1,85 @@
class tls::horizon::horizon(
$horizon_crt,
$horizon_key,
$bind_address,
) {
include tls::params
$root_url = $tls::params::root_url
$ssl_cert_file = $tls::params::tls_cert_file
$ssl_key_file = $tls::params::tls_key_file
#update horizon config file
exec { "USE_SSL":
command => "/bin/sed -i \"s/#USE_SSL = False/USE_SSL = True/\" $tls::params::horizon_settings_file",
unless => "/bin/egrep \"^USE_SSL = True\" $tls::params::horizon_settings_file",
notify => Service[$tls::params::httpd_service_name],
}
exec { "CSRF_COOKIE_SECURE":
command => "/bin/sed -i \"s/#CSRF_COOKIE_SECURE = True/CSRF_COOKIE_SECURE = True/\" $tls::params::horizon_settings_file",
unless => "/bin/egrep \"^CSRF_COOKIE_SECURE = True\" $tls::params::horizon_settings_file",
notify => Service[$tls::params::httpd_service_name],
}
exec { "SESSION_COOKIE_SECURE":
command => "/bin/sed -i \"s/#SESSION_COOKIE_SECURE = True/SESSION_COOKIE_SECURE = True/\" $tls::params::horizon_settings_file",
unless => "/bin/egrep \"^SESSION_COOKIE_SECURE = True\" $tls::params::horizon_settings_file",
notify => Service[$tls::params::httpd_service_name],
}
exec { "SESSION_COOKIE_HTTPONLY":
command => "/bin/sed -i /SESSION_COOKIE_SECURE/i\"SESSION_COOKIE_HTTPONLY = True\" $tls::params::horizon_settings_file",
unless => "/bin/egrep \"^SESSION_COOKIE_HTTPONLY = True\" $tls::params::horizon_settings_file",
notify => Service[$tls::params::httpd_service_name],
}
if $::osfamily == 'Debian' {
exec { "ssl_mod":
command => "/usr/sbin/a2enmod ssl",
notify => Service[$tls::params::httpd_service_name],
}
exec { "header_mod":
command => "/usr/sbin/a2enmod headers",
notify => Service[$tls::params::httpd_service_name],
}
exec { "rewrite":
command => "/usr/sbin/a2enmod rewrite",
notify => Service[$tls::params::httpd_service_name],
}
} elsif($::osfamily == 'RedHat') {
package { 'mod_ssl':
ensure => present,
notify => Service[$tls::params::httpd_service_name],
}
}
#update apache config file
file { 'openstack-dashboard.conf' :
ensure => present,
path => $tls::params::apache_conf_file,
owner => 'root',
group => 'root',
mode => '0755',
content => template('tls/openstack-dashboard.conf.erb'),
notify => Service[$tls::params::httpd_service_name],
}
file { 'port.conf' :
ensure => present,
path => $tls::params::apache_port_file,
owner => 'root',
group => 'root',
mode => '0755',
content => template('tls/port.conf.erb'),
notify => Service[$tls::params::httpd_service_name],
}
file { 'vhost.conf' :
ensure => present,
path => $tls::params::apache_vhost_file,
owner => 'root',
group => 'root',
mode => '0755',
content => template('tls/vhost.erb'),
notify => Service[$tls::params::httpd_service_name],
}
}

View File

@ -0,0 +1,74 @@
class tls::horizon::horizon_ha (
$controllers,
$public_virtual_ip,
$internal_virtual_ip,
) {
require tls::horizon::horizon
include tls::params
Haproxy::Service { use_include => true }
Haproxy::Balancermember { use_include => true }
$haproxy_config_options = {
'option' => ['ssl-hello-chk', 'tcpka'],
'stick-table' => 'type ip size 200k expire 30m',
'stick' => 'on src',
'balance' => 'source',
'timeout' => ['client 3h', 'server 3h'],
'mode' => 'tcp',
}
haproxy::listen { 'horizon-ssl':
order => '017',
ipaddress => $public_virtual_ip,
ports => '443',
options => $haproxy_config_options,
mode => 'tcp',
}
haproxy::balancermember { 'horizon-ssl':
order => '017',
listening_service => 'horizon-tls',
server_names => filter_hash($controllers, 'name'),
ipaddresses => filter_hash($controllers, 'internal_address'),
ports => '443',
options => 'weight 1 check',
define_cookies => false,
define_backups => false,
}
##################################################################################
$haproxy_config_options_nova = {
'option' => ['ssl-hello-chk', 'tcpka'],
'mode' => 'tcp',
}
haproxy::listen { 'nova-novncproxy':
order => '170',
ipaddress => $public_virtual_ip,
ports => '6080',
options => $haproxy_config_options_nova,
mode => 'tcp',
}
haproxy::balancermember { 'nova-novncproxy':
order => '170',
listening_service => 'horizon-tls',
server_names => filter_hash($controllers, 'name'),
ipaddresses => filter_hash($controllers, 'internal_address'),
ports => '6080',
options => 'check',
define_cookies => false,
define_backups => false,
}
######################################################################################
service { 'haproxy':
enable => true,
ensure => running,
}
}

View File

@ -0,0 +1,17 @@
class tls::nova::novnc_compute (
$public_virtual_ip,
$internal_virtual_ip,
$nova_compute_service
) {
$novncproxy_base_url = "https://${public_virtual_ip}:6080/vnc_auto.html"
nova_config {
'DEFAULT/novncproxy_base_url': value => $novncproxy_base_url;
'DEFAULT/ssl_only': value => 'True';
} ~> Service["$nova_compute_service"]
service { "$nova_compute_service":
enable => true,
ensure => running,
}
}

View File

@ -0,0 +1,24 @@
class tls::nova::novnc_controller (
$server_hostname,
$novnc_service,
$httpd_service
) {
$novncproxy_base_url = "https://${server_hostname}:6080/vnc_auto.html"
nova_config {
'DEFAULT/novncproxy_base_url': value => $novncproxy_base_url;
'DEFAULT/ssl_only': value => 'True';
'DEFAULT/cert': value => '/etc/nova/tls/nova.crt';
'DEFAULT/key': value => '/etc/nova/tls/nova.key';
} ~> Service["$novnc_service"]
service { "$novnc_service":
enable => true,
ensure => running,
}
service { $httpd_service:
enable => true,
ensure => running,
}
}

View File

@ -0,0 +1,31 @@
class tls::params {
if $::osfamily == 'Debian' {
$httpd_service_name = 'apache2'
$horizon_settings_file = '/etc/openstack-dashboard/local_settings.py'
$usergroup = 'nogroup'
$nova_compute_service = 'nova-compute'
$nova_novnc_service = 'nova-novncproxy'
$apache_tls_path = '/etc/apache2/TLS'
$tls_cert_file = '/etc/apache2/TLS/horizon.crt'
$tls_key_file = '/etc/apache2/TLS/horizon.key'
$root_url = '/horizon'
$apache_conf_file = '/etc/apache2/conf-available/openstack-dashboard.conf'
$apache_vhost_file = '/etc/apache2/sites-available/openstack-dashboard.conf'
$apache_port_file = '/etc/apache2/ports.conf'
} elsif($::osfamily == 'RedHat') {
$httpd_service_name = 'httpd'
$horizon_settings_file = '/etc/openstack-dashboard/local_settings'
$usergroup = 'nobody'
$nova_compute_service = 'openstack-nova-compute'
$nova_novnc_service = 'openstack-nova-novncproxy'
$apache_tls_path = '/etc/httpd/TLS'
$tls_cert_file = '/etc/httpd/TLS/horizon.crt'
$tls_key_file = '/etc/httpd/TLS/horizon.key'
$root_url = '/dashboard'
$apache_conf_file = '/etc/httpd/conf.d/openstack-dashboard.conf'
$apache_vhost_file = '/etc/httpd/conf.d/ssl.conf'
$apache_port_file = '/etc/httpd/conf.d/ports.conf'
} else {
fail("unsupported family ${::osfamily}")
}
}

View File

@ -0,0 +1,7 @@
require 'spec_helper'
describe 'https' do
context 'with defaults for all parameters' do
it { should contain_class('https') }
end
end

View File

@ -0,0 +1 @@
require 'puppetlabs_spec_helper/module_spec_helper'

View File

@ -0,0 +1,58 @@
#
# This file autogenerated by Puppet
# Do not edit, changes will be overwritten
#
<%
if @memorysize_mb.to_i < 1200 or @processorcount.to_i <= 3
wsgi_daemon_processes = 3
wsgi_daemon_threads = 10
else
wsgi_daemon_processes = @processorcount
wsgi_daemon_threads = 15
end
if @osfamily == 'RedHat' %>
WSGIDaemonProcess dashboard processes=<%= wsgi_daemon_processes %> threads=<%= wsgi_daemon_threads %>
WSGIProcessGroup dashboard
WSGISocketPrefix run/wsgi
WSGIScriptAlias /dashboard /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
Alias /static /usr/share/openstack-dashboard/static
<Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
<IfModule mod_headers.c>
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>
Order allow,deny
Allow from all
</Directory>
<Directory /usr/share/openstack-dashboard/static>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access 6 month"
</IfModule>
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
Order allow,deny
Allow from all
</Directory>
<%
end
if @osfamily == 'Debian' %>
WSGIScriptAlias /horizon /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
WSGIDaemonProcess horizon user=horizon group=horizon processes=<%= wsgi_daemon_processes %> threads=<%= wsgi_daemon_threads %>
WSGIProcessGroup horizon
Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/
<Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
Order allow,deny
Allow from all
</Directory>
<% end %>

View File

@ -0,0 +1,21 @@
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement
NameVirtualHost *:80
Listen <%= @bind_address %>:80
<% if @osfamily == 'RedHat' -%>
NameVirtualHost *:443
Listen <%= @bind_address %>:443
<% else %>
<IfModule mod_ssl.c>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
NameVirtualHost *:443
Listen <%= @bind_address %>:443
</IfModule>
<IfModule mod_gnutls.c>
Listen <%= @bind_address %>:443
</IfModule>
<% end %>

View File

@ -0,0 +1,37 @@
#
# This file autogenerated by Puppet
# Do not edit, changes will be overwritten
#
# SSL support
<% if @osfamily == 'RedHat' -%>
LoadModule ssl_module modules/mod_ssl.so
<% end -%>
SSLPassPhraseDialog builtin
SSLSessionCache shmcb:/var/cache/mod_ssl/scache(512000)
SSLSessionCacheTimeout 300
SSLMutex default
SSLRandomSeed startup file:/dev/urandom 256
SSLRandomSeed connect builtin
SSLCryptoDevice builtin
<% if @use_syslog -%>
ErrorLog syslog:local1
<% end -%>
<VirtualHost *:80>
RedirectMatch permanent ^/$ <%= @root_url %>/
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
</VirtualHost>
<VirtualHost *:443>
RedirectMatch permanent ^/$ <%= @root_url %>/
SSLEngine on
SSLProtocol +TLSv1
SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!EXP:!LOW:!MEDIUM
SSLCertificateFile <%= @ssl_cert_file %>
SSLCertificateKeyFile <%= @ssl_key_file %>
</VirtualHost>

View File

@ -0,0 +1,13 @@
# The baseline for module testing used by Puppet Labs is that each manifest
# should have a corresponding test manifest that declares that class or defined
# type.
#
# Tests are then run by using puppet apply --noop (to check for compilation
# errors and view a log of events) or by fully applying the test in a virtual
# environment (to compare the resulting system state to the desired state).
#
# Learn more about module testing here:
# http://docs.puppetlabs.com/guides/tests_smoke.html
#
include tls::controller_ha
include tls::compute

13
environment_config.yaml Normal file
View File

@ -0,0 +1,13 @@
attributes:
horizon_crt:
value: ""
label: "CRT"
description: "Certificate .crt content"
weight: 10
type: "password"
horizon_key:
value: ""
label: "Key"
description: "Certificate .key content"
weight: 10
type: "password"

BIN
figures/tls-plugin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

34
metadata.yaml Normal file
View File

@ -0,0 +1,34 @@
# Plugin name
name: tls
title: TLS plugin
# Plugin version
version: 1.0.0
# Description
description: Enables the Transport Layer Security (TLS) protocol to secure openstack
# Required fuel version
fuel_version: ['6.0']
# The plugin is compatible with releases in the list
releases:
- os: ubuntu
version: 2014.2-6.0
mode: ['ha', 'multinode']
deployment_scripts_path: deployment_scripts/
repository_path: repositories/ubuntu
- os: centos
version: 2014.2-6.0
mode: ['ha', 'multinode']
deployment_scripts_path: deployment_scripts/
repository_path: repositories/centos
- os: ubuntu
version: 2014.2-6.0.1
mode: ['ha', 'multinode']
deployment_scripts_path: deployment_scripts/
repository_path: repositories/ubuntu
- os: centos
version: 2014.2-6.0.1
mode: ['ha', 'multinode']
deployment_scripts_path: deployment_scripts/
repository_path: repositories/centos
# Version of plugin package
package_version: '1.0.0'

4
pre_build_hook Normal file
View File

@ -0,0 +1,4 @@
#!/bin/bash
# Add here any the actions which are required before plugin build
# like packages building, packages downloading from mirrors and so on.
# The script should return 0 if there were no errors.

View File

View File

15
tasks.yaml Normal file
View File

@ -0,0 +1,15 @@
# Deployment is required for controllers
- role: ['controller']
stage: post_deployment
type: puppet
parameters:
puppet_manifest: puppet/manifests/site.pp
puppet_modules: "puppet/modules/:/etc/puppet/modules/"
timeout: 360
- role: ['compute']
stage: post_deployment
type: puppet
parameters:
puppet_manifest: puppet/manifests/site_compute.pp
puppet_modules: "puppet/modules/:/etc/puppet/modules/"
timeout: 360