Commit 5755b94709905fe79beea6e52aeb5661319e3dd7

Authored by Antonio Terceiro
2 parents c3b1585e edff114b
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Merge branch 'colab_config'

This merge makes the necessary changes for updated colab packages for
SPB release 4
.gitignore
... ... @@ -12,3 +12,4 @@
12 12 *.swo
13 13 /backups
14 14 /exported_data
  15 +.vagrant
... ...
cookbooks/colab/recipes/default.rb
... ... @@ -11,13 +11,12 @@ if node['platform'] == 'centos'
11 11 end
12 12 end
13 13  
14   -# FIXME should not be needed; colab should depend on the right version of
15   -# colab-deps
16   -package 'colab-deps' do
  14 +package 'colab' do
17 15 action :upgrade
  16 + notifies :restart, 'service[colab]'
18 17 end
19 18  
20   -package 'colab' do
  19 +package 'colab-spb-theme' do
21 20 action :upgrade
22 21 notifies :restart, 'service[colab]'
23 22 end
... ... @@ -44,7 +43,7 @@ execute 'secret-key' do
44 43 f = '/etc/colab/secret.key'
45 44 command "openssl rand -hex 32 -out #{f} && chown root:colab #{f} && chmod 0640 #{f}"
46 45 not_if { File.exists?(f) }
47   - notifies :create, 'template[/etc/colab/settings.yaml]'
  46 + notifies :create, 'template[/etc/colab/settings.d/00-custom_settings.py]'
48 47 end
49 48  
50 49 template '/etc/sysconfig/colab' do
... ... @@ -54,20 +53,21 @@ template '/etc/sysconfig/colab' do
54 53 notifies :restart, 'service[colab]'
55 54 end
56 55  
57   -template '/etc/colab/settings.yaml' do
  56 +template '/etc/colab/settings.d/00-custom_settings.py' do
58 57 owner 'root'
59 58 group 'colab'
60 59 mode 0640
61 60 notifies :restart, 'service[colab]'
62 61 end
63 62  
64   -template '/etc/colab/settings.d/00-database.yaml' do
  63 +template '/etc/colab/settings.d/01-database.py' do
65 64 owner 'root'
66 65 group 'colab'
67 66 mode 0640
68 67 notifies :restart, 'service[colab]'
69 68 end
70 69  
  70 +# Creating a gitlab admin user
71 71 template '/tmp/admin-gitlab.json' do
72 72  
73 73 password = SecureRandom.random_number.to_s
... ... @@ -96,12 +96,40 @@ execute 'create-admin-token-gitlab' do
96 96 user 'git'
97 97 end
98 98  
99   -template '/etc/colab/settings.d/01-apps.yaml' do
  99 +# Adding settings.d files
  100 +template '/etc/colab/settings.d/02-logging.py' do
100 101 owner 'root'
101 102 group 'colab'
102 103 mode 0640
103 104 notifies :restart, 'service[colab]'
  105 +end
104 106  
  107 +template '/etc/colab/settings.d/03-sentry.py' do
  108 + owner 'root'
  109 + group 'colab'
  110 + mode 0640
  111 + notifies :restart, 'service[colab]'
  112 +end
  113 +
  114 +template '/etc/colab/settings.d/04-memcached.py' do
  115 + owner 'root'
  116 + group 'colab'
  117 + mode 0640
  118 + notifies :restart, 'service[colab]'
  119 +end
  120 +
  121 +template '/etc/colab/settings.d/05-celery.py' do
  122 + owner 'root'
  123 + group 'colab'
  124 + mode 0640
  125 + notifies :restart, 'service[colab]'
  126 +end
  127 +
  128 +# Adding plugins for colab
  129 +template '/etc/colab/plugins.d/gitlab.py' do
  130 + owner 'root'
  131 + group 'colab'
  132 + mode 0640
105 133 get_private_token = lambda do
106 134 Dir.chdir '/usr/lib/gitlab' do
107 135 `sudo -u git RAILS_ENV=production bundle exec rails runner \"puts User.find_by_name(\'admin-gitlab\').private_token\"`.strip
... ... @@ -111,22 +139,34 @@ template '/etc/colab/settings.d/01-apps.yaml' do
111 139 variables(
112 140 :get_private_token => get_private_token
113 141 )
  142 +
  143 + notifies :restart, 'service[colab]'
