Stein fixes

- Cookstyle fixes
- Refactor Berksfile to use groups so we can exclude integration testing
  cookbooks
- Update documentation
- Cleanup line wraps
- Update delivery configuration to exclude integration cookbooks
- Fix ChefSpec output.
- Add missing ChefSpec tests
- Switch package installations to send packages as arrays instead of individual
  package resources. This generally speeds up chef runs.
- Cleanup array syntax using %w() instead of []
- Remove FWaaS recipe as it's been unmaintained upstream.

Depends-On: https://review.opendev.org/701027
Depends-On: https://review.opendev.org/706101
Depends-On: https://review.opendev.org/706151
Change-Id: Ie3b65b701235bae65a1797d63d6a55dd6fc9958e
This commit is contained in:
Lance Albertson 2020-03-18 16:59:39 -07:00
parent 4e4bed1eed
commit 57b9ab6138
16 changed files with 107 additions and 211 deletions

View File

@ -1 +1,9 @@
remote_file = "https://raw.githubusercontent.com/chef-cookbooks/community_cookbook_tools/master/delivery/project.toml"
[local_phases]
unit = 'rspec spec/'
lint = 'cookstyle --display-cop-names --extra-details'
syntax = "berks install -e integration"
provision = "echo skipping"
deploy = "echo skipping"
smoke = "echo skipping"
functional = "echo skipping"
cleanup = "echo skipping"

View File

@ -14,26 +14,3 @@ AllCops:
- .cookbooks/**/*
- berks-cookbooks/**/*
- .bundle/**/*
Encoding:
Exclude:
- metadata.rb
- Gemfile
NumericLiterals:
Enabled: false
LineLength:
Enabled: false
WordArray:
MinSize: 3
Style/Next:
Description: Use `next` to skip iteration instead of a condition at the end.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
Enabled: true
EnforcedStyle: always
SupportedStyles:
- skip_modifier_ifs
- always

View File

@ -2,21 +2,21 @@ source 'https://supermarket.chef.io'
solver :ruby, :required
%w(
client
-common
-dns
-identity
-image
-integration-test
-network
-ops-database
-ops-messaging
).each do |cookbook|
[
%w(client dep),
%w(-common dep),
%w(-dns integration),
%w(-identity dep),
%w(-image integration),
%w(-integration-test integration),
%w(-network integration),
%w(-ops-database integration),
%w(-ops-messaging integration),
].each do |cookbook, group|
if Dir.exist?("../cookbook-openstack#{cookbook}")
cookbook "openstack#{cookbook}", path: "../cookbook-openstack#{cookbook}"
cookbook "openstack#{cookbook}", path: "../cookbook-openstack#{cookbook}", group: group
else
cookbook "openstack#{cookbook}", git: "https://opendev.org/openstack/cookbook-openstack#{cookbook}"
cookbook "openstack#{cookbook}", git: "https://opendev.org/openstack/cookbook-openstack#{cookbook}", group: group
end
end

View File

