Class: Dolphin::Graylog

Inherits:
Base
  • Object
show all
Defined in:
lib/dolphin/ubuntu/graylog.rb

Overview

graylog related tasks

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Dolphin::Base

Instance Method Details

#srvcObject



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
# File 'lib/dolphin/ubuntu/graylog.rb', line 19

def srvc
  # upload files
  upload("#{@config_root}/graylog/server/*", "/tmp")

  clustername = @env
  networkhost = @vpn_hash[:log]
  unicasthost = @vpn_hash[:ela]
  indexprefix = @env
  mongodbdatabase = "#{@env}-graylog2"
  mongodbreplicaset = @group_hash[:mg].map {|item| "#{@vpn_hash[item]}:27017"}.join(',')

  menu = [
    %{
      # sed -i 's/CLUSTERNAME/#{clustername}/' /tmp/graylog2-elasticsearch.yml
      sed -i 's/NETWORKHOST/#{networkhost}/' /tmp/graylog2-elasticsearch.yml
      sed -i 's/UNICASTHOST/#{unicasthost}/' /tmp/graylog2-elasticsearch.yml
      # sed -i 's/INDEXPREFIX/#{indexprefix}/' /tmp/graylog2.conf
      # sed -i 's/MONGODBREPLICASET/#{mongodbreplicaset}/' /tmp/graylog2.conf
      # sed -i 's/MONGODBDATABASE/#{mongodbdatabase}/' /tmp/graylog2.conf
      sudo mv /tmp/graylog2* /etc
      sudo chown root:root /etc/graylog2*
      sudo mv /tmp/graylog.conf /etc/init/
      sudo chown root:root /etc/init/graylog.conf
      sudo mv /tmp/rails.conf /etc/init/
      sudo chown root:root /etc/init/rails.conf
      sudo restart graylog
    },
  ]

  execute menu
end

#srviObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/dolphin/ubuntu/graylog.rb', line 5

def srvi
  menu = [
    %{
      wget https://github.com/Graylog2/graylog2-server/releases/download/0.13.0-rc.1/graylog2-server-0.13.0-rc.1.tar.gz
      tar xvfz graylog2-server-0.13.0-rc.1.tar.gz
      cd graylog2-server-0.13.0-rc.1
      sudo mv ~/graylog2-server-0.13.0-rc.1 /opt/graylog2-server
    },
  ]

  execute menu
end

#ufwObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/dolphin/ubuntu/graylog.rb', line 52

def ufw
  menu = [
    %{
      # graylog2
      sudo ufw allow from 192.168.0.0/16 to any port 514
      sudo ufw allow from 192.168.0.0/16 to any port 514
      sudo ufw allow from 192.168.0.0/16 to any port 12201

      # elasticsearch ports
      sudo ufw allow from 192.168.0.0/16 to any port 9200
      sudo ufw allow from 192.168.0.0/16 to any port 9300

      # nginx
      sudo ufw allow 'Nginx Full'
      sudo ufw status numbered
    },
  ]

  execute menu
end

#webbObject



127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/dolphin/ubuntu/graylog.rb', line 127

def webb
  menu = [
    %{
      source /usr/local/share/chruby/chruby.sh
      source /usr/local/share/chruby/auto.sh
      cd #{@deploy_dir}
      RAILS_ENV=production bundle exec puma -C #{@deploy_dir}/config/puma.rb
    },
  ]

  execute menu
end

#webcObject



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/dolphin/ubuntu/graylog.rb', line 105

def webc
  # upload files
  upload("#{@config_root}/graylog/nginx/*", "/tmp/")
  upload("#{@config_root}/graylog/rails/*", "#{@app_dir}/graylog2/config/")

  servername = @server_hash[:log]
  menu = [
    %{
      # nginx
      sed -i 's/SERVERNAME/#{servername}/' /tmp/graylog2.conf
      sudo mv /tmp/graylog2.conf /etc/nginx/sites-available/
      sudo rm -f /etc/nginx/sites-enabled/default
      sudo ln -sf /etc/nginx/sites-available/graylog2.conf /etc/nginx/sites-enabled
      sudo service nginx restart
    },
  ]

  execute menu

end

#webiObject



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
# File 'lib/dolphin/ubuntu/graylog.rb', line 74

def webi
  menu = [
    %{
      # web interface
      sudo mkdir #{@app_dir}
      sudo chown #{@user}:#{@user_group} #{@app_dir}
      cd #{@app_dir}
      wget https://github.com/Graylog2/graylog2-web-interface/releases/download/0.12.0/graylog2-web-interface-0.12.0.tar.gz
      tar xvfz graylog2-web-interface-0.12.0.tar.gz
      mv graylog2-web-interface-0.12.0 graylog2
    },
  ]

  execute menu

  # manual steps
  %{
    bin/dolphin setup chruby -t log
    bin/dolphin setup ruby_install -t log
    bin/dolphin setup ruby -t log
    bin/dolphin setup select -t log
    bin/dolphin ubuntu user -t log
    bin/dolphin setup bundler -t log

    # add puma to Gemfile
    sudo bundle install
    # run rake secret
  }
end

#webrObject



155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/dolphin/ubuntu/graylog.rb', line 155

def webr
  menu = [
    %{
      source /usr/local/share/chruby/chruby.sh
      source /usr/local/share/chruby/auto.sh
      cd #{@deploy_dir}
      RAILS_ENV=production bundle exec pumactl -S #{@pids}/#{@application}.state restart
    },
  ]

  execute menu
end

#websObject



141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/dolphin/ubuntu/graylog.rb', line 141

def webs
  menu = [
    %{
      source /usr/local/share/chruby/chruby.sh
      source /usr/local/share/chruby/auto.sh
      cd #{@deploy_dir}
      RAILS_ENV=production bundle exec pumactl -S #{@pids}/#{@application}.state stop
    },
  ]

  execute menu
end