<commit_before>#
# Cookbook Name:: sentry
# Recipe:: default
#
# Copyright (c) 2013 <NAME> <<EMAIL>>
# 
# MIT.
#<commit_msg>Adds the initial directories, configuration files and install to the recipe.<commit_after>#
# Cookbook Name:: sentry
# Recipe:: default
#
# Copyright (c) 2013 <NAME> <<EMAIL>>
# 
# MIT.
#

include_recipe 'postgres'

# create a user to run the daemon as
user 'sentry' do
  home '/home/sentry'
  shell '/bin/bash'
  comment 'User for handling the Sentry application'
  system true
  supports :manage_home => true

  action :create
end

# create the application directories
directory '/var/www/sentry' do
  owner 'sentry'
  group 'sentry'
  mode '0750'
  recursive true
end

directory '/etc/sentry' do
  owner 'sentry' # should be root by with read ability when configured through here
  group 'sentry'
  mode '0750'
end

# create the postgres user and database
pg_user "#{node['sentry']['database']['user']}" do
  privileges superuser: false, createdb: false, login: true

  password "#{node['sentry']['database']['password']}"
end

pg_database "#{node['sentry']['database']['name']}" do
  owner "#{node['sentry']['database']['user']}"
  encoding 'utf8'
  template 'template0'
  locale 'en_US.UTF8'
end

# create the virtualenv
python_virtualenv '/var/www/sentry' do
  owner 'sentry'
  group 'sentry'
  action :create
end

# install sentry
%w{sentry[postgres]}.each do |pip|
  python_pip pip do
    user 'sentry'
    group 'sentry'
    virtualenv '/var/www/sentry'
  end
end

# set the configuration file
template '/etc/sentry/sentry.conf.py' do
  source 'sentry.conf.py.erb'
  owner 'sentry'
  group 'sentry'
  mode '0770'

  variables(
    'database' => node['sentry']['database'],
    'email' => node['sentry']['email'],
    'secret_key' => ndoe['sentry']['secret_key']
  )
end

# run the sentry migration

# configure the superusers

# configure the web server

# apply the nginx settings

{'fraction_non_alphanumeric': 0.13838120104438642, 'fraction_numerical': 0.012010443864229765, 'mean_word_length': 4.307479224376731, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6494900', 'n_tokens_mistral': 667, 'n_tokens_neox': 647, 'n_words': 201}