114 144 end
115 145  
116   -template '/etc/colab/settings.d/02-logging.yaml' do
117   - owner 'root'
118   - group 'colab'
119   - mode 0640
  146 +template '/etc/colab/plugins.d/noosfero.py' do
  147 + owner 'root'
  148 + group 'colab'
  149 + mode 0640
120 150 notifies :restart, 'service[colab]'
121 151 end
122 152  
123   -template '/etc/colab/settings.d/03-sentry.yaml' do
124   - owner 'root'
125   - group 'colab'
126   - mode 0640
  153 +template '/etc/colab/plugins.d/spb.py' do
  154 + owner 'root'
  155 + group 'colab'
  156 + mode 0640
  157 + notifies :restart, 'service[colab]'
  158 +end
  159 +
  160 +template '/etc/colab/plugins.d/raven.py' do
  161 + owner 'root'
  162 + group 'colab'
  163 + mode 0640
127 164 notifies :restart, 'service[colab]'
128 165 end
129 166  
  167 +execute 'colab-admin migrate'
  168 +
  169 +# Static files
130 170 directory '/var/lib/colab-assets/spb/' do
131 171 owner 'root'
132 172 group 'root'
... ...
cookbooks/colab/templates/00-custom_settings.py.erb 0 → 100644
... ... @@ -0,0 +1,37 @@
  1 +## Set to false in production
  2 +DEBUG = False
  3 +TEMPLATE_DEBUG = False
  4 +
  5 +## System admins
  6 +ADMINS = [
  7 +<%- node['config']['admins'].each do |admin| %>
  8 + ("<%= admin[0] %>", "<%= admin[1] %>"),
  9 +<% end %>
  10 +]
  11 +
  12 +MANAGERS = ADMINS
  13 +
  14 +# general Django settings
  15 +DEFAULT_FROM_EMAIL = '<%= node['config']['colab_from_address'] %>'
  16 +
  17 +# colab-specific
  18 +COLAB_FROM_ADDRESS = '<%= node['config']['colab_from_address'] %>'
  19 +SERVER_EMAIL = '<%= node['config']['server_email'] %>'
  20 +
  21 +EMAIL_HOST = "localhost"
  22 +EMAIL_PORT = 25
  23 +EMAIL_SUBJECT_PREFIX = "<%= node['config']['email_subject_prefix'] %>"
  24 +
  25 +SECRET_KEY = "<%= File.read('/etc/colab/secret.key').strip %>"
  26 +
  27 +SITE_URL = "<%= node['config']['site_url'] %>"
  28 +
  29 +ALLOWED_HOSTS = ["<%= node['config']['external_hostname'] %>"]
  30 +
  31 +## Disable indexing
  32 +ROBOTS_NOINDEX = False
  33 +
  34 +## Set URL of Colab home
  35 +COLAB_HOME_URL = '/social'
  36 +
  37 +GOOGLE_ANALYTICS_TRACKING_ID = "<%= node['config']['google_analytics_id'] %>"
... ...
cookbooks/colab/templates/00-database.yaml.erb
... ... @@ -1,6 +0,0 @@
1   -DATABASES:
2   - default:
3   - ENGINE: django.db.backends.postgresql_psycopg2
4   - NAME: colab
5   - USER: colab
6   - HOST: <%= node['peers']['database'] %>
cookbooks/colab/templates/01-apps.yaml.erb
... ... @@ -1,7 +0,0 @@
1   -### Colab proxied apps
2   -PROXIED_APPS:
3   - gitlab:
4   - upstream: 'http://<%= node['peers']['integration'] %>:81/gitlab/'
5   - private_token: '<%= @get_private_token.call %>'
6   - noosfero:
7   - upstream: 'http://<%= node['peers']['social'] %>:80/social/'
cookbooks/colab/templates/01-database.py.erb 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +DATABASES = {
  2 + 'default': {
  3 + 'ENGINE': 'django.db.backends.postgresql_psycopg2',
  4 + 'HOST': "<%= node['peers']['database'] %>",
  5 + 'NAME': 'colab',
  6 + 'USER': 'colab'
  7 + }
  8 +}