@ -20,9 +20,9 @@ https://docs.openstack.org/horizon/latest/
Requirements
============
- Chef 14 or higher
- ChefDK 3.2.30 for testing (also includes Berkshelf for cookbook
dependency resolution)
- Chef 15 or higher
- Chef Workstation 0.15.18 for testing (also includes Berkshelf for
cookbook dependency resolution)
Platform
========
@ -37,8 +37,8 @@ Cookbooks
The following cookbooks are dependencies:
- 'apache2', '~> 8.0'
- 'openstack-common', '>= 18.0.0'
- 'openstack-identity', '>= 18.0.0'
- 'openstack-common', '>= 19.0.0'
- 'openstack-identity', '>= 19.0.0'
- 'poise-python'
Attributes
@ -64,12 +64,6 @@ openstack-dashboard::apache2-server
- Installs the Apache webserver and sets up an ``mod_wsgi`` container to
run the Horizon dashboard.
openstack-dashboard::neutron-fwaas-dashboard
--------------------------------------------
- Installs the python neutron-fwaas-dashboard package. Includes
openstack-dashboard::horizon recipe at the beginning.
openstack-dashboard::neutron-lbaas-dashboard
--------------------------------------------
@ -134,7 +128,7 @@ License and Author
+-----------------+---------------------------------------------------+
| **Copyright** | Copyright (c) 2014, x-ion GmbH. |
+-----------------+---------------------------------------------------+
| **Copyright** | Copyright (c) 2016-2019, Oregon State University |
| **Copyright** | Copyright (c) 2016-2020, Oregon State University |
+-----------------+---------------------------------------------------+
Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,10 +1,11 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-dashboard
# Cookbook:: openstack-dashboard
# Attributes:: default
#
# Copyright 2012, AT&T, Inc.
# Copyright 2013-2014, IBM, Corp.
# Copyright:: 2012, AT&T, Inc.
# Copyright:: 2013-2014, IBM, Corp.
# Copyright:: 2016-2020, Oregon State University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -98,7 +99,8 @@ when 'rhel'
default['openstack']['dashboard']['key_group'] = 'root'
default['openstack']['dashboard']['horizon_user'] = 'apache'
default['openstack']['dashboard']['horizon_group'] = 'apache'
default['openstack']['dashboard']['secret_key_path'] = '/usr/share/openstack-dashboard/openstack_dashboard/local/.secret_key_store'
default['openstack']['dashboard']['secret_key_path'] =
'/usr/share/openstack-dashboard/openstack_dashboard/local/.secret_key_store'
default['openstack']['dashboard']['ssl']['cert_dir'] = '/etc/pki/tls/certs/'
default['openstack']['dashboard']['ssl']['key_dir'] = '/etc/pki/tls/private/'
default['openstack']['dashboard']['local_settings_path'] = '/etc/openstack-dashboard/local_settings'
@ -109,8 +111,8 @@ when 'rhel'
default['openstack']['dashboard']['logout_url'] = "#{node['openstack']['dashboard']['webroot']}auth/logout/"
default['openstack']['dashboard']['login_redirect_url'] = node['openstack']['dashboard']['webroot']
default['openstack']['dashboard']['platform'] = {
'horizon_packages' => ['openstack-dashboard', 'mod_wsgi'],
'memcache_python_packages' => ['python-memcached'],
'horizon_packages' => %w(openstack-dashboard mod_wsgi),
'memcache_python_packages' => %w(python-memcached),
'package_overrides' => '',
}
when 'debian'
@ -128,11 +130,16 @@ when 'debian'
default['openstack']['dashboard']['logout_url'] = nil
default['openstack']['dashboard']['login_redirect_url'] = nil
default['openstack']['dashboard']['platform'] = {
'memcache_python_packages' => ['python3-memcache'],
'memcache_python_packages' => %w(python3-memcache),
'package_overrides' => '',
}
default['openstack']['dashboard']['platform']['horizon_packages'] =
['node-less', 'libapache2-mod-wsgi-py3', 'python3-django-horizon', 'openstack-dashboard']
%w(
node-less
libapache2-mod-wsgi-py3
python3-django-horizon
openstack-dashboard
)
else
default['openstack']['dashboard']['key_group'] = 'root'
end
@ -196,7 +203,6 @@ default['openstack']['dashboard']['simple_ip_management'] = false
default['openstack']['dashboard']['neutron']['enable_quotas'] = true
default['openstack']['dashboard']['neutron']['enable_lb'] = false
default['openstack']['dashboard']['neutron']['enable_vpn'] = false
default['openstack']['dashboard']['neutron']['enable_fwaas'] = false
# Allow for misc sections to be added to the local_settings template
# For example: {
# 'CUSTOM_CONFIG_A' => {

View File

