From cd90d3da11453a95e22f9806bc24deae22d31e5e Mon Sep 17 00:00:00 2001 From: jtschelling Date: Fri, 14 Feb 2020 15:01:53 -0600 Subject: [PATCH 01/12] switch poise-python cookbook usage to pyenv Signed-off-by: jtschelling --- README.md | 8 +++--- attributes/default.rb | 2 ++ attributes/uwsgi.rb | 1 - kitchen.yml | 23 ++++++++------- metadata.rb | 2 +- recipes/_carbon_packages.rb | 15 +++++----- recipes/_directories.rb | 5 ++++ recipes/_web_packages.rb | 20 ++++++------- recipes/carbon.rb | 28 +++++++++++-------- recipes/web.rb | 23 +++++++++++---- resources/carbon_cache.rb | 10 ++----- resources/storage.rb | 12 ++++---- spec/recipes/_carbon_package_spec.rb | 2 +- spec/recipes/_web_packages_spec.rb | 4 +-- .../cookbooks/test/recipes/single_node.rb | 19 ++++++------- 15 files changed, 96 insertions(+), 78 deletions(-) diff --git a/README.md b/README.md index 6f0cc737..3a2538ff 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of ### Cookbooks -- poise-python +- pyenv ## Attributes @@ -79,7 +79,7 @@ Some of this weirdness may not really be needed, so send us a PR if you fix it b ### uwsgi -Start a uwsgi runit service for graphite-web. That's it. +Start a uwsgi systemd service for graphite-web. That's it. ### Various internal recipes @@ -93,7 +93,7 @@ It's like a treasure hunt. Management for the various [Carbon](https://github.com/graphite-project/carbon) services which receive your metrics and write them to disk. -- `graphite_service`: sets up a carbon service with runit, essentially a glorified `runit_service`. Carbon configuration should be defined first with one of the `graphite_carbon_*` resources. Multiple daemons can be run by using multiple resources with names such as `cache:a`, `cache:b`, etc.. +- `graphite_service`: sets up a carbon service with systemd, essentially a glorified `systemd_unit`. Carbon configuration should be defined first with one of the `graphite_carbon_*` resources. Multiple daemons can be run by using multiple resources with names such as `cache:a`, `cache:b`, etc.. - `graphite_carbon_aggregator`: data driven resource for carbon-aggregator configuration - `graphite_carbon_cache`: data driven resource for carbon-cache configuration - `graphite_carbon_relay`: data driven resource for carbon-cache configuration @@ -113,7 +113,7 @@ Write the configuration file for [Graphite Web](https://github.com/graphite-proj Yes it's [writing python via ruby](https://github.com/sous-chefs/graphite/blob/master/libraries/chef_graphite_python.rb#L14). -A runit service definition is provided to [start a uwsgi process](https://github.com/sous-chefs/graphite/blob/master/example/graphite_example/recipes/single_node.rb#L105), but note that choice of web server for proxying to the application server is left up to you. No more hard Apache dependency! +A systemd service unit definition is provided to [start a uwsgi process](https://github.com/sous-chefs/graphite/blob/master/recipes/uwsgi.rb), but note that choice of web server for proxying to the application server is left up to you. No more hard Apache dependency! ### Accumulators diff --git a/attributes/default.rb b/attributes/default.rb index cec1818b..93ccc640 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -71,3 +71,5 @@ else [] end + +default['graphite']['pyenv']['python_version'] = '2.7.17' diff --git a/attributes/uwsgi.rb b/attributes/uwsgi.rb index b51a65a7..8dce8e07 100644 --- a/attributes/uwsgi.rb +++ b/attributes/uwsgi.rb @@ -25,5 +25,4 @@ default['graphite']['uwsgi']['carbon'] = '127.0.0.1:2003' default['graphite']['uwsgi']['listen_http'] = false default['graphite']['uwsgi']['port'] = 8080 -default['graphite']['uwsgi']['service_type'] = 'runit' default['graphite']['uwsgi']['buffer-size'] = '4096' diff --git a/kitchen.yml b/kitchen.yml index 202fe74b..e01621e6 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -16,17 +16,20 @@ platforms: - name: centos-7 - name: debian-8 - name: debian-9 - - name: ubuntu-14.04 + - name: debian-10 - name: ubuntu-16.04 - name: ubuntu-18.04 suites: - - name: default - run_list: - - recipe[test::single_node] - attributes: - graphite: - listen_port: "8080" - uwsgi: - workers: 4 - listen_http: true +- name: default + driver: + network: + - ["forwarded_port", {guest: 8080, host: 8080}] + run_list: + - recipe[test::single_node] + attributes: + graphite: + listen_port: "8080" + uwsgi: + workers: 4 + listen_http: true diff --git a/metadata.rb b/metadata.rb index 0d55d0b3..f330943d 100644 --- a/metadata.rb +++ b/metadata.rb @@ -13,7 +13,7 @@ supports 'scientific' supports 'oracle' -depends 'poise-python', '>= 1.5' +depends 'pyenv', '~> 3.1' source_url 'https://github.com/sous-chefs/graphite' issues_url 'https://github.com/sous-chefs/graphite/issues' diff --git a/recipes/_carbon_packages.rb b/recipes/_carbon_packages.rb index c9057cf1..51181ec0 100644 --- a/recipes/_carbon_packages.rb +++ b/recipes/_carbon_packages.rb @@ -23,22 +23,21 @@ # Compliler is needed to build Twisted gem on this step package platform_family?('debian') ? 'build-essential' : 'gcc' -python_package 'Twisted' do +pyenv_pip 'twisted' do + virtualenv node['graphite']['base_dir'] user node['graphite']['user'] - group node['graphite']['group'] version node['graphite']['twisted_version'] - virtualenv node['graphite']['base_dir'] end -python_package 'carbon' do +pyenv_pip 'carbon' do package_name lazy { node['graphite']['package_names']['carbon'][node['graphite']['install_type']] } + + virtualenv node['graphite']['base_dir'] + user node['graphite']['user'] version lazy { node['graphite']['install_type'] == 'package' ? node['graphite']['version'] : nil } - user node['graphite']['user'] - group node['graphite']['group'] - install_options '--no-binary=:all:' - virtualenv node['graphite']['base_dir'] + options '--no-binary=:all:' end diff --git a/recipes/_directories.rb b/recipes/_directories.rb index 87e6ac41..b7b6edef 100644 --- a/recipes/_directories.rb +++ b/recipes/_directories.rb @@ -17,6 +17,11 @@ # limitations under the License. # +directory node['graphite']['base_dir'] do + owner node['graphite']['user'] + group node['graphite']['group'] +end + directory node['graphite']['storage_dir'] do owner node['graphite']['user'] group node['graphite']['group'] diff --git a/recipes/_web_packages.rb b/recipes/_web_packages.rb index f6622555..3b34b6f6 100644 --- a/recipes/_web_packages.rb +++ b/recipes/_web_packages.rb @@ -19,30 +19,28 @@ package Array(node['graphite']['system_packages']) -python_package 'django' do +pyenv_pip 'django' do + virtualenv node['graphite']['base_dir'] user node['graphite']['user'] - group node['graphite']['group'] version node['graphite']['django_version'] - virtualenv node['graphite']['base_dir'] end -python_package 'uwsgi' do +pyenv_pip 'uwsgi' do + virtualenv node['graphite']['base_dir'] user node['graphite']['user'] - group node['graphite']['group'] options '--isolated' - virtualenv node['graphite']['base_dir'] end -python_package 'graphite_web' do +pyenv_pip 'graphite_web' do package_name lazy { key = node['graphite']['install_type'] node['graphite']['package_names']['graphite_web'][key] } + + virtualenv node['graphite']['base_dir'] + user node['graphite']['user'] version lazy { node['graphite']['version'] if node['graphite']['install_type'] == 'package' } - user node['graphite']['user'] - group node['graphite']['group'] - install_options '--no-binary=:all:' - virtualenv node['graphite']['base_dir'] + options '--no-binary=:all:' end diff --git a/recipes/carbon.rb b/recipes/carbon.rb index a5516371..b9d2d7c1 100644 --- a/recipes/carbon.rb +++ b/recipes/carbon.rb @@ -17,25 +17,29 @@ # limitations under the License. # -python_runtime 'carbons_python' do - provider :system - version '2.7' - options pip_version: true +include_recipe 'graphite::_user' +include_recipe 'graphite::_directories' + +pyenv_user_install 'carbons_pyenv' do + user node['graphite']['user'] end -include_recipe 'graphite::_user' +pyenv_python node['graphite']['pyenv']['python_version'] do + user node['graphite']['user'] +end -directory node['graphite']['base_dir'] do - owner node['graphite']['user'] - group node['graphite']['group'] +pyenv_global node['graphite']['pyenv']['python_version'] do + user node['graphite']['user'] end -python_virtualenv node['graphite']['base_dir'] do +pyenv_pip 'virtualenv' do + user node['graphite']['user'] +end + +pyenv_script 'setup graphite virtualenv' do + code "virtualenv #{node['graphite']['base_dir']}" user node['graphite']['user'] - group node['graphite']['group'] end -include_recipe 'graphite::_user' include_recipe 'graphite::_carbon_packages' -include_recipe 'graphite::_directories' include_recipe 'graphite::_carbon_config' diff --git a/recipes/web.rb b/recipes/web.rb index 59421402..4da3c063 100644 --- a/recipes/web.rb +++ b/recipes/web.rb @@ -17,13 +17,26 @@ # limitations under the License. # -python_runtime 'webs_python' do - provider :system - version '2.7' - options pip_version: true +pyenv_user_install 'webs_pyenv' do + user node['graphite']['user'] end -python_virtualenv node['graphite']['base_dir'] +pyenv_python node['graphite']['pyenv']['python_version'] do + user node['graphite']['user'] +end + +pyenv_global node['graphite']['pyenv']['python_version'] do + user node['graphite']['user'] +end + +pyenv_pip 'virtualenv' do + user node['graphite']['user'] +end + +pyenv_script 'setup graphite virtualenv' do + code "virtualenv #{node['graphite']['base_dir']}" + user node['graphite']['user'] +end include_recipe 'graphite::_user' include_recipe 'graphite::_web_packages' diff --git a/resources/carbon_cache.rb b/resources/carbon_cache.rb index 2e76004e..19315c54 100644 --- a/resources/carbon_cache.rb +++ b/resources/carbon_cache.rb @@ -21,14 +21,10 @@ property :config, [Hash, nil], default: nil action :create do - python_package backend_name do - backend_attributes.each { |attr, value| send(attr, value) } - Chef::Log.info "Installing storage backend: #{package_name}" - action :install - user node['graphite']['user'] - group node['graphite']['group'] - install_options '--no-binary=:all:' + pyenv_pip backend_name do virtualenv node['graphite']['base_dir'] + user node['graphite']['user'] + options '--no-binary=:all:' end end diff --git a/resources/storage.rb b/resources/storage.rb index 0dd73ede..b2be8c40 100644 --- a/resources/storage.rb +++ b/resources/storage.rb @@ -39,14 +39,14 @@ action_class do def manage_python_pip(resource_action) - python_package new_resource.package_name do - version new_resource.version if new_resource.version - Chef::Log.info 'Installing whisper pip package' + pyenv_pip new_resource.package_name do action resource_action - user node['graphite']['user'] - group node['graphite']['group'] - install_options '--no-binary=:all:' + virtualenv node['graphite']['base_dir'] + user node['graphite']['user'] + version new_resource.version if new_resource.version + Chef::Log.info 'Installing whisper pip package' + options '--no-binary=:all:' end end diff --git a/spec/recipes/_carbon_package_spec.rb b/spec/recipes/_carbon_package_spec.rb index fce76f1d..40f198fd 100644 --- a/spec/recipes/_carbon_package_spec.rb +++ b/spec/recipes/_carbon_package_spec.rb @@ -4,6 +4,6 @@ let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) } it 'installs python runtime' do - expect(chef_run).to install_python_runtime('carbons_python') + expect(chef_run).to install_pyenv_user_install('carbons_pyenv') end end diff --git a/spec/recipes/_web_packages_spec.rb b/spec/recipes/_web_packages_spec.rb index 6084b177..244a0263 100644 --- a/spec/recipes/_web_packages_spec.rb +++ b/spec/recipes/_web_packages_spec.rb @@ -13,11 +13,11 @@ end it 'installs a django python package' do - expect(chef_run).to install_python_package('django') + expect(chef_run).to install_pyenv_pip('django') end it 'installs a specific version of graphite_web python package' do - expect(chef_run).to install_python_package('graphite_web').with( + expect(chef_run).to install_pyenv_pip('graphite_web').with( package_name: 'graphite-web', version: '1.1.3' ) diff --git a/test/fixtures/cookbooks/test/recipes/single_node.rb b/test/fixtures/cookbooks/test/recipes/single_node.rb index 01b6ff32..202ada59 100644 --- a/test/fixtures/cookbooks/test/recipes/single_node.rb +++ b/test/fixtures/cookbooks/test/recipes/single_node.rb @@ -1,4 +1,12 @@ -apt_update 'update' if platform_family?('debian') +apt_update 'update' do + action :update +end + +node.default['graphite']['version'] = '1.1.6' +node.default['graphite']['twisted_version'] = '19.7.0' + +node.default['graphite']['django_version'] = '1.11.28' + include_recipe 'graphite::carbon' include_recipe 'graphite::web' @@ -63,13 +71,4 @@ notifies :restart, 'service[graphite-web]', :delayed end -python_execute 'bin/django-admin.py migrate --run-syncdb --settings="graphite.settings" --pythonpath=webapp' do - user node['graphite']['user'] - group node['graphite']['group'] - cwd node['graphite']['base_dir'] - python 'webs_python' - virtualenv node['graphite']['base_dir'] - creates "#{storage_dir}/graphite.db" -end - include_recipe 'graphite::uwsgi' From 916462a85076b2a77156cb2c07c035f1c2e6d070 Mon Sep 17 00:00:00 2001 From: jtschelling Date: Wed, 27 May 2020 17:08:03 -0500 Subject: [PATCH 02/12] add python install inspec test Signed-off-by: jtschelling --- metadata.rb | 2 +- recipes/web.rb | 5 +++-- test/fixtures/cookbooks/test/recipes/single_node.rb | 10 ++++++---- test/integration/default/default_spec.rb | 4 ++++ test/integration/default/python_install_spec.rb | 12 ++++++++++++ 5 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 test/integration/default/python_install_spec.rb diff --git a/metadata.rb b/metadata.rb index f330943d..f7c8e479 100644 --- a/metadata.rb +++ b/metadata.rb @@ -17,4 +17,4 @@ source_url 'https://github.com/sous-chefs/graphite' issues_url 'https://github.com/sous-chefs/graphite/issues' -chef_version '>= 13' +chef_version '>= 14' diff --git a/recipes/web.rb b/recipes/web.rb index 4da3c063..2c8e3fb0 100644 --- a/recipes/web.rb +++ b/recipes/web.rb @@ -17,6 +17,9 @@ # limitations under the License. # +include_recipe 'graphite::_user' +include_recipe 'graphite::_directories' + pyenv_user_install 'webs_pyenv' do user node['graphite']['user'] end @@ -38,9 +41,7 @@ user node['graphite']['user'] end -include_recipe 'graphite::_user' include_recipe 'graphite::_web_packages' -include_recipe 'graphite::_directories' basedir = node['graphite']['base_dir'] docroot = node['graphite']['doc_root'] diff --git a/test/fixtures/cookbooks/test/recipes/single_node.rb b/test/fixtures/cookbooks/test/recipes/single_node.rb index 202ada59..31979ef2 100644 --- a/test/fixtures/cookbooks/test/recipes/single_node.rb +++ b/test/fixtures/cookbooks/test/recipes/single_node.rb @@ -1,10 +1,7 @@ -apt_update 'update' do - action :update -end +apt_update 'update' if platform_family?('debian') node.default['graphite']['version'] = '1.1.6' node.default['graphite']['twisted_version'] = '19.7.0' - node.default['graphite']['django_version'] = '1.11.28' include_recipe 'graphite::carbon' @@ -71,4 +68,9 @@ notifies :restart, 'service[graphite-web]', :delayed end +pyenv_script 'django migrate' do + code "#{node['graphite']['base_dir']}/bin/python #{node['graphite']['base_dir']}/bin/django-admin.py migrate --run-syncdb --settings=\"graphite.settings\" --pythonpath=#{node['graphite']['base_dir']}/webapp" + user node['graphite']['user'] +end + include_recipe 'graphite::uwsgi' diff --git a/test/integration/default/default_spec.rb b/test/integration/default/default_spec.rb index fa105d8d..ac1c7ab2 100644 --- a/test/integration/default/default_spec.rb +++ b/test/integration/default/default_spec.rb @@ -14,3 +14,7 @@ it { should be_listening } its('protocols') { should include 'tcp' } end + +describe command('curl -fs http://localhost:8080/metrics/find?query=carbon.*') do + its(:exit_status) { should eq(0) } +end diff --git a/test/integration/default/python_install_spec.rb b/test/integration/default/python_install_spec.rb new file mode 100644 index 00000000..b1d25d4a --- /dev/null +++ b/test/integration/default/python_install_spec.rb @@ -0,0 +1,12 @@ +describe directory('/var/lib/graphite/.pyenv') do + it { should exist } +end + +describe file('/opt/graphite/bin/python') do + it { should be_executable } + its(:owner) { should eq('graphite') } +end + +describe command('/opt/graphite/bin/python --version') do + its(:stderr) { should match(/2\.7\.17/) } +end From ec61a578efce4e5ad365c276b0a622cc0d53cfcb Mon Sep 17 00:00:00 2001 From: jtschelling Date: Wed, 3 Jun 2020 13:57:16 -0500 Subject: [PATCH 03/12] move python install to separate resource Signed-off-by: jtschelling --- metadata.rb | 2 +- recipes/carbon.rb | 21 +-------------------- recipes/web.rb | 21 +-------------------- resources/python.rb | 29 +++++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 41 deletions(-) create mode 100644 resources/python.rb diff --git a/metadata.rb b/metadata.rb index f7c8e479..68d63c68 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license 'Apache-2.0' description 'Installs/Configures graphite' -version '1.3.0' +version '2.0.0' supports 'ubuntu' supports 'debian' diff --git a/recipes/carbon.rb b/recipes/carbon.rb index b9d2d7c1..b3d74672 100644 --- a/recipes/carbon.rb +++ b/recipes/carbon.rb @@ -20,26 +20,7 @@ include_recipe 'graphite::_user' include_recipe 'graphite::_directories' -pyenv_user_install 'carbons_pyenv' do - user node['graphite']['user'] -end - -pyenv_python node['graphite']['pyenv']['python_version'] do - user node['graphite']['user'] -end - -pyenv_global node['graphite']['pyenv']['python_version'] do - user node['graphite']['user'] -end - -pyenv_pip 'virtualenv' do - user node['graphite']['user'] -end - -pyenv_script 'setup graphite virtualenv' do - code "virtualenv #{node['graphite']['base_dir']}" - user node['graphite']['user'] -end +graphite_python 'carbons_python' include_recipe 'graphite::_carbon_packages' include_recipe 'graphite::_carbon_config' diff --git a/recipes/web.rb b/recipes/web.rb index 2c8e3fb0..d8acc00b 100644 --- a/recipes/web.rb +++ b/recipes/web.rb @@ -20,26 +20,7 @@ include_recipe 'graphite::_user' include_recipe 'graphite::_directories' -pyenv_user_install 'webs_pyenv' do - user node['graphite']['user'] -end - -pyenv_python node['graphite']['pyenv']['python_version'] do - user node['graphite']['user'] -end - -pyenv_global node['graphite']['pyenv']['python_version'] do - user node['graphite']['user'] -end - -pyenv_pip 'virtualenv' do - user node['graphite']['user'] -end - -pyenv_script 'setup graphite virtualenv' do - code "virtualenv #{node['graphite']['base_dir']}" - user node['graphite']['user'] -end +graphite_python 'webs_python' include_recipe 'graphite::_web_packages' diff --git a/resources/python.rb b/resources/python.rb new file mode 100644 index 00000000..c57d4680 --- /dev/null +++ b/resources/python.rb @@ -0,0 +1,29 @@ +default_action :install + +property :pyenv_name, String, name_property: true +property :python_version, String, default: '2.7.17' +property :user, String, default: lazy { node['graphite']['user'] } +property :graphite_dir, String, default: lazy { node['graphite']['base_dir'] } + +action :install do + pyenv_user_install new_resource.pyenv_name do + user new_resource.user + end + + pyenv_python new_resource.python_version do + user new_resource.user + end + + pyenv_global new_resource.python_version do + user new_resource.user + end + + pyenv_pip 'virtualenv' do + user new_resource.user + end + + pyenv_script 'setup graphite virtualenv' do + code "virtualenv #{new_resource.graphite_dir}" + user new_resource.user + end +end From b96cd117bed3bd417dd04217f371bbd751040d41 Mon Sep 17 00:00:00 2001 From: jtschelling Date: Tue, 16 Jun 2020 15:13:39 -0500 Subject: [PATCH 04/12] Get rid of default attribute for python versioning Signed-off-by: jtschelling --- attributes/default.rb | 2 -- kitchen.dokken.yml | 2 +- kitchen.yml | 20 ++++++++----------- .../chef_graphite_carbon_config_converter.rb | 2 +- spec/recipes/_carbon_package_spec.rb | 2 +- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 93ccc640..cec1818b 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -71,5 +71,3 @@ else [] end - -default['graphite']['pyenv']['python_version'] = '2.7.17' diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index 436bd28c..f9761cc7 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -2,7 +2,7 @@ driver: name: dokken privileged: true # because Docker and SystemD/Upstart - chef_version: <%= ENV['CHEF_VERSION'] || 'current' %> + chef_version: 14 env: [CHEF_LICENSE=accept] transport: diff --git a/kitchen.yml b/kitchen.yml index e01621e6..7aaca5a7 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -21,15 +21,11 @@ platforms: - name: ubuntu-18.04 suites: -- name: default - driver: - network: - - ["forwarded_port", {guest: 8080, host: 8080}] - run_list: - - recipe[test::single_node] - attributes: - graphite: - listen_port: "8080" - uwsgi: - workers: 4 - listen_http: true + - name: default + run_list: + - recipe[test::single_node] + attributes: + graphite: + uwsgi: + workers: 4 + listen_http: true diff --git a/libraries/chef_graphite_carbon_config_converter.rb b/libraries/chef_graphite_carbon_config_converter.rb index b13c53ef..43ee8590 100644 --- a/libraries/chef_graphite_carbon_config_converter.rb +++ b/libraries/chef_graphite_carbon_config_converter.rb @@ -122,7 +122,7 @@ def normalize_value(obj) obj.map { |o| normalize_value(o) }.join(', ') else value = obj.to_s - value.capitalize! if %w(true false).include?(value) + value = value.capitalize if %w(true false).include?(value) value end end diff --git a/spec/recipes/_carbon_package_spec.rb b/spec/recipes/_carbon_package_spec.rb index 40f198fd..c0bc07d5 100644 --- a/spec/recipes/_carbon_package_spec.rb +++ b/spec/recipes/_carbon_package_spec.rb @@ -4,6 +4,6 @@ let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) } it 'installs python runtime' do - expect(chef_run).to install_pyenv_user_install('carbons_pyenv') + expect(chef_run).to install_graphite_python('carbons_python') end end From 5f47e08add4df70e99e84d6c0b278889636b5dcf Mon Sep 17 00:00:00 2001 From: jtschelling Date: Mon, 6 Jul 2020 12:34:32 -0500 Subject: [PATCH 05/12] fix amazonlinux cairo installs, add service inspec tests --- attributes/default.rb | 2 +- kitchen.dokken.yml | 12 +++++++----- kitchen.yml | 4 +--- test/integration/default/carbon_cache_spec.rb | 4 ++++ test/integration/default/graphite_web_spec.rb | 4 ++++ 5 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 test/integration/default/carbon_cache_spec.rb create mode 100644 test/integration/default/graphite_web_spec.rb diff --git a/attributes/default.rb b/attributes/default.rb index cec1818b..38e9390b 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -66,7 +66,7 @@ case node['platform_family'] when 'debian' %w(libcairo2-dev libffi-dev python-rrdtool) - when 'rhel' + when 'rhel', 'amazon' %w(cairo-devel libffi-devel python-rrdtool bitmap-fonts) else [] diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index f9761cc7..ee8ab9eb 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -16,11 +16,6 @@ verifier: name: inspec platforms: - - name: amazonlinux - driver: - image: dokken/amazonlinux - pid_one_command: /sbin/init - - name: amazonlinux-2 driver: image: dokken/amazonlinux-2 @@ -40,6 +35,13 @@ platforms: intermediate_instructions: - RUN /usr/bin/apt-get update + - name: debian-10 + driver: + image: dokken/debian-10 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + - name: centos-7 driver: image: dokken/centos-7 diff --git a/kitchen.yml b/kitchen.yml index 7aaca5a7..9c057534 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -10,9 +10,7 @@ verifier: name: inspec platforms: - - name: amazonlinux - driver_config: - box: mvbcoding/awslinux + - name: amazonlinux-2 - name: centos-7 - name: debian-8 - name: debian-9 diff --git a/test/integration/default/carbon_cache_spec.rb b/test/integration/default/carbon_cache_spec.rb new file mode 100644 index 00000000..33556fbc --- /dev/null +++ b/test/integration/default/carbon_cache_spec.rb @@ -0,0 +1,4 @@ +describe systemd_service('carbon-cache') do + it { should be_enabled } + it { should be_running } +end diff --git a/test/integration/default/graphite_web_spec.rb b/test/integration/default/graphite_web_spec.rb new file mode 100644 index 00000000..7d8dbd28 --- /dev/null +++ b/test/integration/default/graphite_web_spec.rb @@ -0,0 +1,4 @@ +describe systemd_service('graphite-web') do + it { should be_enabled } + it { should be_running } +end From 368d79d37672d6f393f6a7c66f1a5d7043ef26c2 Mon Sep 17 00:00:00 2001 From: jtschelling Date: Mon, 6 Jul 2020 13:11:47 -0500 Subject: [PATCH 06/12] ci testing --- .github/workflows/ci.yml | 1 + kitchen.dokken.yml | 5 +++++ kitchen.yml | 1 + 3 files changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14c9201e..7843ba39 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,6 +44,7 @@ jobs: - 'amazonlinux-2' - 'debian-8' - 'debian-9' + - 'debian-10' - 'ubuntu-1604' - 'ubuntu-1804' - 'centos-7' diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index ee8ab9eb..967b200b 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -16,6 +16,11 @@ verifier: name: inspec platforms: + - name: amazonlinux + driver: + image: dokken/amazonlinux + pid_one_command: /usr/lib/systemd/systemd + - name: amazonlinux-2 driver: image: dokken/amazonlinux-2 diff --git a/kitchen.yml b/kitchen.yml index 9c057534..631de031 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -10,6 +10,7 @@ verifier: name: inspec platforms: + - name: amazonlinux - name: amazonlinux-2 - name: centos-7 - name: debian-8 From 274f49098fa4e62d55051f826567f4aec4760464 Mon Sep 17 00:00:00 2001 From: jtschelling Date: Mon, 6 Jul 2020 14:29:26 -0500 Subject: [PATCH 07/12] remove amazonlinux-1 testing --- .github/workflows/ci.yml | 1 - kitchen.dokken.yml | 5 ----- kitchen.yml | 1 - 3 files changed, 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7843ba39..bf4bbb6a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,6 @@ jobs: strategy: matrix: os: - - 'amazonlinux' - 'amazonlinux-2' - 'debian-8' - 'debian-9' diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index 967b200b..ee8ab9eb 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -16,11 +16,6 @@ verifier: name: inspec platforms: - - name: amazonlinux - driver: - image: dokken/amazonlinux - pid_one_command: /usr/lib/systemd/systemd - - name: amazonlinux-2 driver: image: dokken/amazonlinux-2 diff --git a/kitchen.yml b/kitchen.yml index 631de031..9c057534 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -10,7 +10,6 @@ verifier: name: inspec platforms: - - name: amazonlinux - name: amazonlinux-2 - name: centos-7 - name: debian-8 From 5b1a2b91de7889bae3cc532b81df434d2c889f13 Mon Sep 17 00:00:00 2001 From: jtschelling Date: Tue, 7 Jul 2020 09:44:15 -0500 Subject: [PATCH 08/12] use default chef version for CI --- kitchen.dokken.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index ee8ab9eb..28f14523 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -2,7 +2,7 @@ driver: name: dokken privileged: true # because Docker and SystemD/Upstart - chef_version: 14 + chef_version: <%= ENV['CHEF_VERSION'] || 'current' %> env: [CHEF_LICENSE=accept] transport: From dadac837f308dece603183fc5e47b9aaa7943cda Mon Sep 17 00:00:00 2001 From: jtschelling Date: Wed, 29 Jul 2020 16:19:22 -0500 Subject: [PATCH 09/12] respond to PR comments --- .github/workflows/ci.yml | 1 - attributes/default.rb | 2 +- kitchen.dokken.yml | 14 +++++++------- kitchen.yml | 2 +- metadata.rb | 12 +++++------- resources/python.rb | 2 -- .../fixtures/cookbooks/test/recipes/single_node.rb | 1 - 7 files changed, 14 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf4bbb6a..4d89c4c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,6 @@ jobs: matrix: os: - 'amazonlinux-2' - - 'debian-8' - 'debian-9' - 'debian-10' - 'ubuntu-1604' diff --git a/attributes/default.rb b/attributes/default.rb index 38e9390b..9db14259 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -17,7 +17,7 @@ # limitations under the License. # -default['graphite']['version'] = '1.1.3' +default['graphite']['version'] = '1.1.7' # You may set versions of Twisted and Django packages explicitly, otherwise it # installs actual versions of these packages as dependecies default['graphite']['twisted_version'] = '' diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index 28f14523..2b9de91d 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -21,13 +21,6 @@ platforms: image: dokken/amazonlinux-2 pid_one_command: /usr/lib/systemd/systemd - - name: debian-8 - driver: - image: dokken/debian-8 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - - name: debian-9 driver: image: dokken/debian-9 @@ -60,3 +53,10 @@ platforms: pid_one_command: /bin/systemd intermediate_instructions: - RUN /usr/bin/apt-get update + + - name: ubuntu-20.04 + driver: + image: dokken/ubuntu-20.04 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update diff --git a/kitchen.yml b/kitchen.yml index 9c057534..fbe67c46 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -12,11 +12,11 @@ verifier: platforms: - name: amazonlinux-2 - name: centos-7 - - name: debian-8 - name: debian-9 - name: debian-10 - name: ubuntu-16.04 - name: ubuntu-18.04 + - name: ubuntu-20.04 suites: - name: default diff --git a/metadata.rb b/metadata.rb index 68d63c68..0bbbb6fa 100644 --- a/metadata.rb +++ b/metadata.rb @@ -6,14 +6,12 @@ version '2.0.0' -supports 'ubuntu' -supports 'debian' -supports 'redhat' -supports 'centos' -supports 'scientific' -supports 'oracle' +supports 'ubuntu', '>= 16.0' +supports 'debian', '>= 9.0' +supports 'redhat', '>= 7.0' +supports 'centos', '>= 7.0' -depends 'pyenv', '~> 3.1' +depends 'pyenv', '>= 3.1' source_url 'https://github.com/sous-chefs/graphite' issues_url 'https://github.com/sous-chefs/graphite/issues' diff --git a/resources/python.rb b/resources/python.rb index c57d4680..89d4043b 100644 --- a/resources/python.rb +++ b/resources/python.rb @@ -1,5 +1,3 @@ -default_action :install - property :pyenv_name, String, name_property: true property :python_version, String, default: '2.7.17' property :user, String, default: lazy { node['graphite']['user'] } diff --git a/test/fixtures/cookbooks/test/recipes/single_node.rb b/test/fixtures/cookbooks/test/recipes/single_node.rb index 31979ef2..9b6ed5dc 100644 --- a/test/fixtures/cookbooks/test/recipes/single_node.rb +++ b/test/fixtures/cookbooks/test/recipes/single_node.rb @@ -1,6 +1,5 @@ apt_update 'update' if platform_family?('debian') -node.default['graphite']['version'] = '1.1.6' node.default['graphite']['twisted_version'] = '19.7.0' node.default['graphite']['django_version'] = '1.11.28' From e4ea3c899a3c5e83a79f05c3a8cd9ef03e044c0c Mon Sep 17 00:00:00 2001 From: jtschelling Date: Mon, 3 Aug 2020 14:20:40 -0500 Subject: [PATCH 10/12] update python/graphite/django to latest, inspec testing --- .github/workflows/ci.yml | 1 + resources/python.rb | 2 +- test/fixtures/cookbooks/test/recipes/single_node.rb | 4 ++-- test/integration/default/default_spec.rb | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d89c4c1..74932199 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,7 @@ jobs: - 'debian-10' - 'ubuntu-1604' - 'ubuntu-1804' + - 'ubuntu-2004' - 'centos-7' suite: - 'default' diff --git a/resources/python.rb b/resources/python.rb index 89d4043b..97055dc7 100644 --- a/resources/python.rb +++ b/resources/python.rb @@ -1,5 +1,5 @@ property :pyenv_name, String, name_property: true -property :python_version, String, default: '2.7.17' +property :python_version, String, default: '3.8.5' property :user, String, default: lazy { node['graphite']['user'] } property :graphite_dir, String, default: lazy { node['graphite']['base_dir'] } diff --git a/test/fixtures/cookbooks/test/recipes/single_node.rb b/test/fixtures/cookbooks/test/recipes/single_node.rb index 9b6ed5dc..d3869d34 100644 --- a/test/fixtures/cookbooks/test/recipes/single_node.rb +++ b/test/fixtures/cookbooks/test/recipes/single_node.rb @@ -1,7 +1,7 @@ apt_update 'update' if platform_family?('debian') -node.default['graphite']['twisted_version'] = '19.7.0' -node.default['graphite']['django_version'] = '1.11.28' +node.default['graphite']['twisted_version'] = '19.10.0' +node.default['graphite']['django_version'] = '3.0.9' include_recipe 'graphite::carbon' include_recipe 'graphite::web' diff --git a/test/integration/default/default_spec.rb b/test/integration/default/default_spec.rb index ac1c7ab2..09022adb 100644 --- a/test/integration/default/default_spec.rb +++ b/test/integration/default/default_spec.rb @@ -15,6 +15,6 @@ its('protocols') { should include 'tcp' } end -describe command('curl -fs http://localhost:8080/metrics/find?query=carbon.*') do - its(:exit_status) { should eq(0) } +describe http('http://localhost:8080/metrics/find?query=carbon.*', enable_remote_worker: true) do + its('status') { should cmp 200 } end From b5190c8cc1b945bbb9402d521d62655b6ff1e958 Mon Sep 17 00:00:00 2001 From: jtschelling Date: Mon, 3 Aug 2020 14:32:04 -0500 Subject: [PATCH 11/12] update spec Signed-off-by: jtschelling --- spec/recipes/_web_packages_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/recipes/_web_packages_spec.rb b/spec/recipes/_web_packages_spec.rb index 244a0263..ebdac84b 100644 --- a/spec/recipes/_web_packages_spec.rb +++ b/spec/recipes/_web_packages_spec.rb @@ -19,7 +19,7 @@ it 'installs a specific version of graphite_web python package' do expect(chef_run).to install_pyenv_pip('graphite_web').with( package_name: 'graphite-web', - version: '1.1.3' + version: '1.1.7' ) end end From 2d644d68ab091f8f8748cc78f12c3b23f9a2e4d7 Mon Sep 17 00:00:00 2001 From: jtschelling Date: Wed, 5 Aug 2020 15:52:44 -0500 Subject: [PATCH 12/12] fix installs on python 3.8 Signed-off-by: jtschelling --- CHANGELOG.md | 7 +++++++ test/fixtures/cookbooks/test/recipes/single_node.rb | 2 +- test/integration/default/python_install_spec.rb | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb9a31b8..730455cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. +## 2.0.0 (2020-08-05) + +- Replace poise-python cookbook with sous-chef pyenv cookbook ([#350]) +- Default Python version installed is latest (v3.8.5) +- Default Graphite version installed is latest (v1.1.7) +- Default Django version installed is latest (v3.0.9) + ## 1.3.0 (2020-06-06) - Fix bug with changing a frozen string in ruby 2.7.0 diff --git a/test/fixtures/cookbooks/test/recipes/single_node.rb b/test/fixtures/cookbooks/test/recipes/single_node.rb index d3869d34..af7700c5 100644 --- a/test/fixtures/cookbooks/test/recipes/single_node.rb +++ b/test/fixtures/cookbooks/test/recipes/single_node.rb @@ -48,7 +48,7 @@ base_dir = (node['graphite']['base_dir']).to_s -graphite_web_config "#{base_dir}/webapp/graphite/local_settings.py" do +graphite_web_config "#{base_dir}/lib/python3.8/site-packages/graphite/local_settings.py" do config(secret_key: 'a_very_secret_key_jeah!', time_zone: 'America/Chicago', conf_dir: "#{base_dir}/conf", diff --git a/test/integration/default/python_install_spec.rb b/test/integration/default/python_install_spec.rb index b1d25d4a..50ce0778 100644 --- a/test/integration/default/python_install_spec.rb +++ b/test/integration/default/python_install_spec.rb @@ -8,5 +8,5 @@ end describe command('/opt/graphite/bin/python --version') do - its(:stderr) { should match(/2\.7\.17/) } + its(:stdout) { should match(/3\.8\.5/) } end