... ...
cookbooks/colab/templates/02-logging.py.erb 0 → 100644
... ... @@ -0,0 +1,26 @@
  1 +LOGGING = {
  2 + 'loggers': {
  3 + 'revproxy': {
  4 + 'handlers': ['file'],
  5 + 'level': 'ERROR'},
  6 + 'django': {
  7 + 'handlers': ['file'],
  8 + 'level': 'DEBUG'},
  9 + },
  10 + 'version': 1, 'formatters': {
  11 + 'verbose': {
  12 + 'format': '%(asctime)s (%(name)s) %(levelname)s: %(message)s'
  13 + }
  14 + },
  15 + 'disable_existing_loggers': True, 'handlers': {
  16 + 'file': {
  17 + 'level': 'DEBUG',
  18 + 'interval': 24,
  19 + 'backupCount': 7,
  20 + 'encoding': 'UTF-8',
  21 + 'formatter': 'verbose',
  22 + 'class': 'logging.handlers.TimedRotatingFileHandler',
  23 + 'filename': '/var/log/colab/colab.log'
  24 + }
  25 + }
  26 +}
... ...
cookbooks/colab/templates/02-logging.yaml.erb
... ... @@ -1,28 +0,0 @@
1   -LOGGING:
2   - version: 1
3   - disable_existing_loggers: True
4   -
5   - formatters:
6   - verbose:
7   - format: '%(asctime)s (%(name)s) %(levelname)s: %(message)s'
8   -
9   - handlers:
10   - file:
11   - level: DEBUG
12   - class: logging.handlers.TimedRotatingFileHandler
13   - filename: /var/log/colab/colab.log
14   - interval: 24 # 24 hours
15   - backupCount: 7 # keep last 7 backups
16   - encoding: UTF-8
17   - formatter: verbose
18   -
19   - loggers:
20   - django:
21   - handlers:
22   - - file
23   - level: DEBUG
24   -
25   - revproxy:
26   - handlers:
27   - - file
28   - level: ERROR
cookbooks/colab/templates/03-sentry.py.erb 0 → 100644
... ... @@ -0,0 +1 @@
  1 +RAVEN_DSN = "<%= node['config']['raven_dsn'] %>"
... ...
cookbooks/colab/templates/03-sentry.yaml.erb
... ... @@ -1,2 +0,0 @@
1   -
2   -RAVEN_DSN: <%= node['config']['raven_dsn'] %>
cookbooks/colab/templates/04-memcached.py.erb 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +CACHES = {
  2 + 'default': {
  3 + 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
  4 + 'LOCATION': '127.0.0.1:11211',
  5 + }
  6 +}
... ...
cookbooks/colab/templates/05-celery.py.erb 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +BROKER_URL = 'redis://<%= node['peers']['database'] %>:6379/0'
  2 +CELERY_RESULT_BACKEND = 'redis://<%= node['peers']['database'] %>:6379/0'
... ...
cookbooks/colab/templates/gitlab.py.erb 0 → 100644
... ... @@ -0,0 +1,39 @@
  1 +from django.utils.translation import ugettext_lazy as _
  2 +from colab.plugins.utils.menu import colab_url_factory
  3 +
  4 +# Gitlab plugin - Put this in plugins.d/gitlab.py to actiate ##
  5 +
  6 +name = 'colab_gitlab'
  7 +verbose_name = 'Gitlab Plugin'
  8 +
  9 +upstream = 'http://<%= node['peers']['integration'] %>:81/gitlab/'
  10 +
  11 +private_token = '<%= @get_private_token.call %>'
  12 +
  13 +urls = {
  14 + 'include': 'colab_gitlab.urls',
  15 + 'namespace': 'gitlab', # TODO: do not allow to change namespace
  16 + 'prefix': '^gitlab/',
  17 +}
  18 +
  19 +menu_title = _('Development')
  20 +
  21 +url = colab_url_factory('gitlab')
  22 +
  23 +menu_urls = (
  24 + url(display=_('Public Projects'), viewname='gitlab',
  25 + kwargs={'path': 'public/projects'}, auth=False),
  26 + url(display=_('Profile'), viewname='gitlab',
  27 + kwargs={'path': 'profile'}, auth=True),
  28 + url(display=_('New Project'), viewname='gitlab',
  29 + kwargs={'path': 'projects/new'}, auth=True),
  30 + url(display=_('Projects'), viewname='gitlab',
  31 + kwargs={'path': 'dashboard/projects'}, auth=True),
  32 + url(display=_('Groups'), viewname='gitlab',
  33 + kwargs={'path': 'profile/groups'}, auth=True),
  34 + url(display=_('Issues'), viewname='gitlab',
  35 + kwargs={'path': 'dashboard/issues'}, auth=True),
  36 + url(display=_('Merge Requests'), viewname='gitlab',
  37 + kwargs={'path': 'merge_requests'}, auth=True),
  38 +
  39 +)
