diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..3ffe2b0 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,2 @@ +inherit_from: .rubocop_todo.yml + diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..46e0dfe --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,11 @@ +# This configuration was generated by `rubocop --auto-gen-config` +# on 2015-03-31 23:40:42 -0400 using RuboCop version 0.28.0. +# 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 +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 18 +# Configuration parameters: AllowURI, URISchemes. +Metrics/LineLength: + Max: 117 diff --git a/Thorfile b/Thorfile index b23ee16..19aaaf2 100644 --- a/Thorfile +++ b/Thorfile @@ -8,5 +8,5 @@ begin require 'kitchen/thor_tasks' Kitchen::ThorTasks.new rescue LoadError - puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI'] + puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI'] end diff --git a/Vagrantfile b/Vagrantfile index b6001be..6fbe327 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,47 +1,47 @@ BOXES = [ { - hostname: 'teamcity', - ip: '192.168.80.10', - ports: [8111, 5432], - role: 'server', - ram: 2048, - cpus: 2, - chef: { - json: { - 'teamcity' => { - 'password' => '$1$ByY03mDX$4pk9wp9bC19yB6pxSoVB81', - 'server' => { - 'backup' => 'file:///vagrant/tmp/TeamCity_Backup_20141216_154715.zip', - 'database' => { - 'username' => 'postgres', - 'password' => '3175bce1d3201d16594cebf9d7eb3f9d', - 'jar' => 'file:///usr/share/java/postgresql93-jdbc.jar', - 'connection_url' => 'jdbc\:postgresql\:///postgres' + hostname: 'teamcity', + ip: '192.168.80.10', + ports: [8111, 5432], + role: 'server', + ram: 2048, + cpus: 2, + chef: { + json: { + 'teamcity' => { + 'password' => '$1$ByY03mDX$4pk9wp9bC19yB6pxSoVB81', + 'server' => { + 'backup' => 'file:///vagrant/tmp/TeamCity_Backup_20141216_154715.zip', + 'database' => { + 'username' => 'postgres', + 'password' => '3175bce1d3201d16594cebf9d7eb3f9d', + 'jar' => 'file:///usr/share/java/postgresql93-jdbc.jar', + 'connection_url' => 'jdbc\:postgresql\:///postgres' + } + } + }, + 'postgresql' => { + 'version' => '9.3', + 'enable_pgdg_yum' => true, + 'password' => { + 'postgres' => '3175bce1d3201d16594cebf9d7eb3f9d' + }, + 'contrib' => { + 'packages' => ['postgresql93-jdbc'] + } + }, + 'java' => { + 'install_flavor' => 'oracle', + 'jdk_version' => 7, + 'set_etc_environment' => true, + 'oracle' => { + 'accept_oracle_download_terms' => true + } } - } - }, - 'postgresql' => { - 'version' => '9.3', - 'enable_pgdg_yum' => true, - 'password' => { - 'postgres' => '3175bce1d3201d16594cebf9d7eb3f9d' }, - 'contrib' => { - 'packages' => ['postgresql93-jdbc'] - } - }, - 'java' => { - 'install_flavor' => 'oracle', - 'jdk_version' => 7, - 'set_etc_environment' => true, - 'oracle' => { - 'accept_oracle_download_terms' => true - } + run_list: %w(recipe[java] recipe[postgresql::contrib] recipe[chef-teamcity::server]) } }, - run_list: %w(recipe[java] recipe[postgresql::contrib] recipe[chef-teamcity::server]) -} -}, { hostname: 'agent01', ip: '192.168.80.11', @@ -85,9 +85,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| node_config.vm.network :private_network, ip: node[:ip] - node[:ports].each { |port| + node[:ports].each do |port| node_config.vm.network :forwarded_port, guest: port, host: port - } + end node_config.vm.provider :virtualbox do |box| box.customize ['modifyvm', :id, '--name', node[:hostname]] diff --git a/metadata.rb b/metadata.rb index ef4fff2..eafb0f1 100644 --- a/metadata.rb +++ b/metadata.rb @@ -8,9 +8,9 @@ recipe 'chef-teamcity::server', 'Install a TeamCity server' recipe 'chef-teamcity::agent', 'Installs a TeamCity agent' -supports "redhat", '~> 6.0' -supports "centos", '~> 6.0' -supports "windows" +supports 'redhat', '~> 6.0' +supports 'centos', '~> 6.0' +supports 'windows' depends 'java' depends 'git' diff --git a/recipes/linux_agent.rb b/recipes/linux_agent.rb index 7ef3cf9..332a1a2 100644 --- a/recipes/linux_agent.rb +++ b/recipes/linux_agent.rb @@ -51,7 +51,7 @@ owner TEAMCITY_USERNAME group TEAMCITY_GROUP mode TEAMCITY_READ_MODE - not_if { ::File.exists?(TEAMCITY_PATH) } + not_if { ::File.exist?(TEAMCITY_PATH) } end bash 'extract_teamcity' do @@ -61,7 +61,7 @@ chown -R #{TEAMCITY_USERNAME}.#{TEAMCITY_GROUP} #{TEAMCITY_PATH} rm -f #{TEAMCITY_SRC_PATH} EOH - not_if { ::File.exists?(TEAMCITY_PATH) } + not_if { ::File.exist?(TEAMCITY_PATH) } end file TEAMCITY_AGENT_EXECUTABLE do @@ -84,7 +84,7 @@ mode TEAMCITY_READ_MODE owner TEAMCITY_USERNAME group TEAMCITY_GROUP - variables({ + variables( server_uri: TEAMCITY_AGENT_SERVER_URI, name: TEAMCITY_AGENT_NAME, work_dir: TEAMCITY_AGENT_WORK_DIR, @@ -95,8 +95,8 @@ authorization_token: TEAMCITY_AGENT_AUTH_TOKEN, system_properties: TEAMCITY_AGENT_SYSTEM_PROPERTIES, env_properties: TEAMCITY_AGENT_ENV_PROPERTIES - }) - not_if { ::File.exists?(TEAMCITY_AGENT_PROPERTIES) } + ) + not_if { ::File.exist?(TEAMCITY_AGENT_PROPERTIES) } notifies :restart, "service[#{TEAMCITY_SERVICE_NAME}]", :delayed end @@ -105,12 +105,12 @@ mode TEAMCITY_EXECUTABLE_MODE owner 'root' group 'root' - variables({ + variables( teamcity_user_name: TEAMCITY_USERNAME, teamcity_executable: TEAMCITY_AGENT_EXECUTABLE, teamcity_pidfile: TEAMCITY_PID_FILE, teamcity_service_name: TEAMCITY_SERVICE_NAME - }) + ) notifies :restart, "service[#{TEAMCITY_SERVICE_NAME}]", :delayed end diff --git a/recipes/server.rb b/recipes/server.rb index 00c9dad..1cd84c2 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -60,7 +60,7 @@ mv #{TEAMCITY_PATH}/*/* #{TEAMCITY_PATH}/ chown -R #{TEAMCITY_USERNAME}.#{TEAMCITY_GROUP} #{TEAMCITY_PATH} EOH - not_if { ::File.exists?(TEAMCITY_PATH) } + not_if { ::File.exist?(TEAMCITY_PATH) } end paths = [ @@ -99,7 +99,7 @@ owner TEAMCITY_USERNAME group TEAMCITY_GROUP mode TEAMCITY_READ_MODE - not_if { ::File.exists?(processed_backup_path) } + not_if { ::File.exist?(processed_backup_path) } end template home_database_props do @@ -107,11 +107,11 @@ mode TEAMCITY_READ_MODE owner TEAMCITY_USERNAME group TEAMCITY_GROUP - variables({ + variables( url: TEAMCITY_DB_CONNECTION_URL, username: TEAMCITY_DB_USERNAME, - password: TEAMCITY_DB_PASSWORD, - }) + password: TEAMCITY_DB_PASSWORD + ) end bash 'restore' do @@ -122,7 +122,7 @@ rm -f #{backup_path} touch #{processed_backup_path} EOH - not_if { ::File.exists?(processed_backup_path) } + not_if { ::File.exist?(processed_backup_path) } end end @@ -131,11 +131,11 @@ mode TEAMCITY_READ_MODE owner TEAMCITY_USERNAME group TEAMCITY_GROUP - variables({ + variables( url: TEAMCITY_DB_CONNECTION_URL, username: TEAMCITY_DB_USERNAME, - password: TEAMCITY_DB_PASSWORD, - }) + password: TEAMCITY_DB_PASSWORD + ) notifies :restart, "service[#{TEAMCITY_SERVICE_NAME}]", :delayed end @@ -144,13 +144,13 @@ mode TEAMCITY_EXECUTABLE_MODE owner 'root' group 'root' - variables({ + variables( teamcity_user_name: TEAMCITY_USERNAME, teamcity_server_executable: TEAMCITY_SERVER_EXECUTABLE, teamcity_data_path: TEAMCITY_DATA_PATH, teamcity_pidfile: TEAMCITY_PID_FILE, teamcity_service_name: TEAMCITY_SERVICE_NAME - }) + ) notifies :restart, "service[#{TEAMCITY_SERVICE_NAME}]", :delayed end diff --git a/recipes/windows_agent.rb b/recipes/windows_agent.rb index c985f28..8cfec19 100644 --- a/recipes/windows_agent.rb +++ b/recipes/windows_agent.rb @@ -16,7 +16,7 @@ # TEAMCITY_VERSION = node['teamcity']['version'].freeze -TEAMCITY_SERVICE_NAME = "TCBuildAgent".freeze +TEAMCITY_SERVICE_NAME = 'TCBuildAgent'.freeze TEAMCITY_AGENT_NAME = node['teamcity']['agent']['name'].freeze TEAMCITY_AGENT_SERVER_URI = node['teamcity']['agent']['server_uri'].freeze @@ -33,31 +33,31 @@ TEAMCITY_AGENT_SRC_PATH = ::File.join(TEAMCITY_AGENT_SYSTEM_DIR, TEAMCITY_AGENT_FILE).freeze TEAMCITY_AGENT_CONFIG_PATH = "#{TEAMCITY_AGENT_SYSTEM_DIR}/conf".freeze TEAMCITY_AGENT_PROPERTIES = "#{TEAMCITY_AGENT_CONFIG_PATH}/buildAgent.properties".freeze -TEAMCITY_AGENT_BIN_PATH = ::File.join(TEAMCITY_AGENT_SYSTEM_DIR, "bin") +TEAMCITY_AGENT_BIN_PATH = ::File.join(TEAMCITY_AGENT_SYSTEM_DIR, 'bin') TEAMCITY_SRC_PATH = "#{TEAMCITY_AGENT_SYSTEM_DIR}.zip".freeze TEAMCITY_PID_FILE = "#{TEAMCITY_AGENT_SYSTEM_DIR}\\logs\\buildAgent.pid".freeze remote_file TEAMCITY_SRC_PATH do source TEAMCITY_AGENT_URI - not_if { ::File.exists?(TEAMCITY_AGENT_CONFIG_PATH) } + not_if { ::File.exist?(TEAMCITY_AGENT_CONFIG_PATH) } end directory TEAMCITY_AGENT_SYSTEM_DIR do action :create recursive true - not_if { ::File.exists?(TEAMCITY_AGENT_CONFIG_PATH) } + not_if { ::File.exist?(TEAMCITY_AGENT_CONFIG_PATH) } end windows_zipfile TEAMCITY_AGENT_SYSTEM_DIR do source TEAMCITY_SRC_PATH action :unzip - not_if { ::File.exists?(TEAMCITY_AGENT_BIN_PATH) } + not_if { ::File.exist?(TEAMCITY_AGENT_BIN_PATH) } end template TEAMCITY_AGENT_PROPERTIES do source 'buildAgent.properties.erb' - variables({ + variables( server_uri: TEAMCITY_AGENT_SERVER_URI, name: TEAMCITY_AGENT_NAME, work_dir: TEAMCITY_AGENT_WORK_DIR, @@ -68,8 +68,8 @@ authorization_token: TEAMCITY_AGENT_AUTH_TOKEN, system_properties: TEAMCITY_AGENT_SYSTEM_PROPERTIES, env_properties: TEAMCITY_AGENT_ENV_PROPERTIES - }) - not_if { ::File.exists?(TEAMCITY_AGENT_PROPERTIES) } + ) + not_if { ::File.exist?(TEAMCITY_AGENT_PROPERTIES) } notifies :restart, "service[#{TEAMCITY_SERVICE_NAME}]", :delayed end @@ -77,7 +77,7 @@ command "#{TEAMCITY_AGENT_BIN_PATH}/service.install.bat" action :run cwd "#{TEAMCITY_AGENT_SYSTEM_DIR}/bin" - not_if { ::Win32::Service.exists?("TCBuildAgent") } + not_if { ::Win32::Service.exists?('TCBuildAgent') } end service TEAMCITY_SERVICE_NAME do