# # Cookbook Name:: 5apps-hubot # Recipe:: xmpp_botka # # Copyright 2016, Kosmos # # All rights reserved - Do Not Redistribute # unless node.chef_environment == "development" include_recipe "firewall" firewall_rule 'hubot_express_botka_xmpp' do port 8082 protocol :tcp command :allow end end group "hubot" do gid 48268 end user "hubot" do system true manage_home true comment "hubot user" uid 48268 gid 48268 shell "/bin/bash" end botka_xmpp_data_bag_item = Chef::EncryptedDataBagItem.load('credentials', '5apps_botka_xmpp') botka_xmpp_path = "/opt/botka_xmpp" application botka_xmpp_path do owner "hubot" group "hubot" git do user "hubot" group "hubot" repository "https://github.com/67P/botka.git" revision "master" end file "external-scripts.json" do mode "0640" owner "hubot" group "hubot" content [ "hubot-help", "hubot-remotestorage-logger", ].to_json end npm_install do user "hubot" end execute "systemctl daemon-reload" do command "systemctl daemon-reload" action :nothing end template "/lib/systemd/system/botka_xmpp_nodejs.service" do source 'nodejs.systemd.service.erb' owner 'root' group 'root' mode '0644' variables( user: "hubot", group: "hubot", app_dir: botka_xmpp_path, entry: "#{botka_xmpp_path}/bin/hubot -a xmpp --name botka", environment: { "HUBOT_XMPP_USERNAME" => "botka@5apps.com/hubot", "HUBOT_XMPP_PASSWORD" => botka_xmpp_data_bag_item['password'], "HUBOT_XMPP_ROOMS" => "5info@muc.5apps.com,5ops@muc.5apps.com,core@muc.5apps.com,deploy@muc.5apps.com,storage@muc.5apps.com,watercooler@muc.5apps.com,hilti@muc.5apps.com,gymapp@muc.5apps.com,solarisbank@muc.5apps.com", "HUBOT_XMPP_HOST" => "xmpp.5apps.com", "HUBOT_RSS_PRINTSUMMARY" => "false", "EXPRESS_PORT" => "8082", "HUBOT_RSS_HEADER" => "Update:", "HUBOT_AUTH_ADMIN" => "basti,garret,greg", "REDIS_URL" => "redis://localhost:6379/5apps_botka_xmpp", "RS_LOGGER_USER" => "5apps@5apps.com", "RS_LOGGER_TOKEN" => botka_xmpp_data_bag_item['rs_logger_token'], "RS_LOGGER_SERVER_NAME" => "5apps", "WEBHOOK_TOKEN" => botka_xmpp_data_bag_item['webhook_token'] } ) notifies :run, "execute[systemctl daemon-reload]", :delayed notifies :restart, "service[botka_xmpp_nodejs]", :delayed end service "botka_xmpp_nodejs" do action [:enable, :start] end end