... ...
cookbooks/colab/templates/noosfero.py.erb 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +from django.utils.translation import ugettext_lazy as _
  2 +from colab.plugins.utils.menu import colab_url_factory
  3 +
  4 +# Noosfero plugin - Put this in plugins.d/noosfero.py to actiate ##
  5 +# from django.utils.translation import ugettext_lazy as _
  6 +# from colab.plugins.utils.menu import colab_url_factory
  7 +
  8 +name = 'colab_noosfero'
  9 +verbose_name = 'Noosfero Plugin'
  10 +
  11 +upstream = 'http://<%= node['peers']['social'] %>:80/social/'
  12 +
  13 +urls = {
  14 + 'include': 'colab_noosfero.urls',
  15 + 'namespace': 'noosfero', # TODO: do not allow to change namespace
  16 + 'prefix': '^social/',
  17 +}
  18 +
  19 +menu_title = _('Social')
  20 +
  21 +url = colab_url_factory('noosfero')
  22 +
  23 +menu_urls = (
  24 + url(display=_('Users'), viewname='noosfero',
  25 + kwargs={'path': 'search/people'}, auth=False),
  26 + url(display=_('Communities'), viewname='noosfero',
  27 + kwargs={'path': 'search/communities'}, auth=False),
  28 + url(display=_('Profile'), viewname='noosfero',
  29 + kwargs={'path': 'profile/~/'}, auth=True),
  30 + url(display=_('Control Panel'), viewname='noosfero',
  31 + kwargs={'path': 'myprofile/~/'}, auth=True),
  32 +
  33 +)
... ...
cookbooks/colab/templates/raven.py.erb 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +
  2 +name = "raven.contrib.django.raven_compat"
  3 +
  4 +middlewares = ['raven.contrib.django.raven_compat.middleware.Sentry404CatchMiddleware']
... ...
cookbooks/colab/templates/settings.yaml.erb
... ... @@ -1,47 +0,0 @@
1   -
2   -## Set to false in production
3   -DEBUG: false
4   -TEMPLATE_DEBUG: false
5   -
6   -## System admins
7   -ADMINS: &admin
8   -<%- node['config']['admins'].each do |admin| %>
9   - -
10   - <%- admin.each do |item| %>
11   - - <%= item %>
12   - <%- end %>
13   -<% end %>
14   -
15   -MANAGERS: *admin
16   -
17   -# general Django settings
18   -DEFAULT_FROM_EMAIL: '<%= node['config']['colab_from_address'] %>'
19   -
20   -# colab-specific
21   -COLAB_FROM_ADDRESS: '<%= node['config']['colab_from_address'] %>'
22   -SERVER_EMAIL: '<%= node['config']['server_email'] %>'
23   -
24   -EMAIL_HOST: localhost
25   -EMAIL_PORT: 25
26   -EMAIL_SUBJECT_PREFIX: <%= node['config']['email_subject_prefix'] %>
27   -
28   -SECRET_KEY: <%= File.read('/etc/colab/secret.key').strip %>
29   -
30   -SITE_URL: <%= node['config']['site_url'] %>
31   -BROWSERID_AUDIENCES:
32   - - <%= node['config']['site_url'].sub('http:', 'https:') %>
33   - - <%= node['config']['site_url'].sub('https:', 'http:') %>
34   -
35   -ALLOWED_HOSTS:
36   - - <%= node['config']['external_hostname'] %>
37   -
38   -## Disable indexing
39   -ROBOTS_NOINDEX: false
40   -
41   -## Disable planet
42   -FEEDZILLA_ENABLED: false
43   -
44   -## Set URL of Colab home
45   -COLAB_HOME_URL: '/social'
46   -
47   -GOOGLE_ANALYTICS_TRACKING_ID: '<%= node['config']['google_analytics_id'] %>'
cookbooks/colab/templates/spb.py.erb 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +from django.utils.translation import ugettext_lazy as _
  2 +from colab.plugins.utils.menu import colab_url_factory
  3 +
  4 +name = "colab_spb"
  5 +verbose_name = "SPB Plugin"
  6 +
  7 +middlewares = ['colab_spb.middleware.ForceLangMiddleware']
  8 +
  9 +urls = {
  10 + "include":"colab_spb.urls",
  11 + "prefix": '^spb/',
  12 + "namespace":"colab_spb"
  13 + }
  14 +
  15 +url = colab_url_factory('colab_spb')
... ...