diff --git a/.kitchen.travis.yml b/.kitchen.travis.yml new file mode 100644 index 0000000..15fe7dd --- /dev/null +++ b/.kitchen.travis.yml @@ -0,0 +1,14 @@ +driver: + name: digitalocean + private_networking: false + size: 1gb + +provisioner: + client_rb: + formatters: + # Travis CI will cancel job if logs get over 4MB. + - :minimal + attributes: + stash: + jvm: + maximum_memory: 1024m diff --git a/.kitchen.yml b/.kitchen.yml index f803cb6..822f046 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,42 +1,55 @@ --- driver: name: vagrant - require_chef_omnibus: 11.16.2 + require_chef_omnibus: 11.18.12 driver_config: customize: memory: 1024 +provisioner: + name: chef_zero + attributes: + apt: + # Some other cookbook's compile_time nonsense requires this... :/ + compile_time_update: true + java: + install_flavor: oracle + java_home: /usr/lib/jvm/java-7-oracle + jdk_version: 7 + oracle: + accept_oracle_download_terms: true + platforms: + - name: centos-6 driver_config: - box: chef/centos-6.6 + box: chef/centos-6.6 # vagrant + image: centos-6-5-x64 # digitalocean run_list: - recipe[yum] + - name: centos-7 driver_config: box: chef/centos-7.0 + image: centos-7-0-x64 run_list: - recipe[yum] + - name: ubuntu-12.04 driver_config: box: chef/ubuntu-12.04 + image: ubuntu-12-04-x64 run_list: - recipe[apt] + - name: ubuntu-14.04 driver_config: box: chef/ubuntu-14.04 + image: ubuntu-14-04-x64 run_list: - recipe[apt] -default_attributes: &DEFAULT_ATTRIBUTES - java: - install_flavor: oracle - java_home: /usr/lib/jvm/java-7-oracle - jdk_version: 7 - oracle: - accept_oracle_download_terms: true - suites: - name: mysql # default run_list: @@ -44,18 +57,16 @@ suites: - recipe[java] - recipe[stash] attributes: - <<: *DEFAULT_ATTRIBUTES - mysql: - server_root_password: iloverandompasswordsbutthiswilldo - server_repl_password: iloverandompasswordsbutthiswilldo - server_debian_password: iloverandompasswordsbutthiswilldo + stash: + database: + password: iloverandompasswordsbutthiswilldo + - name: postgresql run_list: - recipe[test-helper] - recipe[java] - recipe[stash] attributes: - <<: *DEFAULT_ATTRIBUTES stash: database: type: postgresql diff --git a/.travis.yml b/.travis.yml index 7044d71..ac9cae8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,41 @@ language: ruby -bundler_args: --without integration + cache: bundler -sudo: false + rvm: - - 2.0.0 +- 2.0.0 + +env: + global: + # Uses public key of private keypair set up in `before_install` task. + # Hint: Inspect SSH key edit buttons in DigitalOcean web interface for IDs. + - DIGITALOCEAN_SSH_KEY_IDS="970381" + # DIGITALOCEAN_ACCESS_TOKEN + - secure: "LYbpXAi9+TuzF4kuMiJTXKbgqnPGkokdX0dm+REduODCzORbPlmcfhdJNSpbYOE+PAM9uqjtAlHiuZQ5dvHdP7HgELcFFOhFEvjCWGypxBBMCNbBp6BCMX2wkUPgATqdkyEMsznCQEDbtK61OuJAMT082X7DQVo1qwWnsEmx8cAsIy9hw1c6yXGMDM8nv3ymSwu9FyQ6Vje8d0ZzLy06OkRs8T60LekzZBBus5wESRf0E8wy4I51qLZbndkCgLA/WyAKpK5rczJP3Ve5DNbMBJHyyYILYN7vKyb0JlOdI97juqa6bJYcsBA2EmpYISfWEzTW4hd5hPModqzjHxHPGada4y7rE7w6FEAXO4N/flxJe/tFe2/fHs8sLO3b8awh3YWVJ0FMP/gl8biXAc42DSiF9flMRc9eM0bqDqijOmK+LLL3FoIP7nRnvF2evcZ6bdLkNH9MnkomCliAovPfaDfD4UQXkRN5Nl5HwcIhCvve3j6Uq7o633r409R6Qc5k1ri63FIya/Iyddo4jHYperSv6/ISgwdfGGeRBpP7cZJ/ZA+tCRdQFjELwjG91Pen4im59qjc2IkVV+XrKhde7Hpl4PgiRDeWW230v8obS4Y31iL/usMm1c1UIgW2azrS7TaFdMJBmLOaO68eRJpyyqz5pGZ5tSgWMNaogD/Am5M=" + +before_install: + # Decrypt pre-generated private key + # See: http://docs.travis-ci.com/user/encrypting-files/ +- openssl aes-256-cbc -K $encrypted_370ffe2e34a2_key -iv $encrypted_370ffe2e34a2_iv -in test/support/travis_id_rsa.key.enc -out ~/.ssh/id_rsa -d +- chmod 600 ~/.ssh/id_rsa + # Re-generate public key from private +- ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub + before_script: - - bundle exec berks install +- cp .kitchen.travis.yml .kitchen.local.yml + script: - - bundle exec rake travis +- bundle exec rake style:ruby +- bundle exec rake style:chef +- '[ "${TRAVIS_SECURE_ENV_VARS}" = "true" ] && bundle exec kitchen test --parallel' + +after_script: +- bundle exec kitchen list +- bundle exec kitchen destroy + +branches: + only: + - feature/108-test-kitchen-cloud + +notifications: + email: false diff --git a/Gemfile b/Gemfile index 7c7cc5a..c0b866b 100644 --- a/Gemfile +++ b/Gemfile @@ -13,6 +13,7 @@ group :test do end group :integration do + gem 'kitchen-digitalocean' gem 'busser-serverspec', '~> 0.2.6' gem 'kitchen-vagrant', '~> 0.15' gem 'test-kitchen', '~> 1.3' diff --git a/README.md b/README.md index df19d68..349d7a3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# chef-stash [![Build Status](https://secure.travis-ci.org/bflad/chef-stash.png?branch=master)](http://travis-ci.org/bflad/chef-stash) +# chef-stash [![Build Status](https://secure.travis-ci.org/patcon/chef-stash.png?branch=feature/108-test-kitchen-cloud)](http://travis-ci.org/patcon/chef-stash) ##![](https://assets-cdn.github.com/images/icons/emoji/unicode/2757.png) We are preparing for 4.0.0 release which makes the git repo not stable for now. Please use cookbook from [Supermarket](https://supermarket.chef.io/cookbooks/stash/) for the time being. diff --git a/attributes/default.rb b/attributes/default.rb index d727bc5..096419c 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,5 +1,3 @@ -set['build_essential']['compiletime'] = true - default['stash']['home_path'] = '/var/atlassian/application-data/stash' default['stash']['install_path'] = '/opt/atlassian' default['stash']['install_type'] = 'standalone' diff --git a/metadata.rb b/metadata.rb index 4d3dfc0..86f1847 100644 --- a/metadata.rb +++ b/metadata.rb @@ -23,6 +23,7 @@ depends 'apache2' depends 'ark' +depends 'chef-sugar', '> 1.3.0' depends 'cron' depends 'database' depends 'git' diff --git a/recipes/database.rb b/recipes/database.rb index d23cb73..90a1d61 100644 --- a/recipes/database.rb +++ b/recipes/database.rb @@ -17,12 +17,11 @@ bind_address settings['database']['host'] # See: https://github.com/chef-cookbooks/mysql/pull/361 port settings['database']['port'].to_s - data_dir node['mysql']['data_dir'] if node['mysql']['data_dir'] - initial_root_password node['mysql']['server_root_password'] + initial_root_password settings['database']['password'] action [:create, :start] end - database_connection.merge!(:username => 'root', :password => node['mysql']['server_root_password']) + database_connection.merge!(:username => 'root', :password => settings['database']['password']) mysql_database settings['database']['name'] do connection database_connection diff --git a/recipes/default.rb b/recipes/default.rb index 87a439b..dc405a5 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -9,6 +9,9 @@ end include_recipe 'perl' +include_recipe 'chef-sugar::default' +require 'chef/sugar/core_extensions' + include_recipe 'stash::database' if settings['database']['host'] == '127.0.0.1' include_recipe "stash::#{platform}_#{node['stash']['install_type']}" include_recipe 'stash::configuration' diff --git a/templates/default/web_app.conf.erb b/templates/default/web_app.conf.erb index cc28e81..2d48d6a 100644 --- a/templates/default/web_app.conf.erb +++ b/templates/default/web_app.conf.erb @@ -3,10 +3,10 @@ # Local modifications will be overwritten by Chef. # > - <% unless node['stash']['apache2']['virtual_host_name'].empty? -%> + <% unless node['stash']['apache2']['virtual_host_name'].blank? -%> ServerName <%= node['stash']['apache2']['virtual_host_name'] %> <% end -%> - <% unless node['stash']['apache2']['virtual_host_alias'].empty? -%> + <% unless node['stash']['apache2']['virtual_host_alias'].blank? -%> <% virtual_host_aliases = node['stash']['apache2']['virtual_host_alias'].kind_of?(Array) ? node['stash']['apache2']['virtual_host_alias'] : [ node['stash']['apache2']['virtual_host_alias'] ] -%> <% virtual_host_aliases.each do |virtual_host_alias| -%> ServerAlias <%= virtual_host_alias %> @@ -14,8 +14,8 @@ <% end -%> DocumentRoot <%= node['stash']['install_path'] %> - CustomLog <%= node['stash']['apache2']['access_log'].empty? ? node['apache']['log_dir']+"/stash-access.log" : node['stash']['apache2']['access_log'] %> combined - ErrorLog <%= node['stash']['apache2']['error_log'].empty? ? node['apache']['log_dir']+"/stash-error.log" : node['stash']['apache2']['error_log'] %> + CustomLog <%= node['stash']['apache2']['access_log'].blank? ? node['apache']['log_dir']+"/stash-access.log" : node['stash']['apache2']['access_log'] %> combined + ErrorLog <%= node['stash']['apache2']['error_log'].blank? ? node['apache']['log_dir']+"/stash-error.log" : node['stash']['apache2']['error_log'] %> LogLevel warn @@ -31,10 +31,10 @@ > - <% unless node['stash']['apache2']['virtual_host_name'].empty? -%> + <% unless node['stash']['apache2']['virtual_host_name'].blank? -%> ServerName <%= node['stash']['apache2']['virtual_host_name'] %> <% end -%> - <% unless node['stash']['apache2']['virtual_host_alias'].empty? -%> + <% unless node['stash']['apache2']['virtual_host_alias'].blank? -%> <% virtual_host_aliases = node['stash']['apache2']['virtual_host_alias'].kind_of?(Array) ? node['stash']['apache2']['virtual_host_alias'] : [ node['stash']['apache2']['virtual_host_alias'] ] -%> <% virtual_host_aliases.each do |virtual_host_alias| -%> ServerAlias <%= virtual_host_alias %> @@ -42,8 +42,8 @@ <% end -%> DocumentRoot <%= node['stash']['install_path'] %> - CustomLog <%= node['stash']['apache2']['ssl']['access_log'].empty? ? node['apache']['log_dir']+"/stash-ssl-access.log" : node['stash']['apache2']['ssl']['access_log'] %> combined - ErrorLog <%= node['stash']['apache2']['ssl']['error_log'].empty? ? node['apache']['log_dir']+"/stash-ssl-error.log" : node['stash']['apache2']['ssl']['error_log'] %> + CustomLog <%= node['stash']['apache2']['ssl']['access_log'].blank? ? node['apache']['log_dir']+"/stash-ssl-access.log" : node['stash']['apache2']['ssl']['access_log'] %> combined + ErrorLog <%= node['stash']['apache2']['ssl']['error_log'].blank? ? node['apache']['log_dir']+"/stash-ssl-error.log" : node['stash']['apache2']['ssl']['error_log'] %> LogLevel warn @@ -60,7 +60,7 @@ SSLEngine on SSLCertificateFile <%= node['stash']['apache2']['ssl']['certificate_file'] %> SSLCertificateKeyFile <%= node['stash']['apache2']['ssl']['key_file'] %> - <% unless node['stash']['apache2']['ssl']['chain_file'].empty? -%> + <% unless node['stash']['apache2']['ssl']['chain_file'].blank? -%> SSLCertificateChainFile <%= node['stash']['apache2']['ssl']['chain_file'] %> <% end -%> diff --git a/test/support/travis_id_rsa.key.enc b/test/support/travis_id_rsa.key.enc new file mode 100644 index 0000000..d6b81f5 Binary files /dev/null and b/test/support/travis_id_rsa.key.enc differ