@ -3,22 +3,17 @@ maintainer 'openstack-chef'
maintainer_email 'openstack-discuss@lists.openstack.org'
license 'Apache-2.0'
description 'Installs/Configures the OpenStack Dashboard (Horizon)'
version '18.0.0'
recipe 'horizon', 'Sets up the packages needed to run the Horizon dashboard and its dependencies.'
recipe 'apache2-server', 'Installs the Apache webserver to run the Horizon dashboard.'
recipe 'neutron-fwaas-dashboard', 'Installs the python neutron-fwaas-dashboard package.'
recipe 'neutron-lbaas-dashboard', 'Installs the python neutron-lbaas-dashboard package.'
version '19.0.0'
%w(ubuntu redhat centos).each do |os|
supports os
end
depends 'apache2', '~> 8.0'
depends 'openstack-common', '>= 18.0.0'
depends 'openstack-identity', '>= 18.0.0'
depends 'openstack-common', '>= 19.0.0'
depends 'openstack-identity', '>= 19.0.0'
depends 'poise-python'
issues_url 'https://launchpad.net/openstack-chef'
source_url 'https://opendev.org/openstack/cookbook-openstack-dashboard'
chef_version '>= 14.0'
chef_version '>= 15.0'

View File

@ -1,13 +1,14 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-dashboard
# Cookbook:: openstack-dashboard
# Recipe:: apache2-server
#
# Copyright 2012, Rackspace US, Inc.
# Copyright 2012-2013, AT&T Services, Inc.
# Copyright 2013-2014, IBM, Corp.
# Copyright 2014, SUSE Linux, GmbH.
# Copyright 2014, x-ion GmbH.
# Copyright:: 2012, Rackspace US, Inc.
# Copyright:: 2012-2013, AT&T Services, Inc.
# Copyright:: 2013-2014, IBM, Corp.
# Copyright:: 2014, SUSE Linux, GmbH.
# Copyright:: 2014, x-ion GmbH.
# Copyright:: 2016-2020, Oregon State University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -83,16 +84,19 @@ if node['openstack']['dashboard']['ssl']['use_data_bag']
ssl_chain = secret('certs', node['openstack']['dashboard']['ssl']['chain'])
end
end
ssl_cert_file = File.join(node['openstack']['dashboard']['ssl']['cert_dir'], node['openstack']['dashboard']['ssl']['cert'])
ssl_key_file = File.join(node['openstack']['dashboard']['ssl']['key_dir'], node['openstack']['dashboard']['ssl']['key'])
ssl_chain_file = if node['openstack']['dashboard']['ssl']['chain']
File.join(node['openstack']['dashboard']['ssl']['cert_dir'], node['openstack']['dashboard']['ssl']['chain'])
end
ssl_cert_file =
File.join(node['openstack']['dashboard']['ssl']['cert_dir'], node['openstack']['dashboard']['ssl']['cert'])
ssl_key_file =
File.join(node['openstack']['dashboard']['ssl']['key_dir'], node['openstack']['dashboard']['ssl']['key'])
ssl_chain_file =
if node['openstack']['dashboard']['ssl']['chain']
File.join(node['openstack']['dashboard']['ssl']['cert_dir'], node['openstack']['dashboard']['ssl']['chain'])
end
if node['openstack']['dashboard']['use_ssl'] &&
node['openstack']['dashboard']['ssl']['use_data_bag']
unless ssl_cert_file == ssl_key_file
cert_mode = 0o0644
cert_mode = '644'
cert_owner = 'root'
cert_group = 'root'
@ -105,7 +109,7 @@ if node['openstack']['dashboard']['use_ssl'] &&
end
if ssl_chain_file
cert_mode = 0o0644
cert_mode = '644'
cert_owner = 'root'
cert_group = 'root'
@ -117,7 +121,7 @@ if node['openstack']['dashboard']['use_ssl'] &&
end
end
key_mode = 0o0640
key_mode = '640'
key_owner = 'root'
key_group = node['openstack']['dashboard']['key_group']
@ -133,7 +137,7 @@ end
file node['openstack']['dashboard']['secret_key_path'] do
owner node['openstack']['dashboard']['horizon_user']
group node['openstack']['dashboard']['horizon_group']
mode 0o0600
mode '600'
# the only time the file should be created is if we have secret_key_content
# set, otherwise let apache create it when someone first accesses the
# dashboard
@ -148,7 +152,6 @@ end
# stop apache bitching
directory "#{node['openstack']['dashboard']['dash_path']}/.blackhole" do
owner 'root'
action :create
end
template "#{apache_dir}/sites-available/openstack-dashboard.conf" do

