From 479af11fd7fb06790ab1a246d8f027b18a647cf2 Mon Sep 17 00:00:00 2001 From: Samuel Cassiba Date: Wed, 2 Aug 2017 01:01:23 -0400 Subject: [PATCH] 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 --- .rubocop_todo.yml | 23 +++++------------ Gemfile | 15 ----------- attributes/database.rb | 12 ++++++++- attributes/default.rb | 2 +- bootstrap.sh | 10 +++----- libraries/endpoints.rb | 4 +-- libraries/parse.rb | 21 ++++++++------- metadata.rb | 18 +++++++------ providers/database.rb | 4 ++- recipes/logging.rb | 4 +-- recipes/sysctl.rb | 4 +-- spec/database_provider_spec.rb | 47 +++------------------------------- spec/default_spec.rb | 8 +++--- spec/endpoints_spec.rb | 12 ++++----- spec/logging_spec.rb | 4 +-- spec/network_spec.rb | 4 +-- spec/parse_spec.rb | 12 ++++++--- spec/password_spec.rb | 9 ++++--- spec/search_spec.rb | 3 ++- spec/sysctl_spec.rb | 2 +- 20 files changed, 86 insertions(+), 132 deletions(-) delete mode 100644 Gemfile diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2acc9598..6c97681e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `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 # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -15,6 +15,11 @@ Lint/NestedMethodDefinition: Metrics/AbcSize: Max: 39 +# Offense count: 45 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/BlockLength: + Max: 203 + # Offense count: 1 Metrics/PerceivedComplexity: Max: 13 @@ -33,19 +38,3 @@ Style/ClassAndModuleChildren: - 'libraries/search.rb' - 'libraries/uri.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' diff --git a/Gemfile b/Gemfile deleted file mode 100644 index f865dacb..00000000 --- a/Gemfile +++ /dev/null @@ -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' diff --git a/attributes/database.rb b/attributes/database.rb index b985a0d9..f4608e6d 100644 --- a/attributes/database.rb +++ b/attributes/database.rb @@ -88,7 +88,7 @@ default['openstack']['endpoints']['db']['slave_port'] = '3316' # 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. # 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['openstack']['db']['server_role'] = 'os-ops-database' @@ -135,6 +135,14 @@ when 'debian' default['openstack']['db']['python_packages']['galera'] = ['python-mysqldb'] 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 node['openstack']['common']['services'].each do |service, project| 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_port'] = node['openstack']['endpoints']['db']['slave_port'] + default['openstack']['db'][service]['socket'] = node['openstack']['db']['socket'] + case service when 'dashboard' default['openstack']['db'][service]['migrate'] = true diff --git a/attributes/default.rb b/attributes/default.rb index a7cda062..4f21129a 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -72,7 +72,7 @@ default['openstack']['use_databags'] = true # feature of the official chef project, you can use 'vault' to # encrypt your secrets with the method provided in the chef-vault gem. 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) node['openstack']['common']['services'].each_key do |service| diff --git a/bootstrap.sh b/bootstrap.sh index 5004aef6..0c90c8b1 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -11,7 +11,7 @@ if [ -f /usr/bin/yum ] ; then sudo pip uninstall requests -y || true # 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 sudo yum -y install $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 # install chefdk - chefdk=chefdk_1.0.3-1_amd64.deb - wget -nv -t 3 https://packages.chef.io/stable/ubuntu/12.04/$chefdk + chefdk=chefdk_1.5.0-1_amd64.deb + wget -nv -t 3 https://packages.chef.io/stable/ubuntu/16.04/$chefdk sudo dpkg -i $chefdk rm $chefdk @@ -46,10 +46,6 @@ if [ -f /etc/nodepool/provider ]; then CENTOS_MIRROR_HOST=${NODEPOOL_MIRROR_HOST} UCA_MIRROR_HOST="${NODEPOOL_MIRROR_HOST}/ubuntu-cloud-archive" 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 CENTOS_MIRROR_HOST='mirror.centos.org' UCA_MIRROR_HOST='ubuntu-cloud.archive.canonical.com/ubuntu' diff --git a/libraries/endpoints.rb b/libraries/endpoints.rb index 0edff837..036591f6 100644 --- a/libraries/endpoints.rb +++ b/libraries/endpoints.rb @@ -76,8 +76,8 @@ module ::Openstack # Build uri case type - when 'mysql', 'postgresql' - "#{type}://#{user}:#{pass}@#{host}:#{port}/#{name}#{options}" + when 'mysql' + "mysql+pymysql://#{user}:#{pass}@#{host}:#{port}/#{name}#{options}" when 'sqlite' # SQLite uses filepaths not db name # README(galstrom): 3 slashes is a relative path, 4 slashes is an absolute path diff --git a/libraries/parse.rb b/libraries/parse.rb index 9ec3ef2e..ddbacabb 100644 --- a/libraries/parse.rb +++ b/libraries/parse.rb @@ -31,18 +31,17 @@ module ::Openstack ret = [] return ret if table.nil? indicies = [] - (table.split(/$/).map { |x| x.strip }).each do |line| - unless line.start_with?('+--') || line.empty? - cols = line.split('|').map { |x| x.strip } - cols.shift - if indicies == [] - indicies = cols - next - end - newobj = {} - cols.each { |val| newobj[indicies[newobj.length]] = val } - ret.push(newobj) + table.split(/$/).map(&:strip).each do |line| + next if line.start_with?('+--') || line.empty? + cols = line.split('|').map(&:strip) + cols.shift + if indicies == [] + indicies = cols + next end + newobj = {} + cols.each { |val| newobj[indicies[newobj.length]] = val } + ret.push(newobj) end # this kinda sucks, but some prettytable data comes diff --git a/metadata.rb b/metadata.rb index 407469dd..9d898cbb 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,12 +1,10 @@ -name 'openstack-common' -maintainer 'openstack-chef' +name 'openstack-common' +maintainer 'openstack-chef' maintainer_email 'openstack-dev@lists.openstack.org' -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) -license 'Apache 2.0' -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')) -version '15.0.0' +version '15.0.0' recipe 'openstack-common', 'Installs/Configures common recipes' recipe 'openstack-common::logging', 'Installs/Configures common logging' @@ -18,8 +16,12 @@ end depends 'apt', '~> 5.0' depends 'database', '~> 6.1' -depends 'mariadb', '~> 0.3.3' +depends 'mariadb', '~> 1.5' depends 'mysql', '~> 8.2' depends 'yum', '~> 3.13' depends 'yum-epel', '~> 2.0' 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) diff --git a/providers/database.rb b/providers/database.rb index 179226d1..db3a2547 100644 --- a/providers/database.rb +++ b/providers/database.rb @@ -27,6 +27,7 @@ def info @port = service_info['port'] || info['port'] user_key = node['openstack']['db']['root_user_key'] @super_password = get_password 'db', user_key + @socket = node['openstack']['db']['socket'] @db_type = service_info['service_type'] @db_name = service_info['db_name'] @user = new_resource.user @@ -55,7 +56,8 @@ def connection_info host: @host, port: @port.to_i, username: @super_user, - password: @super_password + password: @super_password, + socket: @socket } end diff --git a/recipes/logging.rb b/recipes/logging.rb index 68b76186..92059832 100644 --- a/recipes/logging.rb +++ b/recipes/logging.rb @@ -21,7 +21,7 @@ directory '/etc/openstack' do owner 'root' group 'root' - mode 00755 + mode 0o0755 action :create end @@ -29,7 +29,7 @@ template '/etc/openstack/logging.conf' do source 'logging.conf.erb' owner 'root' group 'root' - mode 00644 + mode 0o0644 variables( loggers: node['openstack']['logging']['loggers'], formatters: node['openstack']['logging']['formatters'], diff --git a/recipes/sysctl.rb b/recipes/sysctl.rb index 5035f2e3..c850c0a7 100644 --- a/recipes/sysctl.rb +++ b/recipes/sysctl.rb @@ -21,14 +21,14 @@ directory '/etc/sysctl.d' do owner 'root' group 'root' - mode 00755 + mode 0o0755 end template '/etc/sysctl.d/60-openstack.conf' do source '60-openstack.conf.erb' owner 'root' group 'root' - mode 00644 + mode 0o0644 end execute 'sysctl -p /etc/sysctl.d/60-openstack.conf' do diff --git a/spec/database_provider_spec.rb b/spec/database_provider_spec.rb index ada8e7ef..4a575aaa 100644 --- a/spec/database_provider_spec.rb +++ b/spec/database_provider_spec.rb @@ -30,7 +30,7 @@ describe 'test-openstack-common-database::default' do expect(chef_run).to create_database('create database service_db') .with( 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', encoding: 'utf8' ) @@ -41,7 +41,7 @@ describe 'test-openstack-common-database::default' do expect(chef_run).to create_database('create database service_db') .with( 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', 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') .with( 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', 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') .with( 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', password: 'db_pass', database_name: 'service_db', @@ -70,45 +70,6 @@ describe 'test-openstack-common-database::default' do ) 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 before do node.override['openstack']['db']['service'] = { service_type: 'galera', port: 3306, db_name: 'service_db' } diff --git a/spec/default_spec.rb b/spec/default_spec.rb index 281ca25b..eb93d566 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -30,7 +30,8 @@ describe 'openstack-common::default' do expect(chef_run).to add_apt_repository('openstack-ppa').with( uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu', distribution: 'xenial-updates/ocata', - components: ['main']) + components: ['main'] + ) end 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( uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu', distribution: 'xenial-updates/ocata', - components: ['main']) + components: ['main'] + ) end 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 node.set['openstack']['databag_type'] = 'vault' expect(chef_run).to install_chef_gem('chef-vault') - .with(version: '~> 2.3') + .with(version: '~> 3.2') end context 'rabbit mq' do diff --git a/spec/endpoints_spec.rb b/spec/endpoints_spec.rb index d683391d..31be685b 100644 --- a/spec/endpoints_spec.rb +++ b/spec/endpoints_spec.rb @@ -158,7 +158,7 @@ describe 'openstack-common::default' do it 'returns compute db info hash when service found for default mysql' do 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( subject.db_uri('compute', 'user', 'pass') ).to eq(expected) @@ -178,7 +178,7 @@ describe 'openstack-common::default' do it 'returns compute db info hash when service found for mariadb' do node.set['openstack']['db']['service_type'] = 'mariadb' 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( subject.db_uri('compute', 'user', 'pass') ).to eq(expected) @@ -188,7 +188,7 @@ describe 'openstack-common::default' do it "returns compute db info hash when service found for #{db}" do node.set['openstack']['db']['service_type'] = db 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( subject.db_uri('compute', 'user', 'pass') ).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 node.set['openstack']['endpoints']['db']['enabled_slave'] = true 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( subject.db_uri('compute', 'user', 'pass', true) ).to eq(expected) @@ -208,7 +208,7 @@ describe 'openstack-common::default' do node.set['openstack']['db']['service_type'] = 'mariadb' node.set['openstack']['endpoints']['db']['enabled_slave'] = true 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( subject.db_uri('image', 'user', 'pass', true) ).to eq(expected) @@ -219,7 +219,7 @@ describe 'openstack-common::default' do node.set['openstack']['db']['service_type'] = db node.set['openstack']['endpoints']['db']['enabled_slave'] = true 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( subject.db_uri('network', 'user', 'pass', true) ).to eq(expected) diff --git a/spec/logging_spec.rb b/spec/logging_spec.rb index 0da468f1..84769bcd 100644 --- a/spec/logging_spec.rb +++ b/spec/logging_spec.rb @@ -14,7 +14,7 @@ describe 'openstack-common::logging' do expect(chef_run).to create_directory('/etc/openstack').with( owner: 'root', group: 'root', - mode: 00755 + mode: 0o0755 ) end end @@ -26,7 +26,7 @@ describe 'openstack-common::logging' do expect(chef_run).to create_template(file.name).with( owner: 'root', group: 'root', - mode: 00644 + mode: 0o0644 ) end diff --git a/spec/network_spec.rb b/spec/network_spec.rb index 73d10475..8fea983d 100644 --- a/spec/network_spec.rb +++ b/spec/network_spec.rb @@ -12,8 +12,8 @@ describe 'openstack-common::default' do '::1' => { 'family' => 'inet6', 'prefixlen' => '128', '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' }, - '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) end diff --git a/spec/parse_spec.rb b/spec/parse_spec.rb index 76d7a2ee..05f3b370 100644 --- a/spec/parse_spec.rb +++ b/spec/parse_spec.rb @@ -29,7 +29,8 @@ describe 'Openstack parse' do ).to eq( [{ 'tenant' => 'service', 'access' => '91af731b3be244beb8f30fc59b7bc96d', - 'secret' => 'ce811442cfb549c39390a203778a4bf5' }]) + 'secret' => 'ce811442cfb549c39390a203778a4bf5' }] + ) end it 'returns proper array of hashes when proper table provided including whitespace' do table = @@ -46,7 +47,8 @@ describe 'Openstack parse' do ).to eq( [{ 'tenant' => 'service', 'access' => '91af731b3be244beb8f30fc59b7bc96d', - 'secret' => 'ce811442cfb549c39390a203778a4bf5' }]) + 'secret' => 'ce811442cfb549c39390a203778a4bf5' }] + ) end it 'returns a flatten hash when provided a Property/Value table' do table = @@ -64,7 +66,8 @@ describe 'Openstack parse' do [{ 'tenant_id' => '429271dd1cf54b7ca921a0017524d8ea', 'access' => '91af731b3be244beb8f30fc59b7bc96d', 'secret' => 'ce811442cfb549c39390a203778a4bf5', - 'user_id' => '1c4fc229560f40689c490c5d0838fd84' }]) + 'user_id' => '1c4fc229560f40689c490c5d0838fd84' }] + ) end it 'returns a flatten hash when provided a Property/Value table including whitespace' do table = @@ -82,7 +85,8 @@ describe 'Openstack parse' do [{ 'tenant_id' => '429271dd1cf54b7ca921a0017524d8ea', 'access' => '91af731b3be244beb8f30fc59b7bc96d', 'secret' => 'ce811442cfb549c39390a203778a4bf5', - 'user_id' => '1c4fc229560f40689c490c5d0838fd84' }]) + 'user_id' => '1c4fc229560f40689c490c5d0838fd84' }] + ) end end end diff --git a/spec/password_spec.rb b/spec/password_spec.rb index f605365c..2f6ba4a0 100644 --- a/spec/password_spec.rb +++ b/spec/password_spec.rb @@ -50,9 +50,11 @@ describe 'openstack-common::default' do it 'returns tokens from the secrets_data_bag' do bag_content = { 'nova' => 'mysecret' } 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( - 'secrets', 'nova', 'secret').and_return(bag_content) + 'secrets', 'nova', 'secret' + ).and_return(bag_content) expect(subject.get_password('token', 'nova')).to eq('mysecret') end end @@ -84,7 +86,8 @@ describe 'openstack-common::default' do it 'returns tokens from the secrets_data_bag' do bag_content = { 'nova' => 'mysecret' } 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') end end diff --git a/spec/search_spec.rb b/spec/search_spec.rb index 0febc2fb..cb28c0d7 100644 --- a/spec/search_spec.rb +++ b/spec/search_spec.rb @@ -110,7 +110,8 @@ describe 'openstack-common::default' do allow(subject).to receive(:search_for) .and_return(nodes) 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 it 'returns sorted rabbit servers' do diff --git a/spec/sysctl_spec.rb b/spec/sysctl_spec.rb index b584c287..ea3aa8e9 100644 --- a/spec/sysctl_spec.rb +++ b/spec/sysctl_spec.rb @@ -20,7 +20,7 @@ describe 'openstack-common::sysctl' do expect(chef_run).to create_template('/etc/sysctl.d/60-openstack.conf').with( owner: 'root', group: 'root', - mode: 0644 + mode: 0o644 ) end