Use python3 packages on Ubuntu

Python2.7 is going EOL soon, let us deploy python3 for Rocky from the
start, so we avoid having to switch later.

Add a workaround because the apache2::mod_wsgi recipe hardcodes python2 deployment.

Install neutron-*aas-dashboard plugins as distro packages and not from pypi.

Change-Id: Ia994665c69b64725e7e5369ceb93ee9608620d2b
This commit is contained in:
Jens Harbott 2019-09-18 13:49:34 +00:00
parent 8f5ef483b9
commit 1fe8dedbab
8 changed files with 16 additions and 111 deletions

View File

@ -130,10 +130,10 @@ when 'debian'
default['openstack']['dashboard']['logout_url'] = nil
default['openstack']['dashboard']['login_redirect_url'] = nil
default['openstack']['dashboard']['platform'] = {
'memcache_python_packages' => ['python-memcache'],
'memcache_python_packages' => ['python3-memcache'],
'package_overrides' => '',
}
default['openstack']['dashboard']['platform']['horizon_packages'] = ['node-less', 'openstack-dashboard']
default['openstack']['dashboard']['platform']['horizon_packages'] = ['node-less', 'libapache2-mod-wsgi-py3', 'python3-django-horizon', 'openstack-dashboard']
default['openstack']['dashboard']['apache']['sites-path'] = "#{node['apache']['dir']}/sites-available/openstack-dashboard.conf"
else
default['openstack']['dashboard']['key_group'] = 'root'
@ -220,5 +220,3 @@ default['openstack']['dashboard']['neutron']['enable_fwaas'] = false
# 'varable2': 'value2',
# }
default['openstack']['dashboard']['misc_local_settings'] = nil
# version of python neutron-lbaas-dashboard package to install
default['openstack']['dashboard']['lbaas']['version'] = '3.0.1'

View File

@ -62,7 +62,13 @@ node.normal['apache']['listen'] = apache2_listen.uniq
include_recipe 'apache2'
include_recipe 'apache2::mod_headers'
include_recipe 'apache2::mod_wsgi'
# TODO(jh): hardcoded to include py2 mod-wsgi package
# include_recipe 'apache2::mod_wsgi'
package 'libapache2-mod-wsgi-py3' do
only_if { platform_family?('debian') }
end
apache_module 'wsgi'
include_recipe 'apache2::mod_rewrite'
include_recipe 'apache2::mod_ssl' if node['openstack']['dashboard']['use_ssl']

View File

@ -17,37 +17,4 @@
include_recipe 'openstack-dashboard::horizon'
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://raw.githubusercontent.com/openstack/neutron-fwaas-dashboard/stable/queens/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://raw.githubusercontent.com/openstack/neutron-fwaas-dashboard/stable/queens/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
package 'python3-neutron-fwaas-dashboard'

View File

@ -17,17 +17,4 @@
include_recipe 'openstack-dashboard::horizon'
django_path = node['openstack']['dashboard']['django_path']
python_package 'neutron-lbaas-dashboard' do
version node['openstack']['dashboard']['lbaas']['version']
notifies :run, 'execute[restore-selinux-context]', :immediately
notifies :run, 'execute[openstack-dashboard collectstatic]'
end
remote_file "#{django_path}/openstack_dashboard/local/enabled/_1481_project_ng_loadbalancersv2_panel.py" do
source 'https://raw.githubusercontent.com/openstack/neutron-lbaas-dashboard/stable/queens/neutron_lbaas_dashboard/enabled/_1481_project_ng_loadbalancersv2_panel.py'
owner 'root'
mode 0o0644
notifies :run, 'execute[openstack-dashboard collectstatic]'
end
package 'python3-neutron-lbaas-dashboard'

View File

@ -69,7 +69,6 @@ describe 'openstack-dashboard::apache2-server' do
it 'includes apache packages' do
%w(apache2
apache2::mod_headers
apache2::mod_wsgi
apache2::mod_rewrite
apache2::mod_ssl).each do |recipe|
expect(chef_run).to include_recipe(recipe)

View File

@ -19,8 +19,10 @@ describe 'openstack-dashboard::horizon' do
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('python-mysqldb')
expect(chef_run).to upgrade_package('python3-mysqldb')
end
describe 'local_settings.py' do

View File

@ -17,46 +17,7 @@ describe 'openstack-dashboard::neutron-fwaas-dashboard' do
end
it do
expect(chef_run).to install_python_package('neutron-fwaas-dashboard')
end
%w(
_7010_project_firewalls_common.py
_7011_project_firewalls_panel.py
_7012_project_firewalls_v2_panel.py
).each do |file|
it do
expect(chef_run).to create_remote_file(
"#{node['openstack']['dashboard']['django_path']}/openstack_dashboard/local/enabled/#{file}"
).with(
mode: 0o0644,
owner: 'root',
source: "https://raw.githubusercontent.com/openstack/neutron-fwaas-dashboard/stable/queens/neutron_fwaas_dashboard/enabled/#{file}"
)
end
it do
expect(chef_run.remote_file("#{node['openstack']['dashboard']['django_path']}/openstack_dashboard/local/enabled/#{file}"))
.to notify('execute[openstack-dashboard collectstatic]').to(:run)
notify('execute[neutron-fwaas-dashboard compilemessages]').to(:run)
end
end
it do
expect(chef_run).to create_remote_file(
"#{node['openstack']['dashboard']['policy_files_path']}/neutron-fwaas-policy.json"
).with(
mode: 0o0644,
owner: 'root',
source: 'https://raw.githubusercontent.com/openstack/neutron-fwaas-dashboard/stable/queens/etc/neutron-fwaas-policy.json'
)
end
it do
expect(chef_run.remote_file("#{node['openstack']['dashboard']['policy_files_path']}/neutron-fwaas-policy.json"))
.to notify('execute[openstack-dashboard collectstatic]').to(:run)
notify('execute[neutron-fwaas-dashboard compilemessages]').to(:run)
notify('service[apache2]').to(:restart).delayed
expect(chef_run).to install_package('python3-neutron-fwaas-dashboard')
end
end
end

View File

@ -17,22 +17,7 @@ describe 'openstack-dashboard::neutron-lbaas-dashboard' do
end
it do
expect(chef_run).to install_python_package('neutron-lbaas-dashboard')
end
it do
expect(chef_run).to create_remote_file(
"#{node['openstack']['dashboard']['django_path']}/openstack_dashboard/local/enabled/_1481_project_ng_loadbalancersv2_panel.py"
).with(
mode: 0o0644,
owner: 'root',
source: 'https://raw.githubusercontent.com/openstack/neutron-lbaas-dashboard/stable/queens/neutron_lbaas_dashboard/enabled/_1481_project_ng_loadbalancersv2_panel.py'
)
end
it do
expect(chef_run.remote_file("#{node['openstack']['dashboard']['django_path']}/openstack_dashboard/local/enabled/_1481_project_ng_loadbalancersv2_panel.py"))
.to notify('execute[openstack-dashboard collectstatic]')
expect(chef_run).to install_package('python3-neutron-lbaas-dashboard')
end
end
end