View File

@ -1,13 +1,14 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-dashboard
# Cookbook:: openstack-dashboard
# Recipe:: horizon
#
# Copyright 2012, Rackspace US, Inc.
# Copyright 2012-2013, AT&T Services, Inc.
# Copyright 2013-2014, IBM, Corp.
# Copyright 2014, SUSE Linux, GmbH.
# Copyright 2014, x-ion, GmbH.
# Copyright:: 2012, Rackspace US, Inc.
# Copyright:: 2012-2013, AT&T Services, Inc.
# Copyright:: 2013-2014, IBM, Corp.
# Copyright:: 2014, SUSE Linux, GmbH.
# Copyright:: 2014, x-ion, GmbH.
# Copyright:: 2019-2020, Oregon State University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -38,11 +39,12 @@ http_bind_address = bind_address http_bind
https_bind = node['openstack']['bind_service']['dashboard_https']
https_bind_address = bind_address https_bind
horizon_host = if node['openstack']['dashboard']['use_ssl']
https_bind_address
else
http_bind_address
end
horizon_host =
if node['openstack']['dashboard']['use_ssl']
https_bind_address
else
http_bind_address
end
db_pass = get_password 'db', 'horizon'
db_info = db 'dashboard'
@ -50,11 +52,9 @@ db_info = db 'dashboard'
python_packages = node['openstack']['db']['python_packages'][db_info['service_type']]
# Add dashboard specific database packages
python_packages += Array(node['openstack']['dashboard']['db_python_packages'][db_info['service_type']])
(platform_options['horizon_packages'] + python_packages).each do |pkg|
package pkg do
action :upgrade
options platform_options['package_overrides']
end
package platform_options['horizon_packages'] + python_packages do
action :upgrade
options platform_options['package_overrides']
end
if node['openstack']['dashboard']['session_backend'] == 'memcached'
@ -70,7 +70,7 @@ template node['openstack']['dashboard']['local_settings_path'] do
source 'local_settings.py.erb'
owner 'root'
group node['openstack']['dashboard']['horizon_group']
mode 0o0640
mode '640'
sensitive true
variables(
@ -99,8 +99,7 @@ end
directory "#{node['openstack']['dashboard']['dash_path']}/local" do
owner 'root'
group node['openstack']['dashboard']['horizon_group']
mode 0o2770
action :create
mode '2770'
end
# resource can be triggered from other recipes (e.g. in
@ -123,7 +122,7 @@ secret_file =
file secret_file do
owner node['openstack']['dashboard']['horizon_user']
group node['openstack']['dashboard']['horizon_user']
mode 0600
mode '600'
subscribes :create, 'service[apache2]', :immediately
only_if { ::File.exist?(secret_file) }
end

View File

@ -1,58 +0,0 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-dashboard
# Recipe:: neutron-lbaas-dashboard
#
# 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.
include_recipe 'openstack-dashboard::horizon'
case node['platform_family']
when 'debian'
package 'python3-neutron-fwaas-dashboard'
when 'rhel'
django_path = node['openstack']['dashboard']['django_path']
policy_file_path = node['openstack']['dashboard']['policy_files_path']
python_package 'neutron-fwaas-dashboard'
%w(
_7010_project_firewalls_common.py
_7011_project_firewalls_panel.py
_7012_project_firewalls_v2_panel.py
).each do |file|
remote_file "#{django_path}/openstack_dashboard/local/enabled/#{file}" do
source "https://opendev.org/openstack/neutron-fwaas-dashboard/raw/branch/stable/rocky/neutron_fwaas_dashboard/enabled/#{file}"
owner 'root'
mode 0o0644
notifies :run, 'execute[neutron-fwaas-dashboard compilemessages]'
notifies :run, 'execute[openstack-dashboard collectstatic]'
end
end
remote_file "#{policy_file_path}/neutron-fwaas-policy.json" do
source 'https://opendev.org/openstack/neutron-fwaas-dashboard/raw/branch/stable/rocky/etc/neutron-fwaas-policy.json'
owner 'root'
mode 0o0644
notifies :run, 'execute[neutron-fwaas-dashboard compilemessages]'
notifies :run, 'execute[openstack-dashboard collectstatic]'
notifies :restart, 'service[apache2]', :delayed
end
execute 'neutron-fwaas-dashboard compilemessages' do
cwd django_path
environment 'PYTHONPATH' => "/etc/openstack-dashboard:#{django_path}:$PYTHONPATH"
command 'python manage.py compilemessages'
action :nothing
end
end

View File

@ -1,8 +1,10 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-dashboard
# Cookbook:: openstack-dashboard
# Recipe:: neutron-lbaas-dashboard
#
# Copyright:: 2020, Oregon State University
#
# 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
@ -29,9 +31,9 @@ when 'rhel'
end
remote_file "#{django_path}/openstack_dashboard/local/enabled/_1481_project_ng_loadbalancersv2_panel.py" do
source 'https://opendev.org/openstack/neutron-lbaas-dashboard/raw/branch/stable/rocky/neutron_lbaas_dashboard/enabled/_1481_project_ng_loadbalancersv2_panel.py'
source "https://opendev.org/openstack/neutron-lbaas-dashboard/raw/branch/stable/#{node['openstack']['release']}/neutron_lbaas_dashboard/enabled/_1481_project_ng_loadbalancersv2_panel.py"
owner 'root'
mode 0o0644
mode '644'
notifies :run, 'execute[openstack-dashboard collectstatic]'
end
end

View File

@ -20,12 +20,12 @@ describe 'openstack-dashboard::apache2-server' do
expect(chef_run).to create_file('/etc/pki/tls/certs/horizon.pem').with(
user: 'root',
group: 'root',
mode: 0o644
mode: '644'
)
expect(chef_run).to create_file('/etc/pki/tls/private/horizon.key').with(
user: 'root',
group: 'root',
mode: 0o640
mode: '640'
)
end

View File

@ -99,13 +99,13 @@ describe 'openstack-dashboard::apache2-server' do
content: 'horizon_pem_value',
user: 'root',
group: 'root',
mode: 0o644
mode: '644'
)
expect(chef_run).to create_file('/etc/ssl/private/horizon.key').with(
content: 'horizon_key_value',
user: 'root',
group: 'ssl-cert',
mode: 0o640
mode: '640'
)
end
end
@ -117,7 +117,7 @@ describe 'openstack-dashboard::apache2-server' do
content: 'horizon_chain_pem_value',
user: 'root',
group: 'root',
mode: 0o644
mode: '644'
)
end
end
@ -138,7 +138,7 @@ describe 'openstack-dashboard::apache2-server' do
content: 'horizon_pem_value',
user: 'root',
group: 'root',
mode: 0o644
mode: '644'
)
end
@ -147,7 +147,7 @@ describe 'openstack-dashboard::apache2-server' do
content: 'horizon_pem_value',
user: 'root',
group: 'ssl-cert',
mode: 0o640
mode: '640'
)
end
@ -188,13 +188,13 @@ describe 'openstack-dashboard::apache2-server' do
content: 'any_pem_value',
user: 'root',
group: 'root',
mode: 0o644
mode: '644'
)
expect(chef_run).to create_file('/etc/anypath/any.key').with(
content: 'any_key_value',
user: 'root',
group: 'ssl-cert',
mode: 0o640
mode: '640'
)
end
describe 'set ssl chain' do
@ -204,7 +204,7 @@ describe 'openstack-dashboard::apache2-server' do
content: 'any_chain_pem_value',
user: 'root',
group: 'root',
mode: 0o644
mode: '644'
)
end
end
@ -555,7 +555,7 @@ describe 'openstack-dashboard::apache2-server' do
end
it 'has correct mode' do
expect(file.mode).to eq(0o0600)
expect(file.mode).to eq('600')
end
it 'does not notify apache2 restart' do

