Replace application cookbook with git resource
This commit is contained in:
parent
3cf9c3868b
commit
3a5a038f7e
@ -10,6 +10,5 @@ depends 'kosmos-base'
|
||||
depends 'kosmos-nodejs'
|
||||
depends 'kosmos-ipfs'
|
||||
depends 'firewall'
|
||||
depends 'application_javascript'
|
||||
depends 'git'
|
||||
depends 'redisio'
|
||||
|
@ -18,20 +18,17 @@ include_recipe "kosmos-hubot::_user"
|
||||
include_recipe "kosmos-hubot::_nodejs"
|
||||
include_recipe "kosmos-base::firewall"
|
||||
|
||||
application app_path do
|
||||
credentials = Chef::EncryptedDataBagItem.load('credentials', app_name)
|
||||
credentials = Chef::EncryptedDataBagItem.load('credentials', app_name)
|
||||
|
||||
owner app_user
|
||||
group app_group
|
||||
|
||||
git do
|
||||
git app_path do
|
||||
user app_user
|
||||
group app_group
|
||||
repository "https://gitea.kosmos.org/kosmos/botka.git"
|
||||
revision "master"
|
||||
end
|
||||
notifies :restart, "systemd_unit[#{app_name}.service]", :delayed
|
||||
end
|
||||
|
||||
file "#{app_path}/external-scripts.json" do
|
||||
file "#{app_path}/external-scripts.json" do
|
||||
mode "0640"
|
||||
owner app_user
|
||||
group app_group
|
||||
@ -41,28 +38,15 @@ application app_path do
|
||||
"hubot-remotestorage-logger",
|
||||
"hubot-web-push-notifications",
|
||||
].to_json
|
||||
end
|
||||
end
|
||||
|
||||
npm_install do
|
||||
execute "npm install" do
|
||||
cwd app_path
|
||||
environment "HOME" => app_path
|
||||
user app_user
|
||||
end
|
||||
end
|
||||
|
||||
execute "systemctl daemon-reload" do
|
||||
command "systemctl daemon-reload"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
template "/lib/systemd/system/#{app_name}.service" do
|
||||
source 'nodejs.systemd.service.erb'
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
variables(
|
||||
user: app_user,
|
||||
group: app_group,
|
||||
app_dir: app_path,
|
||||
entry: "#{app_path}/bin/hubot -a irc",
|
||||
environment: {
|
||||
service_env = {
|
||||
"HUBOT_LOG_LEVEL" => node.chef_environment == "development" ? "debug" : "info",
|
||||
"HUBOT_IRC_USESSL" => "true",
|
||||
"HUBOT_IRC_SERVER" => credentials["znc_host"],
|
||||
@ -88,15 +72,32 @@ application app_path do
|
||||
"VAPID_SUBJECT" => "https://kosmos.org",
|
||||
"VAPID_PUBLIC_KEY" => credentials['vapid_public_key'],
|
||||
"VAPID_PRIVATE_KEY" => credentials['vapid_private_key']
|
||||
}
|
||||
)
|
||||
notifies :run, "execute[systemctl daemon-reload]", :delayed
|
||||
notifies :restart, "service[#{app_name}]", :delayed
|
||||
end
|
||||
}
|
||||
|
||||
service app_name do
|
||||
action [:enable, :start]
|
||||
end
|
||||
systemd_unit "#{app_name}.service" do
|
||||
content({
|
||||
Unit: {
|
||||
Description: app_name,
|
||||
Requires: "redis@6379.service",
|
||||
After: "redis@6379.service"
|
||||
},
|
||||
|
||||
Service: {
|
||||
ExecStart: "#{app_path}/bin/hubot -a irc",
|
||||
WorkingDirectory: app_path,
|
||||
User: app_user,
|
||||
Group: app_group,
|
||||
Environment: service_env.map { |k, v| "'#{k}=#{v}'" },
|
||||
Restart: 'always'
|
||||
},
|
||||
|
||||
Install: {
|
||||
WantedBy: 'multi-user.target'
|
||||
}
|
||||
})
|
||||
verify false
|
||||
triggers_reload true
|
||||
action [:create, :enable, :start]
|
||||
end
|
||||
|
||||
firewall_rule app_name do
|
||||
|
@ -18,37 +18,36 @@ include_recipe "kosmos-hubot::_user"
|
||||
include_recipe "kosmos-hubot::_nodejs"
|
||||
include_recipe "kosmos-base::firewall"
|
||||
|
||||
application app_path do
|
||||
data_bag = Chef::EncryptedDataBagItem.load('credentials', app_name)
|
||||
data_bag = Chef::EncryptedDataBagItem.load('credentials', app_name)
|
||||
|
||||
owner app_user
|
||||
group app_group
|
||||
|
||||
git do
|
||||
git app_path do
|
||||
user app_user
|
||||
group app_group
|
||||
repository "https://gitea.kosmos.org/kosmos/hal8000.git"
|
||||
revision "master"
|
||||
end
|
||||
notifies :restart, "systemd_unit[#{app_name}.service]", :delayed
|
||||
end
|
||||
|
||||
file "#{app_path}/external-scripts.json" do
|
||||
file "#{app_path}/external-scripts.json" do
|
||||
mode "0640"
|
||||
owner app_user
|
||||
group app_group
|
||||
content node[app_name]['hubot_scripts'].to_json
|
||||
end
|
||||
end
|
||||
|
||||
npm_install do
|
||||
execute "npm install" do
|
||||
cwd app_path
|
||||
environment "HOME" => app_path
|
||||
user app_user
|
||||
end
|
||||
end
|
||||
|
||||
ipfs_host = search(:node, "role:ipfs_gateway").first["knife_zero"]["host"]
|
||||
node.override[app_name]['kredits']['ipfs_host'] = ipfs_host
|
||||
ipfs_host = search(:node, "role:ipfs_gateway").first["knife_zero"]["host"]
|
||||
node.override[app_name]['kredits']['ipfs_host'] = ipfs_host
|
||||
|
||||
rsk_node_ip = search(:node, "role:rskj_testnet").first["knife_zero"]["host"]
|
||||
node.override[app_name]['kredits']['provider_url'] = "http://#{rsk_node_ip}:4444"
|
||||
rsk_node_ip = search(:node, "role:rskj_testnet").first["knife_zero"]["host"]
|
||||
node.override[app_name]['kredits']['provider_url'] = "http://#{rsk_node_ip}:4444"
|
||||
|
||||
file "#{app_path}/node_modules/@kredits/hubot-kredits/.env" do
|
||||
file "#{app_path}/node_modules/@kredits/hubot-kredits/.env" do
|
||||
mode "0600"
|
||||
owner app_user
|
||||
group app_group
|
||||
@ -62,24 +61,13 @@ IPFS_API_PROTOCOL=#{node[app_name]['kredits']['ipfs_protocol']}
|
||||
KREDITS_WALLET_PATH=../../#{node[app_name]['kredits']['wallet_path']}
|
||||
KREDITS_WALLET_PASSWORD=#{data_bag['kredits_wallet_password']}
|
||||
EOF
|
||||
end
|
||||
end
|
||||
|
||||
execute "systemctl daemon-reload" do
|
||||
command "systemctl daemon-reload"
|
||||
action :nothing
|
||||
end
|
||||
cookbook_file "#{app_path}/wallet.json" do
|
||||
source "wallet.json"
|
||||
end
|
||||
|
||||
template "/lib/systemd/system/#{app_name}.service" do
|
||||
source 'nodejs.systemd.service.erb'
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
variables(
|
||||
user: app_user,
|
||||
group: app_user,
|
||||
app_dir: app_path,
|
||||
entry: "#{app_path}/bin/hubot -a xmpp --name hal8000",
|
||||
environment: {
|
||||
service_env = {
|
||||
"HUBOT_LOG_LEVEL" => node.chef_environment == "development" ? "debug" : "info",
|
||||
"HUBOT_XMPP_USERNAME" => "hal8000@kosmos.org/hubot",
|
||||
"HUBOT_XMPP_PASSWORD" => data_bag['xmpp_password'],
|
||||
@ -114,19 +102,32 @@ KREDITS_WALLET_PASSWORD=#{data_bag['kredits_wallet_password']}
|
||||
"KREDITS_GITHUB_SECRET" => data_bag['kredits_github_secret'],
|
||||
"KREDITS_ZOOM_JWT" => data_bag['kredits_zoom_jwt'],
|
||||
"KREDITS_ZOOM_MEETING_WHITELIST" => "414901303,82557072771"
|
||||
}
|
||||
|
||||
systemd_unit "#{app_name}.service" do
|
||||
content({
|
||||
Unit: {
|
||||
Description: app_name,
|
||||
Requires: "redis@6379.service",
|
||||
After: "redis@6379.service"
|
||||
},
|
||||
|
||||
Service: {
|
||||
ExecStart: "#{app_path}/bin/hubot -a xmpp --name hal8000",
|
||||
WorkingDirectory: app_path,
|
||||
User: app_user,
|
||||
Group: app_group,
|
||||
Environment: service_env.map { |k, v| "'#{k}=#{v}'" },
|
||||
Restart: 'always'
|
||||
},
|
||||
|
||||
Install: {
|
||||
WantedBy: 'multi-user.target'
|
||||
}
|
||||
)
|
||||
notifies :run, "execute[systemctl daemon-reload]", :delayed
|
||||
notifies :restart, "service[#{app_name}]", :delayed
|
||||
end
|
||||
|
||||
cookbook_file "#{app_path}/wallet.json" do
|
||||
source "wallet.json"
|
||||
end
|
||||
|
||||
service app_name do
|
||||
action [:enable, :start]
|
||||
end
|
||||
})
|
||||
verify false
|
||||
triggers_reload true
|
||||
action [:create, :enable, :start]
|
||||
end
|
||||
|
||||
firewall_rule app_name do
|
||||
|
@ -1,19 +0,0 @@
|
||||
[Unit]
|
||||
Description=Start nodejs app
|
||||
<% unless @without_redis %>
|
||||
Requires=redis@6379.service
|
||||
After=redis@6379.service
|
||||
<% end %>
|
||||
|
||||
[Service]
|
||||
ExecStart=<%= @entry %>
|
||||
WorkingDirectory=<%= @app_dir %>
|
||||
User=<%= @user %>
|
||||
Group=<%= @group %>
|
||||
<% unless @environment.empty? -%>
|
||||
Environment=<% @environment.each do |key, value| -%>'<%= key %>=<%= value %>' <% end %>
|
||||
<% end -%>
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
x
Reference in New Issue
Block a user