Skip to content

Commit

Permalink
Feature/release 1.0.0 (#31)
Browse files Browse the repository at this point in the history
* move recipes to different names


add contributing


disable java

* add source-distribution

* fix lint

* fix distribution typo

* change install-unix modes to safer ones

* move java + package installation to prerequesites

* let chef manage the home directory of artifactory user

* set directories without ::File.join

* change zip_url and zip_checksum to package_*

* change default run_list

* reorder attributes + add new attributes for distribution installation

* fix link in contribution

* add suites for testing

* Add helpers for package detection

* change usage in recipes

* update server.xml.erb template

* update with tests, add missing installs and enables

* rename stages + add concurrent to 2

* fix stage renaming

* specify version, add missing service resource,

* add excludes and fix bugs

* change to concurrent 3

* fix yum repo and add install of package

* add monthly integration test

* add gpg check for yum repository

* fix test for different os environments

* add service test for runit_service, which is used in zip archives

* add integration test for zip package

* add changelog + bump metadata.rb

* update changelog

* only 1 test at a time

* disable some kitchen tests

* circle ci

* retries 2

* add retry_delay as artifactory needs some more time for it

* try killing apt lock

* again

* redo config

* fix dokken start command + fix naming in header of recipe files

* reenable tests

* update changelog
  • Loading branch information
pschaumburg authored Mar 27, 2019
1 parent e6b5245 commit 4d7f671
Show file tree
Hide file tree
Showing 18 changed files with 509 additions and 87 deletions.
21 changes: 17 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2
jobs:
test:
linting:
docker:
- image: chef/chefdk
working_directory: ~/chef-repo
Expand All @@ -24,6 +24,8 @@ jobs:
- run:
name: Install chefdk
command: |
# sudo fuser -k /var/lib/apt/lists/lock
# sudo pkill -f apt
sudo apt-get update --fix-missing
sudo apt-get install -y apt-transport-https
wget -qO - https://packages.chef.io/chef.asc | sudo apt-key add -
Expand All @@ -41,7 +43,7 @@ jobs:
- run:
name: running kitchen create
command: |
kitchen create -c && kitchen converge
kitchen test -c 1
- run:
name: destroying kitchen
command: |
Expand All @@ -50,11 +52,11 @@ workflows:
version: 2
base:
jobs:
- test
- linting
- integration
nightly:
jobs:
- test
- linting
- integration
triggers:
-
Expand All @@ -64,3 +66,14 @@ workflows:
branches:
only:
- master
monthly:
jobs:
- integration
triggers:
-
schedule:
cron: "0 1 1 * *"
filters:
branches:
only:
- master
2 changes: 2 additions & 0 deletions .kitchen.dokken.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ platforms:
image: dokken/debian-8
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN echo "deb http://deb.debian.org/debian jessie main" > /etc/apt/sources.list
- RUN echo "deb http://security.debian.org/debian-security jessie/updates main" >> /etc/apt/sources.list
- RUN /usr/bin/apt-get update

- name: debian-9
Expand Down
91 changes: 90 additions & 1 deletion .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,103 @@ platforms:
- name: debian-9
- name: centos-7

verifier:
name: inspec

suites:
- name: artifactory-oracle
- name: artifactory-oracle-distribution-oss
run_list:
- recipe[artifactory]
verifier:
inspec_tests:
- test/integration/default/package-oss.rb
- test/integration/default/service.rb
attributes:
java:
oracle:
accept_oracle_download_terms: true
install_flavor: oracle
ark_retries: 2
ark_retry_delay: 10
artifactory:
install_flavor: distribution
edition: oss
version: '6.8.7'
# - name: artifactory-oracle-distribution-pro
# run_list:
# - recipe[artifactory]
# verifier:
# inspec_tests:
# - test/integration/default/package-pro.rb
# - test/integration/default/service.rb
# attributes:
# java:
# oracle:
# accept_oracle_download_terms: true
# install_flavor: oracle
# ark_retries: 2
# ark_retry_delay: 10
# artifactory:
# install_flavor: distribution
# edition: pro
# version: '6.8.7'

- name: artifactory-oracle-binary-deb
run_list:
- recipe[artifactory]
excludes:
- centos-7
verifier:
inspec_tests:
- test/integration/default/package-oss.rb
- test/integration/default/service.rb
attributes:
java:
oracle:
accept_oracle_download_terms: true
install_flavor: oracle
ark_retries: 2
ark_retry_delay: 10
artifactory:
install_flavor: binary
package_uri: 'https://jfrog.bintray.com/artifactory-debs/pool/main/j/jfrog-artifactory-oss-deb/jfrog-artifactory-oss-6.8.7.deb'
package_sha256: 'ceb80f808209579aef287d84c5d7747452498b12f286d21eee2effb0002f4f8e'
- name: artifactory-oracle-binary-rpm
run_list:
- recipe[artifactory]
excludes:
- ubuntu-16.04
- debian-8
- debian-9
verifier:
inspec_tests:
- test/integration/default/package-oss.rb
- test/integration/default/service.rb
attributes:
java:
oracle:
accept_oracle_download_terms: true
install_flavor: oracle
ark_retries: 2
ark_retry_delay: 10
artifactory:
install_flavor: binary
package_uri: 'https://jfrog.bintray.com/artifactory-rpms/jfrog-artifactory-oss-6.8.7.rpm'
package_sha256: 'f9aa12cf7f35e87a23e88e3cb6de95275c82c2d78b4d85a41583b5a64508e3f7'
- name: artifactory-oracle-binary-zip
run_list:
- recipe[artifactory]
verifier:
inspec_tests:
- test/integration/default/service.rb
attributes:
java:
oracle:
accept_oracle_download_terms: true
install_flavor: oracle
ark_retries: 2
ark_retry_delay: 10
artifactory:
install_flavor: binary
package_uri: 'http://dl.bintray.com/jfrog/artifactory/jfrog-artifactory-oss-6.8.7.zip'
package_sha256: '43e29a84e34049f3aa2cf143274e4c25dc130406f88eae902d07f7351b9c6015'
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# Artifactory Cookbook Changelog
This file is used to list changes made in each version of the artifactory cookbook.

## v1.0.0 - 28.03.2019

- Add installation type binary and distribution
- Add suites for testing
- Add some basic integration tests
- Add helpers for package detection
- Add Contributing.md
- Add monthly integration tests
- Add daily linting tests for latest chef-client version
- Update server.xml template
- Prepared multi OS integration and moved recipe content of default into install_distribution
- Reorder attributes

## v0.5.0 - 05.03.2019

- Add kitchen dokken
Expand Down
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Contributing

1. Fork the repository on Github
2. Create a named feature branch (like `feature/add_foobar`)
3. Write your change
4. Write tests for your change (if applicable)
5. Run the tests, ensuring they all pass
6. Submit a Pull Request using Github
29 changes: 21 additions & 8 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
default['artifactory']['zip_url'] = 'http://dl.bintray.com/content/jfrog/artifactory/jfrog-artifactory-oss-5.2.1.zip'
default['artifactory']['zip_checksum'] = '993d9abd188a6b1eaf4c762f201f0ba70f545ca68ad099f9a9a48bec3470d68d'
# This file contains all possible attributes, which can be set
# artifactory configurations
default['artifactory']['home'] = '/var/lib/artifactory'
default['artifactory']['log_dir'] = '/var/log/artifactory'
default['artifactory']['catalina_base'] = ::File.join(node['artifactory']['home'], 'tomcat')
default['artifactory']['java']['xmx'] = '1g'
default['artifactory']['java']['xms'] = '512m'
default['artifactory']['java']['extra_opts'] = '-XX:+UseG1GC'
default['artifactory']['java']['jdk_version'] = 8

default['artifactory']['user'] = 'artifactory'
default['artifactory']['group'] = 'artifactory'
default['artifactory']['port'] = 8081
# default['artifactory']['max_threads'] = 200
default['artifactory']['shutdown_port'] = 8015
default['artifactory']['install_java'] = true

# java configurations
default['artifactory']['catalina_base'] = ::File.join(node['artifactory']['home'], 'tomcat')
default['artifactory']['java']['xmx'] = '1g'
default['artifactory']['java']['xms'] = '512m'
default['artifactory']['java']['extra_opts'] = '-XX:+UseG1GC'
default['artifactory']['java']['jdk_version'] = 8

# ajp configurations
default['artifactory']['use_ajp'] = false
default['artifactory']['ajp']['port'] = 8019
default['artifactory']['ajp']['maxThreads'] = 500
default['artifactory']['ajp']['minSpareThreads'] = 20
default['artifactory']['ajp']['enableLookups'] = false
default['artifactory']['ajp']['backlog'] = 100

# can be 'distribution' (apt source / yum source) || 'binary' (rpm / deb)
default['artifactory']['install_flavor'] = 'binary'
# when set install_flavor = distribution
default['artifactory']['edition'] = 'oss' # can be ce, oss, pro
default['artifactory']['version'] = '6.8.7'

# install_flavor = binary
default['artifactory']['package_uri'] = 'http://dl.bintray.com/jfrog/artifactory/jfrog-artifactory-oss-6.8.4.zip'
default['artifactory']['package_sha256'] = '4bbdb76cec091ba61b6d7bffc61b2432327f2e1375efb108468ee445cd5ed261'
28 changes: 28 additions & 0 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Artifactory
module Cookbook
module Helpers
def file_ending
package = node['artifactory']['package_uri']
File.extname(package)
end

def pack_name
case node['artifactory']['edition']
when 'oss'
'jfrog-artifactory-oss'
when 'ce'
'jfrog-artifactory-cpp-ce'
when 'pro'
'jfrog-artifactory-pro'
end
end

def binary_file
Chef::Config[:file_cache_path] + '/artifactory' + file_ending
end
end
end
end

Chef::Recipe.include(Artifactory::Cookbook::Helpers)
Chef::Resource.include(Artifactory::Cookbook::Helpers)
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'Apache-2.0'
description 'Installs/Configures artifactory'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.5.0'
version '1.0.0'

source_url 'https://github.com/pschaumburg/artifactory' if defined?(:source_url)
issues_url 'https://github.com/pschaumburg/artifactory/issues' if defined?(:issues_url)
Expand Down
80 changes: 9 additions & 71 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,80 +2,18 @@
# Cookbook Name:: artifactory
# Recipe:: default
#
# Copyright (C) 2013 Fewbytes
#
# Apache V2
#
# Copyright (c) 2019 Patrick Schaumburg, Apache-2.0

case node['platform_family']
when 'windows'
Chef::Application.fatal!('You want to install artifactory on windows, which is not supported right now.')
end

if node['artifactory']['install_java']
node.default['java']['jdk_version'] = node['artifactory']['java']['jdk_version']
include_recipe 'java'
end

include_recipe 'runit'
package 'unzip'
# ark requires rsync package
package 'rsync'

user node['artifactory']['user'] do
home node['artifactory']['home']
end

group node['artifactory']['group'] do
members [node['artifactory']['user']]
end

directory node['artifactory']['home'] do
owner node['artifactory']['user']
group node['artifactory']['group']
mode 00755
recursive true
end

directory node['artifactory']['catalina_base'] do
owner node['artifactory']['user']
group node['artifactory']['group']
mode 00755
recursive true
end

%w(work temp).each do |tomcat_dir|
directory ::File.join(node['artifactory']['catalina_base'], tomcat_dir) do
owner node['artifactory']['user']
group node['artifactory']['group']
mode 00755
end
end

directory node['artifactory']['log_dir'] do
owner node['artifactory']['user']
group node['artifactory']['group']
mode 00755
end

ark 'artifactory' do
url node['artifactory']['zip_url']
checksum node['artifactory']['zip_checksum']
owner node['artifactory']['user']
group node['artifactory']['group']
action :install
end

link ::File.join(node['artifactory']['home'], 'webapps') do
to '/usr/local/artifactory/webapps'
end

link ::File.join(node['artifactory']['catalina_base'], 'logs') do
to node['artifactory']['log_dir']
end

link ::File.join(node['artifactory']['catalina_base'], 'conf') do
to '/usr/local/artifactory/tomcat/conf'
end

template '/usr/local/artifactory/tomcat/conf/server.xml' do
mode 00644
notifies :restart, 'runit_service[artifactory]'
end

runit_service 'artifactory'
include_recipe 'artifactory::prerequesites'
include_recipe "artifactory::install_#{node['artifactory']['install_flavor']}"
include_recipe 'artifactory::deprecations' # test this
16 changes: 16 additions & 0 deletions recipes/deprecations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Cookbook Name:: artifactory
# Recipe:: deprecations
#
# Copyright (c) 2019 Patrick Schaumburg, Apache-2.0

# log "you are using the attribute node['artifactory']['zip_url'], which will be deprecated in future versions" do
# level :warn
# only_if node['artifactory']['zip_url']
# end
#
# log "you are using the attribute node['artifactory']['zip_checksum'], which will be deprecated in future versions" do
# message "use node['artifactory']['package_checksum'] instead"
# level :warn
# only_if node['artifactory']['zip_checksum']
# end
Loading

0 comments on commit 4d7f671

Please sign in to comment.