default.rb
3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
if node['platform'] == 'centos'
cookbook_file '/etc/yum.repos.d/noosfero.repo' do
action :delete
end
end
# FIXME should not be needed. noosfero should depend on the right version
package 'noosfero-deps' do
action :upgrade
end
package 'noosfero' do
action :upgrade
end
template '/etc/noosfero/database.yml' do
owner 'noosfero'
group 'noosfero'
mode '0600'
notifies :restart, 'service[noosfero]'
end
# create DB schema
execute 'noosfero:schema' do
command "RAILS_ENV=production bundle exec rake db:schema:load && RAILS_ENV=production NOOSFERO_DOMAIN=#{node['config']['external_hostname']} bundle exec rake db:data:minimal"
cwd '/usr/lib/noosfero'
user 'noosfero'
not_if "psql -h database -U noosfero --no-align --tuples-only -q -c 'select count(*) from profiles'", :user => 'noosfero'
notifies :restart, 'service[noosfero]'
end
package 'noosfero-spb' do
action :upgrade
end
plugins = [
'breadcrumbs',
'container_block',
'display_content',
'people_block',
'recent_content',
'remote_user',
'organization_ratings',
'statistics',
'sub_organizations',
'video',
'community_block',
]
execute 'plugins:enable' do
command '/usr/lib/noosfero/script/noosfero-plugins enable ' + plugins.join(' ')
end
execute 'noosfero:migrate' do
command 'RAILS_ENV=production SCHEMA=/dev/null bundle exec rake db:migrate'
cwd '/usr/lib/noosfero'
user 'noosfero'
end
execute 'plugins:activate' do
command "RAILS_ENV=production bundle exec rake noosfero:plugins:enable_all"
cwd '/usr/lib/noosfero'
user 'noosfero'
only_if 'bundle exec rake -P | grep enable_all'
end
plugins_spb = [
'software_communities',
'gov_user',
'spb_migrations',
]
#FIXME: We did it, because we have to enable each plugin and migrate it separately.
plugins_spb.each do |plugin|
execute 'plugins_spb:activate' do
command '/usr/lib/noosfero/script/noosfero-plugin enable' + plugin +
' && RAILS_ENV=production SCHEMA=/dev/null bundle exec ' +
'rake db:migrate'
end
end
execute 'theme:enable' do
command 'psql -h database -U noosfero --no-align --tuples-only -q -c "update environments set theme=\'noosfero-spb-theme\' where id=1;"'
end
execute 'software:create_licenses' do
cwd '/usr/lib/noosfero'
command 'sudo -u noosfero bundle exec rake software:create_licenses RAILS_ENV=production'
end
template '/etc/noosfero/unicorn.rb' do
owner 'root'; group 'root'; mode 0644
notifies :restart, 'service[noosfero]'
end
cookbook_file '/etc/default/noosfero' do
owner 'root'; group 'root'; mode 0644
source 'noosfero-default'
notifies :restart, 'service[noosfero]'
end
package 'cronie'
service 'crond' do
action [:enable, :start]
end
service 'noosfero' do
action [:enable, :start]
end
service 'memcached' do
action [:enable, :start]
end
template '/etc/nginx/conf.d/noosfero.conf' do
owner 'root'; group 'root'; mode 0644
source 'nginx.conf.erb'
notifies :restart, 'service[nginx]'
end
cookbook_file '/usr/lib/noosfero/config/noosfero.yml' do
owner 'root'; group 'root'; mode 0644
source 'noosfero.yml'
notifies :restart, 'service[noosfero]'
end
###############################################
# SELinux: permission to access static files noosfero
################################################
cookbook_file '/etc/selinux/local/noosfero.te' do
notifies :run, 'execute[selinux-noosfero]'
end
execute 'selinux-noosfero' do
command 'selinux-install-module /etc/selinux/local/noosfero.te'
action :nothing
end