Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use pyenv cookbook instead of poise for python install/usage #350

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ jobs:
strategy:
matrix:
os:
- 'amazonlinux'
- 'amazonlinux-2'
- 'debian-8'
- 'debian-9'
- 'debian-10'
- 'ubuntu-1604'
- 'ubuntu-1804'
- 'ubuntu-2004'
- 'centos-7'
suite:
- 'default'
Expand Down
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

All notable changes to this project will be documented in this file.

## Unreleased
## 2.0.0 (2020-08-05)

- resolved cookstyle error: libraries/provider_carbon_conf_accumulator.rb:37:7 refactor: `ChefModernize/ActionMethodInResource`
- resolved cookstyle error: libraries/provider_storage_conf_accumulator.rb:37:7 refactor: `ChefModernize/ActionMethodInResource`
- Fix frozen method error in libraries/chef_graphite_carbon_config_converter.rb
- 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)

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of

### Cookbooks

- poise-python
- pyenv

## Attributes

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = ''
Expand Down Expand Up @@ -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
[]
Expand Down
1 change: 0 additions & 1 deletion attributes/uwsgi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Author

@jtschelling jtschelling May 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a cleanup as i was thinking about the systemd portions of the cookbook, its not used anywhere. should i remove the change?

default['graphite']['uwsgi']['buffer-size'] = '4096'
20 changes: 11 additions & 9 deletions kitchen.dokken.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,21 @@ verifier:
name: inspec

platforms:
- name: amazonlinux
driver:
image: dokken/amazonlinux
pid_one_command: /sbin/init

- name: amazonlinux-2
driver:
image: dokken/amazonlinux-2
pid_one_command: /usr/lib/systemd/systemd

- name: debian-8
- name: debian-9
driver:
image: dokken/debian-8
image: dokken/debian-9
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update

- name: debian-9
- name: debian-10
driver:
image: dokken/debian-9
image: dokken/debian-10
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
Expand All @@ -58,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
9 changes: 3 additions & 6 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,20 @@ verifier:
name: inspec

platforms:
- name: amazonlinux
driver_config:
box: mvbcoding/awslinux
- name: amazonlinux-2
- name: centos-7
- name: debian-8
- name: debian-9
- name: ubuntu-14.04
- name: debian-10
- name: ubuntu-16.04
- name: ubuntu-18.04
ramereth marked this conversation as resolved.
Show resolved Hide resolved
- name: ubuntu-20.04

suites:
- name: default
run_list:
- recipe[test::single_node]
attributes:
graphite:
listen_port: "8080"
uwsgi:
workers: 4
listen_http: true
16 changes: 7 additions & 9 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
license 'Apache-2.0'
description 'Installs/Configures graphite'

version '1.3.0'
version '2.0.0'
ramereth marked this conversation as resolved.
Show resolved Hide resolved

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 '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'
chef_version '>= 13'
chef_version '>= 14'
ramereth marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 7 additions & 8 deletions recipes/_carbon_packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions recipes/_directories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
20 changes: 9 additions & 11 deletions recipes/_web_packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,28 @@

package Array(node['graphite']['system_packages'])

python_package 'django' do
pyenv_pip 'django' do
virtualenv node['graphite']['base_dir']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have a library helper we should use that in the resource instead of using node attributes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm kind of unclear on what you're asking, are you saying setting the virtualenv as a library helper and then remove setting all the virtualenv properties when using the pyenv_pip resources? Or are you saying using use a library helper to get the node attribute?

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
19 changes: 2 additions & 17 deletions recipes/carbon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,10 @@
# limitations under the License.
#

python_runtime 'carbons_python' do
provider :system
version '2.7'
options pip_version: true
end

include_recipe 'graphite::_user'
ramereth marked this conversation as resolved.
Show resolved Hide resolved
include_recipe 'graphite::_directories'

directory node['graphite']['base_dir'] do
owner node['graphite']['user']
group node['graphite']['group']
end

python_virtualenv node['graphite']['base_dir'] do
user node['graphite']['user']
group node['graphite']['group']
end
graphite_python 'carbons_python'

include_recipe 'graphite::_user'
include_recipe 'graphite::_carbon_packages'
include_recipe 'graphite::_directories'
include_recipe 'graphite::_carbon_config'
11 changes: 3 additions & 8 deletions recipes/web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@
# limitations under the License.
#

python_runtime 'webs_python' do
provider :system
version '2.7'
options pip_version: true
end
include_recipe 'graphite::_user'
include_recipe 'graphite::_directories'

python_virtualenv node['graphite']['base_dir']
graphite_python 'webs_python'

include_recipe 'graphite::_user'
include_recipe 'graphite::_web_packages'
include_recipe 'graphite::_directories'

basedir = node['graphite']['base_dir']
docroot = node['graphite']['doc_root']
Expand Down
10 changes: 3 additions & 7 deletions resources/carbon_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Copy link
Author

@jtschelling jtschelling May 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is some ruby/chef patterns that I don't really understand, please let me know what this is doing and how I can emulate this in my changes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is “just” collecting all the attributes and sending them though. It’s a little terse, and hard to read. So I’m with you here and write something easier to read.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so its another way to set the properties here? if install_options was set in the backend_attributes would it overwrite the --no-binary=:all: property below this? keeping that in mind for how I want to fix this

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

Expand Down
27 changes: 27 additions & 0 deletions resources/python.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
property :pyenv_name, String, name_property: true
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'] }

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
12 changes: 6 additions & 6 deletions resources/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/recipes/_carbon_package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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_graphite_python('carbons_python')
end
end
Loading