Fixes for Ocata, define socket for MySQL
- bumped chefdk to 1.5 - bumped mariadb to 1.5 - style fixes to make rubocop/foodcritic happy - rewrote metadata.rb for readability - removed ancient Gemfile - removed openshift rubygems mirror since it doesn't help us Change-Id: I950605f384405b55737af77bc4224f1e18fee8e1
This commit is contained in:
parent
eb465b4f68
commit
479af11fd7
|
@ -1,6 +1,6 @@
|
||||||
# This configuration was generated by
|
# This configuration was generated by
|
||||||
# `rubocop --auto-gen-config`
|
# `rubocop --auto-gen-config`
|
||||||
# on 2017-02-23 16:58:23 +0100 using RuboCop version 0.39.0.
|
# on 2017-08-01 09:24:32 -0400 using RuboCop version 0.47.1.
|
||||||
# The point is for the user to remove these configuration records
|
# The point is for the user to remove these configuration records
|
||||||
# one by one as the offenses are removed from the code base.
|
# one by one as the offenses are removed from the code base.
|
||||||
# Note that changes in the inspected code, or installation of new
|
# Note that changes in the inspected code, or installation of new
|
||||||
|
@ -15,6 +15,11 @@ Lint/NestedMethodDefinition:
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Max: 39
|
Max: 39
|
||||||
|
|
||||||
|
# Offense count: 45
|
||||||
|
# Configuration parameters: CountComments, ExcludedMethods.
|
||||||
|
Metrics/BlockLength:
|
||||||
|
Max: 203
|
||||||
|
|
||||||
# Offense count: 1
|
# Offense count: 1
|
||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
Max: 13
|
Max: 13
|
||||||
|
@ -33,19 +38,3 @@ Style/ClassAndModuleChildren:
|
||||||
- 'libraries/search.rb'
|
- 'libraries/search.rb'
|
||||||
- 'libraries/uri.rb'
|
- 'libraries/uri.rb'
|
||||||
- 'libraries/wrappers.rb'
|
- 'libraries/wrappers.rb'
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
|
|
||||||
# SupportedStyles: skip_modifier_ifs, always
|
|
||||||
Style/Next:
|
|
||||||
Exclude:
|
|
||||||
- 'libraries/parse.rb'
|
|
||||||
|
|
||||||
# Offense count: 2
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: IgnoredMethods.
|
|
||||||
# IgnoredMethods: respond_to
|
|
||||||
Style/SymbolProc:
|
|
||||||
Exclude:
|
|
||||||
- 'libraries/parse.rb'
|
|
||||||
|
|
15
Gemfile
15
Gemfile
|
@ -1,15 +0,0 @@
|
||||||
## THIS GEMFILE IS DEPRECATED AND WILL BE REMOVED AFTER THE NEXT RELEASE
|
|
||||||
## THERE WON'T BE ANY UPDATES TO THIS FILE DURING THIS RELEASE CYCLE
|
|
||||||
## WE SWITCHED TO CHEFDK AS THE BUNDLE FOR THE NEEDED GEMS
|
|
||||||
|
|
||||||
source 'https://rubygems.org'
|
|
||||||
|
|
||||||
gem 'chef', '~> 11.18.6'
|
|
||||||
gem 'json', '<= 1.7.7' # chef 11 dependency
|
|
||||||
gem 'berkshelf', '~> 3.2.1'
|
|
||||||
gem 'hashie', '~> 2.0'
|
|
||||||
gem 'chefspec', '~> 4.0.0'
|
|
||||||
gem 'rspec', '~> 3.0.0'
|
|
||||||
gem 'foodcritic', '~> 4.0'
|
|
||||||
gem 'rubocop', '~> 0.29.1'
|
|
||||||
gem 'chef-vault', '~> 2.3'
|
|
|
@ -88,7 +88,7 @@ default['openstack']['endpoints']['db']['slave_port'] = '3316'
|
||||||
# will work for mysql databases, since it will use a direct connection via
|
# will work for mysql databases, since it will use a direct connection via
|
||||||
# the socket, so the database does not have not to listen on 127.0.0.1.
|
# the socket, so the database does not have not to listen on 127.0.0.1.
|
||||||
# Set this to 'localhost' for mysql to connect via socket.
|
# Set this to 'localhost' for mysql to connect via socket.
|
||||||
default['openstack']['endpoints']['db']['host_for_db_root_user'] = nil
|
default['openstack']['endpoints']['db']['host_for_db_root_user'] = 'localhost'
|
||||||
|
|
||||||
# Default database attributes
|
# Default database attributes
|
||||||
default['openstack']['db']['server_role'] = 'os-ops-database'
|
default['openstack']['db']['server_role'] = 'os-ops-database'
|
||||||
|
@ -135,6 +135,14 @@ when 'debian'
|
||||||
default['openstack']['db']['python_packages']['galera'] = ['python-mysqldb']
|
default['openstack']['db']['python_packages']['galera'] = ['python-mysqldb']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# database sockets, because different
|
||||||
|
case node['platform_family']
|
||||||
|
when 'rhel'
|
||||||
|
default['openstack']['db']['socket'] = '/var/lib/mysql/mysql.sock'
|
||||||
|
when 'debian'
|
||||||
|
default['openstack']['db']['socket'] = '/run/mysql-default/mysqld.sock'
|
||||||
|
end
|
||||||
|
|
||||||
# Database used by the OpenStack services
|
# Database used by the OpenStack services
|
||||||
node['openstack']['common']['services'].each do |service, project|
|
node['openstack']['common']['services'].each do |service, project|
|
||||||
default['openstack']['db'][service]['service_type'] = node['openstack']['db']['service_type']
|
default['openstack']['db'][service]['service_type'] = node['openstack']['db']['service_type']
|
||||||
|
@ -147,6 +155,8 @@ node['openstack']['common']['services'].each do |service, project|
|
||||||
default['openstack']['db'][service]['slave_host'] = node['openstack']['endpoints']['db']['slave_host']
|
default['openstack']['db'][service]['slave_host'] = node['openstack']['endpoints']['db']['slave_host']
|
||||||
default['openstack']['db'][service]['slave_port'] = node['openstack']['endpoints']['db']['slave_port']
|
default['openstack']['db'][service]['slave_port'] = node['openstack']['endpoints']['db']['slave_port']
|
||||||
|
|
||||||
|
default['openstack']['db'][service]['socket'] = node['openstack']['db']['socket']
|
||||||
|
|
||||||
case service
|
case service
|
||||||
when 'dashboard'
|
when 'dashboard'
|
||||||
default['openstack']['db'][service]['migrate'] = true
|
default['openstack']['db'][service]['migrate'] = true
|
||||||
|
|
|
@ -72,7 +72,7 @@ default['openstack']['use_databags'] = true
|
||||||
# feature of the official chef project, you can use 'vault' to
|
# feature of the official chef project, you can use 'vault' to
|
||||||
# encrypt your secrets with the method provided in the chef-vault gem.
|
# encrypt your secrets with the method provided in the chef-vault gem.
|
||||||
default['openstack']['databag_type'] = 'encrypted'
|
default['openstack']['databag_type'] = 'encrypted'
|
||||||
default['openstack']['vault_gem_version'] = '~> 2.3'
|
default['openstack']['vault_gem_version'] = '~> 3.2'
|
||||||
|
|
||||||
# Default attributes when not using data bags (use_databags = false)
|
# Default attributes when not using data bags (use_databags = false)
|
||||||
node['openstack']['common']['services'].each_key do |service|
|
node['openstack']['common']['services'].each_key do |service|
|
||||||
|
|
10
bootstrap.sh
10
bootstrap.sh
|
@ -11,7 +11,7 @@ if [ -f /usr/bin/yum ] ; then
|
||||||
sudo pip uninstall requests -y || true
|
sudo pip uninstall requests -y || true
|
||||||
|
|
||||||
# install chefdk
|
# install chefdk
|
||||||
chefdk=chefdk-1.0.3-1.el7.x86_64.rpm
|
chefdk=chefdk-1.5.0-1.el7.x86_64.rpm
|
||||||
wget -nv -t 3 https://packages.chef.io/stable/el/7/$chefdk
|
wget -nv -t 3 https://packages.chef.io/stable/el/7/$chefdk
|
||||||
sudo yum -y install $chefdk
|
sudo yum -y install $chefdk
|
||||||
rm $chefdk
|
rm $chefdk
|
||||||
|
@ -26,8 +26,8 @@ elif [ -f /usr/bin/apt-get ]; then
|
||||||
sudo apt-get -y install build-essential liblzma-dev zlib1g-dev
|
sudo apt-get -y install build-essential liblzma-dev zlib1g-dev
|
||||||
|
|
||||||
# install chefdk
|
# install chefdk
|
||||||
chefdk=chefdk_1.0.3-1_amd64.deb
|
chefdk=chefdk_1.5.0-1_amd64.deb
|
||||||
wget -nv -t 3 https://packages.chef.io/stable/ubuntu/12.04/$chefdk
|
wget -nv -t 3 https://packages.chef.io/stable/ubuntu/16.04/$chefdk
|
||||||
sudo dpkg -i $chefdk
|
sudo dpkg -i $chefdk
|
||||||
rm $chefdk
|
rm $chefdk
|
||||||
|
|
||||||
|
@ -46,10 +46,6 @@ if [ -f /etc/nodepool/provider ]; then
|
||||||
CENTOS_MIRROR_HOST=${NODEPOOL_MIRROR_HOST}
|
CENTOS_MIRROR_HOST=${NODEPOOL_MIRROR_HOST}
|
||||||
UCA_MIRROR_HOST="${NODEPOOL_MIRROR_HOST}/ubuntu-cloud-archive"
|
UCA_MIRROR_HOST="${NODEPOOL_MIRROR_HOST}/ubuntu-cloud-archive"
|
||||||
CEPH_MIRROR_HOST="${NODEPOOL_MIRROR_HOST}/ceph-deb-jewel"
|
CEPH_MIRROR_HOST="${NODEPOOL_MIRROR_HOST}/ceph-deb-jewel"
|
||||||
# due to rubygems.org timeouts, use OpenShift's mirror
|
|
||||||
chef exec gem sources --remove https://rubygems.org/
|
|
||||||
chef exec gem sources --add http://mirror.ops.rhcloud.com/mirror/ruby/
|
|
||||||
chef exec gem sources --list
|
|
||||||
else
|
else
|
||||||
CENTOS_MIRROR_HOST='mirror.centos.org'
|
CENTOS_MIRROR_HOST='mirror.centos.org'
|
||||||
UCA_MIRROR_HOST='ubuntu-cloud.archive.canonical.com/ubuntu'
|
UCA_MIRROR_HOST='ubuntu-cloud.archive.canonical.com/ubuntu'
|
||||||
|
|
|
@ -76,8 +76,8 @@ module ::Openstack
|
||||||
|
|
||||||
# Build uri
|
# Build uri
|
||||||
case type
|
case type
|
||||||
when 'mysql', 'postgresql'
|
when 'mysql'
|
||||||
"#{type}://#{user}:#{pass}@#{host}:#{port}/#{name}#{options}"
|
"mysql+pymysql://#{user}:#{pass}@#{host}:#{port}/#{name}#{options}"
|
||||||
when 'sqlite'
|
when 'sqlite'
|
||||||
# SQLite uses filepaths not db name
|
# SQLite uses filepaths not db name
|
||||||
# README(galstrom): 3 slashes is a relative path, 4 slashes is an absolute path
|
# README(galstrom): 3 slashes is a relative path, 4 slashes is an absolute path
|
||||||
|
|
|
@ -31,18 +31,17 @@ module ::Openstack
|
||||||
ret = []
|
ret = []
|
||||||
return ret if table.nil?
|
return ret if table.nil?
|
||||||
indicies = []
|
indicies = []
|
||||||
(table.split(/$/).map { |x| x.strip }).each do |line|
|
table.split(/$/).map(&:strip).each do |line|
|
||||||
unless line.start_with?('+--') || line.empty?
|
next if line.start_with?('+--') || line.empty?
|
||||||
cols = line.split('|').map { |x| x.strip }
|
cols = line.split('|').map(&:strip)
|
||||||
cols.shift
|
cols.shift
|
||||||
if indicies == []
|
if indicies == []
|
||||||
indicies = cols
|
indicies = cols
|
||||||
next
|
next
|
||||||
end
|
|
||||||
newobj = {}
|
|
||||||
cols.each { |val| newobj[indicies[newobj.length]] = val }
|
|
||||||
ret.push(newobj)
|
|
||||||
end
|
end
|
||||||
|
newobj = {}
|
||||||
|
cols.each { |val| newobj[indicies[newobj.length]] = val }
|
||||||
|
ret.push(newobj)
|
||||||
end
|
end
|
||||||
|
|
||||||
# this kinda sucks, but some prettytable data comes
|
# this kinda sucks, but some prettytable data comes
|
||||||
|
|
18
metadata.rb
18
metadata.rb
|
@ -1,12 +1,10 @@
|
||||||
name 'openstack-common'
|
name 'openstack-common'
|
||||||
maintainer 'openstack-chef'
|
maintainer 'openstack-chef'
|
||||||
maintainer_email 'openstack-dev@lists.openstack.org'
|
maintainer_email 'openstack-dev@lists.openstack.org'
|
||||||
issues_url 'https://launchpad.net/openstack-chef' if respond_to?(:issues_url)
|
license 'Apache 2.0'
|
||||||
source_url 'https://github.com/openstack/cookbook-openstack-common' if respond_to?(:source_url)
|
description 'Common OpenStack attributes, libraries and recipes.'
|
||||||
license 'Apache 2.0'
|
|
||||||
description 'Common OpenStack attributes, libraries and recipes.'
|
|
||||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||||
version '15.0.0'
|
version '15.0.0'
|
||||||
|
|
||||||
recipe 'openstack-common', 'Installs/Configures common recipes'
|
recipe 'openstack-common', 'Installs/Configures common recipes'
|
||||||
recipe 'openstack-common::logging', 'Installs/Configures common logging'
|
recipe 'openstack-common::logging', 'Installs/Configures common logging'
|
||||||
|
@ -18,8 +16,12 @@ end
|
||||||
|
|
||||||
depends 'apt', '~> 5.0'
|
depends 'apt', '~> 5.0'
|
||||||
depends 'database', '~> 6.1'
|
depends 'database', '~> 6.1'
|
||||||
depends 'mariadb', '~> 0.3.3'
|
depends 'mariadb', '~> 1.5'
|
||||||
depends 'mysql', '~> 8.2'
|
depends 'mysql', '~> 8.2'
|
||||||
depends 'yum', '~> 3.13'
|
depends 'yum', '~> 3.13'
|
||||||
depends 'yum-epel', '~> 2.0'
|
depends 'yum-epel', '~> 2.0'
|
||||||
depends 'poise-python', '~> 1.5'
|
depends 'poise-python', '~> 1.5'
|
||||||
|
|
||||||
|
issues_url 'https://launchpad.net/openstack-chef' if respond_to?(:issues_url)
|
||||||
|
source_url 'https://github.com/openstack/cookbook-openstack-common' if respond_to?(:source_url)
|
||||||
|
chef_version '>= 12.5' if respond_to?(:chef_version)
|
||||||
|
|
|
@ -27,6 +27,7 @@ def info
|
||||||
@port = service_info['port'] || info['port']
|
@port = service_info['port'] || info['port']
|
||||||
user_key = node['openstack']['db']['root_user_key']
|
user_key = node['openstack']['db']['root_user_key']
|
||||||
@super_password = get_password 'db', user_key
|
@super_password = get_password 'db', user_key
|
||||||
|
@socket = node['openstack']['db']['socket']
|
||||||
@db_type = service_info['service_type']
|
@db_type = service_info['service_type']
|
||||||
@db_name = service_info['db_name']
|
@db_name = service_info['db_name']
|
||||||
@user = new_resource.user
|
@user = new_resource.user
|
||||||
|
@ -55,7 +56,8 @@ def connection_info
|
||||||
host: @host,
|
host: @host,
|
||||||
port: @port.to_i,
|
port: @port.to_i,
|
||||||
username: @super_user,
|
username: @super_user,
|
||||||
password: @super_password
|
password: @super_password,
|
||||||
|
socket: @socket
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
directory '/etc/openstack' do
|
directory '/etc/openstack' do
|
||||||
owner 'root'
|
owner 'root'
|
||||||
group 'root'
|
group 'root'
|
||||||
mode 00755
|
mode 0o0755
|
||||||
action :create
|
action :create
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ template '/etc/openstack/logging.conf' do
|
||||||
source 'logging.conf.erb'
|
source 'logging.conf.erb'
|
||||||
owner 'root'
|
owner 'root'
|
||||||
group 'root'
|
group 'root'
|
||||||
mode 00644
|
mode 0o0644
|
||||||
variables(
|
variables(
|
||||||
loggers: node['openstack']['logging']['loggers'],
|
loggers: node['openstack']['logging']['loggers'],
|
||||||
formatters: node['openstack']['logging']['formatters'],
|
formatters: node['openstack']['logging']['formatters'],
|
||||||
|
|
|
@ -21,14 +21,14 @@
|
||||||
directory '/etc/sysctl.d' do
|
directory '/etc/sysctl.d' do
|
||||||
owner 'root'
|
owner 'root'
|
||||||
group 'root'
|
group 'root'
|
||||||
mode 00755
|
mode 0o0755
|
||||||
end
|
end
|
||||||
|
|
||||||
template '/etc/sysctl.d/60-openstack.conf' do
|
template '/etc/sysctl.d/60-openstack.conf' do
|
||||||
source '60-openstack.conf.erb'
|
source '60-openstack.conf.erb'
|
||||||
owner 'root'
|
owner 'root'
|
||||||
group 'root'
|
group 'root'
|
||||||
mode 00644
|
mode 0o0644
|
||||||
end
|
end
|
||||||
|
|
||||||
execute 'sysctl -p /etc/sysctl.d/60-openstack.conf' do
|
execute 'sysctl -p /etc/sysctl.d/60-openstack.conf' do
|
||||||
|
|
|
@ -30,7 +30,7 @@ describe 'test-openstack-common-database::default' do
|
||||||
expect(chef_run).to create_database('create database service_db')
|
expect(chef_run).to create_database('create database service_db')
|
||||||
.with(
|
.with(
|
||||||
provider: ::Chef::Provider::Database::Mysql,
|
provider: ::Chef::Provider::Database::Mysql,
|
||||||
connection: { host: 'localhost123', port: 3306, username: 'root', password: 'root_pass' },
|
connection: { host: 'localhost123', port: 3306, username: 'root', password: 'root_pass', socket: '/run/mysql-default/mysqld.sock' },
|
||||||
database_name: 'service_db',
|
database_name: 'service_db',
|
||||||
encoding: 'utf8'
|
encoding: 'utf8'
|
||||||
)
|
)
|
||||||
|
@ -41,7 +41,7 @@ describe 'test-openstack-common-database::default' do
|
||||||
expect(chef_run).to create_database('create database service_db')
|
expect(chef_run).to create_database('create database service_db')
|
||||||
.with(
|
.with(
|
||||||
provider: ::Chef::Provider::Database::Mysql,
|
provider: ::Chef::Provider::Database::Mysql,
|
||||||
connection: { host: '127.0.0.1', port: 3306, username: 'root', password: 'root_pass' },
|
connection: { host: 'localhost', port: 3306, username: 'root', password: 'root_pass', socket: '/run/mysql-default/mysqld.sock' },
|
||||||
database_name: 'service_db',
|
database_name: 'service_db',
|
||||||
encoding: 'utf8'
|
encoding: 'utf8'
|
||||||
)
|
)
|
||||||
|
@ -51,7 +51,7 @@ describe 'test-openstack-common-database::default' do
|
||||||
expect(chef_run).to create_database_user('create database user db_user')
|
expect(chef_run).to create_database_user('create database user db_user')
|
||||||
.with(
|
.with(
|
||||||
provider: ::Chef::Provider::Database::MysqlUser,
|
provider: ::Chef::Provider::Database::MysqlUser,
|
||||||
connection: { host: '127.0.0.1', port: 3306, username: 'root', password: 'root_pass' },
|
connection: { host: 'localhost', port: 3306, username: 'root', password: 'root_pass', socket: '/run/mysql-default/mysqld.sock' },
|
||||||
username: 'db_user',
|
username: 'db_user',
|
||||||
password: 'db_pass'
|
password: 'db_pass'
|
||||||
)
|
)
|
||||||
|
@ -61,7 +61,7 @@ describe 'test-openstack-common-database::default' do
|
||||||
expect(chef_run).to grant_database_user('grant database user db_user')
|
expect(chef_run).to grant_database_user('grant database user db_user')
|
||||||
.with(
|
.with(
|
||||||
provider: ::Chef::Provider::Database::MysqlUser,
|
provider: ::Chef::Provider::Database::MysqlUser,
|
||||||
connection: { host: '127.0.0.1', port: 3306, username: 'root', password: 'root_pass' },
|
connection: { host: 'localhost', port: 3306, username: 'root', password: 'root_pass', socket: '/run/mysql-default/mysqld.sock' },
|
||||||
username: 'db_user',
|
username: 'db_user',
|
||||||
password: 'db_pass',
|
password: 'db_pass',
|
||||||
database_name: 'service_db',
|
database_name: 'service_db',
|
||||||
|
@ -70,45 +70,6 @@ describe 'test-openstack-common-database::default' do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'postgresql' do
|
|
||||||
before do
|
|
||||||
node.override['openstack']['db']['service'] = { service_type: 'postgresql', port: 5432, db_name: 'service_postgres' }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates the database with the database resource' do
|
|
||||||
expect(chef_run).to create_database('create database service_postgres')
|
|
||||||
.with(
|
|
||||||
provider: ::Chef::Provider::Database::Postgresql,
|
|
||||||
connection: { host: '127.0.0.1', port: 5432, username: 'postgres', password: 'root_pass' },
|
|
||||||
database_name: 'service_postgres',
|
|
||||||
encoding: 'DEFAULT'
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates the database use with the database_user resource' do
|
|
||||||
expect(chef_run).to create_database_user('create database user db_user')
|
|
||||||
.with(
|
|
||||||
provider: ::Chef::Provider::Database::PostgresqlUser,
|
|
||||||
connection: { host: '127.0.0.1', port: 5432, username: 'postgres', password: 'root_pass' },
|
|
||||||
username: 'db_user',
|
|
||||||
password: 'db_pass'
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'grants database privileges to the user with the database_user resource' do
|
|
||||||
expect(chef_run).to grant_database_user('grant database user db_user')
|
|
||||||
.with(
|
|
||||||
provider: ::Chef::Provider::Database::PostgresqlUser,
|
|
||||||
connection: { host: '127.0.0.1', port: 5432, username: 'postgres', password: 'root_pass' },
|
|
||||||
username: 'db_user',
|
|
||||||
password: 'db_pass',
|
|
||||||
database_name: 'service_postgres',
|
|
||||||
host: '%',
|
|
||||||
privileges: [:all]
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'galera' do
|
context 'galera' do
|
||||||
before do
|
before do
|
||||||
node.override['openstack']['db']['service'] = { service_type: 'galera', port: 3306, db_name: 'service_db' }
|
node.override['openstack']['db']['service'] = { service_type: 'galera', port: 3306, db_name: 'service_db' }
|
||||||
|
|
|
@ -30,7 +30,8 @@ describe 'openstack-common::default' do
|
||||||
expect(chef_run).to add_apt_repository('openstack-ppa').with(
|
expect(chef_run).to add_apt_repository('openstack-ppa').with(
|
||||||
uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
|
uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
|
||||||
distribution: 'xenial-updates/ocata',
|
distribution: 'xenial-updates/ocata',
|
||||||
components: ['main'])
|
components: ['main']
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'disables openstack live updates' do
|
it 'disables openstack live updates' do
|
||||||
|
@ -38,7 +39,8 @@ describe 'openstack-common::default' do
|
||||||
expect(chef_run).to_not add_apt_repository('openstack-ppa').with(
|
expect(chef_run).to_not add_apt_repository('openstack-ppa').with(
|
||||||
uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
|
uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
|
||||||
distribution: 'xenial-updates/ocata',
|
distribution: 'xenial-updates/ocata',
|
||||||
components: ['main'])
|
components: ['main']
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not install the gem chef-vault by default' do
|
it 'does not install the gem chef-vault by default' do
|
||||||
|
@ -48,7 +50,7 @@ describe 'openstack-common::default' do
|
||||||
it 'installs the gem chef-vault if databag_type is vault' do
|
it 'installs the gem chef-vault if databag_type is vault' do
|
||||||
node.set['openstack']['databag_type'] = 'vault'
|
node.set['openstack']['databag_type'] = 'vault'
|
||||||
expect(chef_run).to install_chef_gem('chef-vault')
|
expect(chef_run).to install_chef_gem('chef-vault')
|
||||||
.with(version: '~> 2.3')
|
.with(version: '~> 3.2')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'rabbit mq' do
|
context 'rabbit mq' do
|
||||||
|
|
|
@ -158,7 +158,7 @@ describe 'openstack-common::default' do
|
||||||
|
|
||||||
it 'returns compute db info hash when service found for default mysql' do
|
it 'returns compute db info hash when service found for default mysql' do
|
||||||
allow(subject).to receive(:node).and_return(chef_run.node)
|
allow(subject).to receive(:node).and_return(chef_run.node)
|
||||||
expected = 'mysql://user:pass@127.0.0.1:3306/nova?charset=utf8'
|
expected = 'mysql+pymysql://user:pass@127.0.0.1:3306/nova?charset=utf8'
|
||||||
expect(
|
expect(
|
||||||
subject.db_uri('compute', 'user', 'pass')
|
subject.db_uri('compute', 'user', 'pass')
|
||||||
).to eq(expected)
|
).to eq(expected)
|
||||||
|
@ -178,7 +178,7 @@ describe 'openstack-common::default' do
|
||||||
it 'returns compute db info hash when service found for mariadb' do
|
it 'returns compute db info hash when service found for mariadb' do
|
||||||
node.set['openstack']['db']['service_type'] = 'mariadb'
|
node.set['openstack']['db']['service_type'] = 'mariadb'
|
||||||
allow(subject).to receive(:node).and_return(chef_run.node)
|
allow(subject).to receive(:node).and_return(chef_run.node)
|
||||||
expected = 'mysql://user:pass@127.0.0.1:3306/nova?charset=utf8'
|
expected = 'mysql+pymysql://user:pass@127.0.0.1:3306/nova?charset=utf8'
|
||||||
expect(
|
expect(
|
||||||
subject.db_uri('compute', 'user', 'pass')
|
subject.db_uri('compute', 'user', 'pass')
|
||||||
).to eq(expected)
|
).to eq(expected)
|
||||||
|
@ -188,7 +188,7 @@ describe 'openstack-common::default' do
|
||||||
it "returns compute db info hash when service found for #{db}" do
|
it "returns compute db info hash when service found for #{db}" do
|
||||||
node.set['openstack']['db']['service_type'] = db
|
node.set['openstack']['db']['service_type'] = db
|
||||||
allow(subject).to receive(:node).and_return(chef_run.node)
|
allow(subject).to receive(:node).and_return(chef_run.node)
|
||||||
expected = 'mysql://user:pass@127.0.0.1:3306/nova?charset=utf8'
|
expected = 'mysql+pymysql://user:pass@127.0.0.1:3306/nova?charset=utf8'
|
||||||
expect(
|
expect(
|
||||||
subject.db_uri('compute', 'user', 'pass')
|
subject.db_uri('compute', 'user', 'pass')
|
||||||
).to eq(expected)
|
).to eq(expected)
|
||||||
|
@ -198,7 +198,7 @@ describe 'openstack-common::default' do
|
||||||
it 'returns compute slave db info hash when service found for default mysql' do
|
it 'returns compute slave db info hash when service found for default mysql' do
|
||||||
node.set['openstack']['endpoints']['db']['enabled_slave'] = true
|
node.set['openstack']['endpoints']['db']['enabled_slave'] = true
|
||||||
allow(subject).to receive(:node).and_return(chef_run.node)
|
allow(subject).to receive(:node).and_return(chef_run.node)
|
||||||
expected = 'mysql://user:pass@127.0.0.1:3316/nova?charset=utf8'
|
expected = 'mysql+pymysql://user:pass@127.0.0.1:3316/nova?charset=utf8'
|
||||||
expect(
|
expect(
|
||||||
subject.db_uri('compute', 'user', 'pass', true)
|
subject.db_uri('compute', 'user', 'pass', true)
|
||||||
).to eq(expected)
|
).to eq(expected)
|
||||||
|
@ -208,7 +208,7 @@ describe 'openstack-common::default' do
|
||||||
node.set['openstack']['db']['service_type'] = 'mariadb'
|
node.set['openstack']['db']['service_type'] = 'mariadb'
|
||||||
node.set['openstack']['endpoints']['db']['enabled_slave'] = true
|
node.set['openstack']['endpoints']['db']['enabled_slave'] = true
|
||||||
allow(subject).to receive(:node).and_return(chef_run.node)
|
allow(subject).to receive(:node).and_return(chef_run.node)
|
||||||
expected = 'mysql://user:pass@127.0.0.1:3316/glance?charset=utf8'
|
expected = 'mysql+pymysql://user:pass@127.0.0.1:3316/glance?charset=utf8'
|
||||||
expect(
|
expect(
|
||||||
subject.db_uri('image', 'user', 'pass', true)
|
subject.db_uri('image', 'user', 'pass', true)
|
||||||
).to eq(expected)
|
).to eq(expected)
|
||||||
|
@ -219,7 +219,7 @@ describe 'openstack-common::default' do
|
||||||
node.set['openstack']['db']['service_type'] = db
|
node.set['openstack']['db']['service_type'] = db
|
||||||
node.set['openstack']['endpoints']['db']['enabled_slave'] = true
|
node.set['openstack']['endpoints']['db']['enabled_slave'] = true
|
||||||
allow(subject).to receive(:node).and_return(chef_run.node)
|
allow(subject).to receive(:node).and_return(chef_run.node)
|
||||||
expected = 'mysql://user:pass@127.0.0.1:3316/neutron?charset=utf8'
|
expected = 'mysql+pymysql://user:pass@127.0.0.1:3316/neutron?charset=utf8'
|
||||||
expect(
|
expect(
|
||||||
subject.db_uri('network', 'user', 'pass', true)
|
subject.db_uri('network', 'user', 'pass', true)
|
||||||
).to eq(expected)
|
).to eq(expected)
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe 'openstack-common::logging' do
|
||||||
expect(chef_run).to create_directory('/etc/openstack').with(
|
expect(chef_run).to create_directory('/etc/openstack').with(
|
||||||
owner: 'root',
|
owner: 'root',
|
||||||
group: 'root',
|
group: 'root',
|
||||||
mode: 00755
|
mode: 0o0755
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -26,7 +26,7 @@ describe 'openstack-common::logging' do
|
||||||
expect(chef_run).to create_template(file.name).with(
|
expect(chef_run).to create_template(file.name).with(
|
||||||
owner: 'root',
|
owner: 'root',
|
||||||
group: 'root',
|
group: 'root',
|
||||||
mode: 00644
|
mode: 0o0644
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ describe 'openstack-common::default' do
|
||||||
'::1' => { 'family' => 'inet6', 'prefixlen' => '128', 'scope' => 'Node' },
|
'::1' => { 'family' => 'inet6', 'prefixlen' => '128', 'scope' => 'Node' },
|
||||||
'2001:db8::1' => { 'family' => 'inet6', 'prefixlen' => '64', 'scope' => 'Node' } } },
|
'2001:db8::1' => { 'family' => 'inet6', 'prefixlen' => '64', 'scope' => 'Node' } } },
|
||||||
'eth0' => { 'addresses' => { '10.0.0.2' => { 'family' => 'inet', 'prefixlen' => '32', 'netmask' => '255.255.255.255', 'scope' => 'Node' },
|
'eth0' => { 'addresses' => { '10.0.0.2' => { 'family' => 'inet', 'prefixlen' => '32', 'netmask' => '255.255.255.255', 'scope' => 'Node' },
|
||||||
'10.0.0.3' => { 'family' => 'inet', 'prefixlen' => '24', 'netmask' => '255.255.255.0', 'scope' => 'Node' }
|
'10.0.0.3' => { 'family' => 'inet', 'prefixlen' => '24', 'netmask' => '255.255.255.0', 'scope' => 'Node' } } }
|
||||||
} } }
|
}
|
||||||
|
|
||||||
runner.converge(described_recipe)
|
runner.converge(described_recipe)
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,8 @@ describe 'Openstack parse' do
|
||||||
).to eq(
|
).to eq(
|
||||||
[{ 'tenant' => 'service',
|
[{ 'tenant' => 'service',
|
||||||
'access' => '91af731b3be244beb8f30fc59b7bc96d',
|
'access' => '91af731b3be244beb8f30fc59b7bc96d',
|
||||||
'secret' => 'ce811442cfb549c39390a203778a4bf5' }])
|
'secret' => 'ce811442cfb549c39390a203778a4bf5' }]
|
||||||
|
)
|
||||||
end
|
end
|
||||||
it 'returns proper array of hashes when proper table provided including whitespace' do
|
it 'returns proper array of hashes when proper table provided including whitespace' do
|
||||||
table =
|
table =
|
||||||
|
@ -46,7 +47,8 @@ describe 'Openstack parse' do
|
||||||
).to eq(
|
).to eq(
|
||||||
[{ 'tenant' => 'service',
|
[{ 'tenant' => 'service',
|
||||||
'access' => '91af731b3be244beb8f30fc59b7bc96d',
|
'access' => '91af731b3be244beb8f30fc59b7bc96d',
|
||||||
'secret' => 'ce811442cfb549c39390a203778a4bf5' }])
|
'secret' => 'ce811442cfb549c39390a203778a4bf5' }]
|
||||||
|
)
|
||||||
end
|
end
|
||||||
it 'returns a flatten hash when provided a Property/Value table' do
|
it 'returns a flatten hash when provided a Property/Value table' do
|
||||||
table =
|
table =
|
||||||
|
@ -64,7 +66,8 @@ describe 'Openstack parse' do
|
||||||
[{ 'tenant_id' => '429271dd1cf54b7ca921a0017524d8ea',
|
[{ 'tenant_id' => '429271dd1cf54b7ca921a0017524d8ea',
|
||||||
'access' => '91af731b3be244beb8f30fc59b7bc96d',
|
'access' => '91af731b3be244beb8f30fc59b7bc96d',
|
||||||
'secret' => 'ce811442cfb549c39390a203778a4bf5',
|
'secret' => 'ce811442cfb549c39390a203778a4bf5',
|
||||||
'user_id' => '1c4fc229560f40689c490c5d0838fd84' }])
|
'user_id' => '1c4fc229560f40689c490c5d0838fd84' }]
|
||||||
|
)
|
||||||
end
|
end
|
||||||
it 'returns a flatten hash when provided a Property/Value table including whitespace' do
|
it 'returns a flatten hash when provided a Property/Value table including whitespace' do
|
||||||
table =
|
table =
|
||||||
|
@ -82,7 +85,8 @@ describe 'Openstack parse' do
|
||||||
[{ 'tenant_id' => '429271dd1cf54b7ca921a0017524d8ea',
|
[{ 'tenant_id' => '429271dd1cf54b7ca921a0017524d8ea',
|
||||||
'access' => '91af731b3be244beb8f30fc59b7bc96d',
|
'access' => '91af731b3be244beb8f30fc59b7bc96d',
|
||||||
'secret' => 'ce811442cfb549c39390a203778a4bf5',
|
'secret' => 'ce811442cfb549c39390a203778a4bf5',
|
||||||
'user_id' => '1c4fc229560f40689c490c5d0838fd84' }])
|
'user_id' => '1c4fc229560f40689c490c5d0838fd84' }]
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,9 +50,11 @@ describe 'openstack-common::default' do
|
||||||
it 'returns tokens from the secrets_data_bag' do
|
it 'returns tokens from the secrets_data_bag' do
|
||||||
bag_content = { 'nova' => 'mysecret' }
|
bag_content = { 'nova' => 'mysecret' }
|
||||||
allow(Chef::EncryptedDataBagItem).to receive(:load_secret).with(
|
allow(Chef::EncryptedDataBagItem).to receive(:load_secret).with(
|
||||||
'/etc/chef/openstack_data_bag_secret').and_return('secret')
|
'/etc/chef/openstack_data_bag_secret'
|
||||||
|
).and_return('secret')
|
||||||
allow(Chef::EncryptedDataBagItem).to receive(:load).with(
|
allow(Chef::EncryptedDataBagItem).to receive(:load).with(
|
||||||
'secrets', 'nova', 'secret').and_return(bag_content)
|
'secrets', 'nova', 'secret'
|
||||||
|
).and_return(bag_content)
|
||||||
expect(subject.get_password('token', 'nova')).to eq('mysecret')
|
expect(subject.get_password('token', 'nova')).to eq('mysecret')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -84,7 +86,8 @@ describe 'openstack-common::default' do
|
||||||
it 'returns tokens from the secrets_data_bag' do
|
it 'returns tokens from the secrets_data_bag' do
|
||||||
bag_content = { 'nova' => 'mysecret' }
|
bag_content = { 'nova' => 'mysecret' }
|
||||||
allow(Chef::DataBagItem).to receive(:load).with(
|
allow(Chef::DataBagItem).to receive(:load).with(
|
||||||
'secrets', 'nova').and_return(bag_content)
|
'secrets', 'nova'
|
||||||
|
).and_return(bag_content)
|
||||||
expect(subject.get_password('token', 'nova')).to eq('mysecret')
|
expect(subject.get_password('token', 'nova')).to eq('mysecret')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -110,7 +110,8 @@ describe 'openstack-common::default' do
|
||||||
allow(subject).to receive(:search_for)
|
allow(subject).to receive(:search_for)
|
||||||
.and_return(nodes)
|
.and_return(nodes)
|
||||||
expect(
|
expect(
|
||||||
subject.rabbit_servers).to eq('1.1.1.1:5672,2.2.2.2:5672')
|
subject.rabbit_servers
|
||||||
|
).to eq('1.1.1.1:5672,2.2.2.2:5672')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns sorted rabbit servers' do
|
it 'returns sorted rabbit servers' do
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe 'openstack-common::sysctl' do
|
||||||
expect(chef_run).to create_template('/etc/sysctl.d/60-openstack.conf').with(
|
expect(chef_run).to create_template('/etc/sysctl.d/60-openstack.conf').with(
|
||||||
owner: 'root',
|
owner: 'root',
|
||||||
group: 'root',
|
group: 'root',
|
||||||
mode: 0644
|
mode: 0o644
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue