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-nodejs'
|
||||||
depends 'kosmos-ipfs'
|
depends 'kosmos-ipfs'
|
||||||
depends 'firewall'
|
depends 'firewall'
|
||||||
depends 'application_javascript'
|
|
||||||
depends 'git'
|
depends 'git'
|
||||||
depends 'redisio'
|
depends 'redisio'
|
||||||
|
@ -18,20 +18,17 @@ include_recipe "kosmos-hubot::_user"
|
|||||||
include_recipe "kosmos-hubot::_nodejs"
|
include_recipe "kosmos-hubot::_nodejs"
|
||||||
include_recipe "kosmos-base::firewall"
|
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
|
git app_path do
|
||||||
group app_group
|
|
||||||
|
|
||||||
git do
|
|
||||||
user app_user
|
user app_user
|
||||||
group app_group
|
group app_group
|
||||||
repository "https://gitea.kosmos.org/kosmos/botka.git"
|
repository "https://gitea.kosmos.org/kosmos/botka.git"
|
||||||
revision "master"
|
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"
|
mode "0640"
|
||||||
owner app_user
|
owner app_user
|
||||||
group app_group
|
group app_group
|
||||||
@ -41,28 +38,15 @@ application app_path do
|
|||||||
"hubot-remotestorage-logger",
|
"hubot-remotestorage-logger",
|
||||||
"hubot-web-push-notifications",
|
"hubot-web-push-notifications",
|
||||||
].to_json
|
].to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
npm_install do
|
execute "npm install" do
|
||||||
|
cwd app_path
|
||||||
|
environment "HOME" => app_path
|
||||||
user app_user
|
user app_user
|
||||||
end
|
end
|
||||||
|
|
||||||
execute "systemctl daemon-reload" do
|
service_env = {
|
||||||
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: {
|
|
||||||
"HUBOT_LOG_LEVEL" => node.chef_environment == "development" ? "debug" : "info",
|
"HUBOT_LOG_LEVEL" => node.chef_environment == "development" ? "debug" : "info",
|
||||||
"HUBOT_IRC_USESSL" => "true",
|
"HUBOT_IRC_USESSL" => "true",
|
||||||
"HUBOT_IRC_SERVER" => credentials["znc_host"],
|
"HUBOT_IRC_SERVER" => credentials["znc_host"],
|
||||||
@ -88,15 +72,32 @@ application app_path do
|
|||||||
"VAPID_SUBJECT" => "https://kosmos.org",
|
"VAPID_SUBJECT" => "https://kosmos.org",
|
||||||
"VAPID_PUBLIC_KEY" => credentials['vapid_public_key'],
|
"VAPID_PUBLIC_KEY" => credentials['vapid_public_key'],
|
||||||
"VAPID_PRIVATE_KEY" => credentials['vapid_private_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
|
systemd_unit "#{app_name}.service" do
|
||||||
action [:enable, :start]
|
content({
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
firewall_rule app_name do
|
firewall_rule app_name do
|
||||||
|
@ -18,37 +18,36 @@ include_recipe "kosmos-hubot::_user"
|
|||||||
include_recipe "kosmos-hubot::_nodejs"
|
include_recipe "kosmos-hubot::_nodejs"
|
||||||
include_recipe "kosmos-base::firewall"
|
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
|
git app_path do
|
||||||
group app_group
|
|
||||||
|
|
||||||
git do
|
|
||||||
user app_user
|
user app_user
|
||||||
group app_group
|
group app_group
|
||||||
repository "https://gitea.kosmos.org/kosmos/hal8000.git"
|
repository "https://gitea.kosmos.org/kosmos/hal8000.git"
|
||||||
revision "master"
|
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"
|
mode "0640"
|
||||||
owner app_user
|
owner app_user
|
||||||
group app_group
|
group app_group
|
||||||
content node[app_name]['hubot_scripts'].to_json
|
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
|
user app_user
|
||||||
end
|
end
|
||||||
|
|
||||||
ipfs_host = search(:node, "role:ipfs_gateway").first["knife_zero"]["host"]
|
ipfs_host = search(:node, "role:ipfs_gateway").first["knife_zero"]["host"]
|
||||||
node.override[app_name]['kredits']['ipfs_host'] = ipfs_host
|
node.override[app_name]['kredits']['ipfs_host'] = ipfs_host
|
||||||
|
|
||||||
rsk_node_ip = search(:node, "role:rskj_testnet").first["knife_zero"]["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"
|
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"
|
mode "0600"
|
||||||
owner app_user
|
owner app_user
|
||||||
group app_group
|
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_PATH=../../#{node[app_name]['kredits']['wallet_path']}
|
||||||
KREDITS_WALLET_PASSWORD=#{data_bag['kredits_wallet_password']}
|
KREDITS_WALLET_PASSWORD=#{data_bag['kredits_wallet_password']}
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
|
|
||||||
execute "systemctl daemon-reload" do
|
cookbook_file "#{app_path}/wallet.json" do
|
||||||
command "systemctl daemon-reload"
|
source "wallet.json"
|
||||||
action :nothing
|
end
|
||||||
end
|
|
||||||
|
|
||||||
template "/lib/systemd/system/#{app_name}.service" do
|
service_env = {
|
||||||
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: {
|
|
||||||
"HUBOT_LOG_LEVEL" => node.chef_environment == "development" ? "debug" : "info",
|
"HUBOT_LOG_LEVEL" => node.chef_environment == "development" ? "debug" : "info",
|
||||||
"HUBOT_XMPP_USERNAME" => "hal8000@kosmos.org/hubot",
|
"HUBOT_XMPP_USERNAME" => "hal8000@kosmos.org/hubot",
|
||||||
"HUBOT_XMPP_PASSWORD" => data_bag['xmpp_password'],
|
"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_GITHUB_SECRET" => data_bag['kredits_github_secret'],
|
||||||
"KREDITS_ZOOM_JWT" => data_bag['kredits_zoom_jwt'],
|
"KREDITS_ZOOM_JWT" => data_bag['kredits_zoom_jwt'],
|
||||||
"KREDITS_ZOOM_MEETING_WHITELIST" => "414901303,82557072771"
|
"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
|
verify false
|
||||||
notifies :restart, "service[#{app_name}]", :delayed
|
triggers_reload true
|
||||||
end
|
action [:create, :enable, :start]
|
||||||
|
|
||||||
cookbook_file "#{app_path}/wallet.json" do
|
|
||||||
source "wallet.json"
|
|
||||||
end
|
|
||||||
|
|
||||||
service app_name do
|
|
||||||
action [:enable, :start]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
firewall_rule app_name do
|
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