View File

@ -13,9 +13,7 @@ describe 'openstack-dashboard::horizon' do
include_context 'redhat_stubs'
it 'installs packages' do
expect(chef_run).to upgrade_package('openstack-dashboard')
expect(chef_run).to upgrade_package('mod_wsgi')
expect(chef_run).to upgrade_package('MySQL-python')
expect(chef_run).to upgrade_package %w(openstack-dashboard mod_wsgi MySQL-python)
end
describe 'local_settings' do
@ -25,7 +23,7 @@ describe 'openstack-dashboard::horizon' do
expect(chef_run).to create_template(file.name).with(
user: 'root',
group: 'apache',
mode: 0o640
mode: '640'
)
end

View File

@ -58,11 +58,7 @@ describe 'openstack-dashboard::horizon' do
include_context 'dashboard_stubs'
it 'installs packages' do
expect(chef_run).to upgrade_package('node-less')
expect(chef_run).to upgrade_package('libapache2-mod-wsgi-py3')
expect(chef_run).to upgrade_package('python3-django-horizon')
expect(chef_run).to upgrade_package('openstack-dashboard')
expect(chef_run).to upgrade_package('python3-mysqldb')
expect(chef_run).to upgrade_package %w(node-less libapache2-mod-wsgi-py3 python3-django-horizon openstack-dashboard python3-mysqldb)
end
describe 'local_settings.py' do
@ -73,7 +69,7 @@ describe 'openstack-dashboard::horizon' do
sensitive: true,
user: 'root',
group: 'horizon',
mode: 0o640
mode: '640'
)
end
@ -444,7 +440,7 @@ describe 'openstack-dashboard::horizon' do
context "#{service_type} database settings" do
cached(:chef_run) do
node.override['openstack']['db']['dashboard']['username'] = "#{service_type}_user"
node.override['openstack']['db']['python_packages'][service_type] = ['pkg1', 'pkg2']
node.override['openstack']['db']['python_packages'][service_type] = %w(pkg1 pkg2)
runner.converge('openstack-identity::server-apache', described_recipe)
end
before do
@ -553,7 +549,7 @@ describe 'openstack-dashboard::horizon' do
.with(
owner: 'root',
group: 'horizon',
mode: 0o2770
mode: '2770'
)
end
end

View File

@ -1,23 +0,0 @@
# encoding: UTF-8
require_relative 'spec_helper'
describe 'openstack-dashboard::neutron-fwaas-dashboard' do
describe 'ubuntu' do
cached(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
cached(:node) { runner.node }
cached(:chef_run) do
runner.converge('openstack-identity::server-apache', described_recipe)
end
include_context 'non_redhat_stubs'
include_context 'dashboard_stubs'
it do
expect(chef_run).to include_recipe('openstack-dashboard::horizon')
end
it do
expect(chef_run).to install_package('python3-neutron-fwaas-dashboard')
end
end
end

View File

@ -225,7 +225,6 @@ OPENSTACK_NEUTRON_NETWORK = {
'enable_lb': <%= node['openstack']['dashboard']['neutron']['enable_lb'].to_s.capitalize %>,
'enable_vpn': <%= node['openstack']['dashboard']['neutron']['enable_vpn'].to_s.capitalize %>,
'enable_quotas': <%= node['openstack']['dashboard']['neutron']['enable_quotas'] ? 'True' : 'False' %>,
'enable_firewall': <%= node['openstack']['dashboard']['neutron']['enable_fwaas'].to_s.capitalize %>,
# The profile_support option is used to detect if an external router can be
# configured via the dashboard. When using specific plugins the
# profile_support can be turned on if needed.