Skip to content

Commit

Permalink
WIP to install, configure and run mesos
Browse files Browse the repository at this point in the history
  • Loading branch information
dazza-codes committed Sep 22, 2017
1 parent 6a668fa commit 4b5c3eb
Show file tree
Hide file tree
Showing 8 changed files with 378 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/settings/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ aws:
availability_zone: us-west-2b # need one node in each zone

test_mesos_agent3:
<<: *MesosMasterDefaults
<<: *MesosAgentDefaults
tag_name: test_mesos_agent3
availability_zone: us-west-2c # need one node in each zone

Expand Down
65 changes: 65 additions & 0 deletions lib/mesos/mesos_agent_configure.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
require_relative 'mesos_agent_helpers'

namespace :mesos_agent do
namespace :service do
MESOS_HOME_DEFAULT = '/opt/mesos_agent'.freeze

def mesos_agent_home
host_settings['mesos_agent_home'] || MESOS_HOME_DEFAULT
end

def mesos_agent_ver
settings = host_settings
[
settings['scala_version'] || '2.11',
settings['mesos_agent_version '] || '0.11.0.0'
].join(' ')
end

def zookeeper_connections
ZookeeperHelpers.connections.join(',')
end

###############################
# Configuration notes
#
# Modify the `server.properties` file in each broker:
# - the broker.id should be unique for each broker
# - the zookeeper.connect should be set to point to the same
# ZooKeeper instances
# - for multiple ZooKeeper instances, the zookeeper.connect should be a
# comma-separated string listing the IP addresses and port numbers
# of all the ZooKeeper instances.

desc 'Configure service'
task :configure do
# on roles(:mesos_agent), in: :parallel do |host|
# # Replace the content in ${MESOS_HOME}/config/server.properties
# config_file = capture("ls #{mesos_agent_home}/config/server.properties")
#
# # Set broker.id
# broker_id = host_settings['broker_id']
# sudo("sed -i -e 's/broker.id=.*/broker.id=#{broker_id}/' #{config_file}")
#
# # Set zookeeper.connect
# zoo_connect = "zookeeper.connect=#{zookeeper_connections}"
# sudo("sed -i -e 's/zookeeper.connect=.*/#{zoo_connect}/' #{config_file}")
#
# # Setup the /etc/hosts file for zookeeper nodes, using private IPs
# etc_hosts_new = ZookeeperHelpers.manager.etc_hosts(false) # use private IPs
# # remove any existing server entries in /etc/hosts
# sudo("sed -i -e '/BEGIN_ZOO_SERVERS/,/END_ZOO_SERVERS/{ d; }' /etc/hosts")
# # append new entries to the /etc/hosts file (one line at a time)
# sudo("echo '### BEGIN_ZOO_SERVERS' | sudo tee -a /etc/hosts > /dev/null")
# # append new entries to the /etc/hosts file (one line at a time)
# etc_hosts_new.each do |etc_host|
# sudo("echo '#{etc_host}' | sudo tee -a /etc/hosts > /dev/null")
# end
# sudo("echo '### END_ZOO_SERVERS' | sudo tee -a /etc/hosts > /dev/null")
#
# # TODO: advertised.listeners=PLAINTEXT://your.host.name:9092
# end
end
end
end

18 changes: 18 additions & 0 deletions lib/mesos/mesos_agent_helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

# Utilities for working with Mesos
module MesosAgentHelpers

module_function

SERVICE = 'mesos_agent'.freeze

def settings
@settings ||= ServiceSettings.new SERVICE
end

def manager
@manager ||= ServiceManager.new SERVICE
end

end

43 changes: 43 additions & 0 deletions lib/mesos/mesos_agent_install.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require_relative 'mesos_agent_helpers'

namespace :mesos_agent do
namespace :service do
MESOS_HOME_DEFAULT = '/opt/mesos_agent'.freeze

def mesos_agent_home
host_settings['mesos_agent_home'] || MESOS_HOME_DEFAULT
end

def mesos_agent_ver
settings = host_settings
[
settings['scala_version'] || '2.11',
settings['mesos_agent_version '] || '0.11.0.0'
].join(' ')
end

def zookeeper_connections
ZookeeperHelpers.connections.join(',')
end

desc 'Install service'
task :install do
# on roles(:mesos_agent), in: :parallel do |host|
# # PuppetHelpers.puppet_apply('mesos_agent.pp')
# # Set or update the system ENV for MESOS_HOME and the PATH
# # The mesos_agent_bin.sh script should install into the MESOS_HOME directory;
# # if 'MESOS_HOME=/opt/mesos_agent', then it should install
# # /opt/mesos_agent sym-linked to /opt/mesos_agent_{SCALA_VER}-{MESOS-VER}
# sudo("sed -i -e '/export MESOS_HOME/d' /etc/profile.d/mesos_agent.sh > /dev/null 2>&1 || true")
# sudo("echo 'export MESOS_HOME=#{mesos_agent_home}' | sudo tee -a /etc/profile.d/mesos_agent.sh")
# sudo("sed -i -e '/export PATH/d' /etc/profile.d/mesos_agent.sh > /dev/null 2>&1 || true")
# sudo("echo 'export PATH=${PATH}:#{mesos_agent_home}/bin' | sudo tee -a /etc/profile.d/mesos_agent.sh")
# # Set the scala/mesos_agent version to install and do it, check dependencies
# sudo("#{current_path}/lib/bash/debian/java_oracle_license.sh > #{current_path}/log/bash_java_oracle_license.log")
# sudo("#{current_path}/lib/bash/debian/java_8_oracle.sh > #{current_path}/log/bash_java_8_oracle.log")
# sudo("#{current_path}/lib/bash/debian/mesos_agent_bin.sh #{mesos_agent_ver} > #{current_path}/log/bash_mesos_agent_bin.log")
# end
end
end
end

48 changes: 48 additions & 0 deletions lib/mesos/mesos_agent_nodes.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require_relative 'mesos_agent_helpers'

namespace :mesos_agent do
namespace :nodes do
desc 'List settings in this project'
task :check_settings do
MesosAgentHelpers.settings.nodes.each do |params|
puts JSON.pretty_generate(JSON.parse(params.to_json))
end
end

desc 'Create nodes'
task :create do
MesosAgentHelpers.manager.create_nodes
end

desc 'Terminate nodes'
task :terminate do
MesosAgentHelpers.manager.terminate_nodes
end

desc 'Find and describe all nodes'
task :find do
MesosAgentHelpers.manager.describe_nodes
end

desc 'Compose public entries for ~/.ssh/config for nodes'
task :ssh_config_public do
puts MesosAgentHelpers.manager.ssh_config
end

desc 'Compose private entries for ~/.ssh/config for nodes'
task :ssh_config_private do
puts MesosAgentHelpers.manager.ssh_config(false)
end

desc 'Compose entries for /etc/hosts using public IPs'
task :etc_hosts_public do
puts MesosAgentHelpers.manager.etc_hosts.join("\n")
end

desc 'Compose entries for /etc/hosts using private IPs'
task :etc_hosts_private do
puts MesosAgentHelpers.manager.etc_hosts(false).join("\n")
end
end
end

29 changes: 29 additions & 0 deletions lib/mesos/mesos_agent_service.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require_relative 'mesos_agent_helpers'

namespace :mesos_agent do
namespace :service do
desc 'Start service'
task :start do
# on roles(:mesos_agent) do |host|
# # Does this command need to use an absolute path to use the default server.properties?
# sudo("#{mesos_agent_home}/bin/mesos_agent-server-start.sh -daemon #{mesos_agent_home}/config/server.properties")
# end
end

# desc 'Status of service'
# task :status do
# on roles(:mesos_agent) do |host|
# sudo('service mesos_agent status')
# end
# end

desc 'Stop service'
task :stop do
# on roles(:mesos_agent) do |host|
# # Ignore the exit(1) status when it's not running already
# sudo("#{mesos_agent_home}/bin/mesos_agent-server-stop.sh || true")
# end
end
end
end

156 changes: 156 additions & 0 deletions lib/mesos/mesos_master.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
require_relative 'mesos_master_helpers'

namespace :mesos_master do
namespace :nodes do
desc 'List settings in this project'
task :check_settings do
MesosMasterHelpers.settings.nodes.each do |params|
puts JSON.pretty_generate(JSON.parse(params.to_json))
end
end

desc 'Create nodes'
task :create do
MesosMasterHelpers.manager.create_nodes
end

desc 'Terminate nodes'
task :terminate do
MesosMasterHelpers.manager.terminate_nodes
end

desc 'Find and describe all nodes'
task :find do
MesosMasterHelpers.manager.describe_nodes
end

desc 'Compose public entries for ~/.ssh/config for nodes'
task :ssh_config_public do
puts MesosMasterHelpers.manager.ssh_config
end

desc 'Compose private entries for ~/.ssh/config for nodes'
task :ssh_config_private do
puts MesosMasterHelpers.manager.ssh_config(false)
end

desc 'Compose entries for /etc/hosts using public IPs'
task :etc_hosts_public do
puts MesosMasterHelpers.manager.etc_hosts.join("\n")
end

desc 'Compose entries for /etc/hosts using private IPs'
task :etc_hosts_private do
puts MesosMasterHelpers.manager.etc_hosts(false).join("\n")
end
end

namespace :service do
MESOS_HOME_DEFAULT = '/opt/mesos_master'.freeze

def host_settings
# the `host` object is accessible to this method
Settings.aws[host.hostname]
end

def mesos_master_home
host_settings['mesos_master_home'] || MESOS_HOME_DEFAULT
end

def mesos_master_ver
settings = host_settings
[
settings['scala_version'] || '2.11',
settings['mesos_master_version '] || '0.11.0.0'
].join(' ')
end

def zookeeper_connections
ZookeeperHelpers.connections.join(',')
end

desc 'Install MesosMaster service'
task :install do
# on roles(:mesos_master), in: :parallel do |host|
# # PuppetHelpers.puppet_apply('mesos_master.pp')
# # Set or update the system ENV for MESOS_HOME and the PATH
# # The mesos_master_bin.sh script should install into the MESOS_HOME directory;
# # if 'MESOS_HOME=/opt/mesos_master', then it should install
# # /opt/mesos_master sym-linked to /opt/mesos_master_{SCALA_VER}-{MESOS-VER}
# sudo("sed -i -e '/export MESOS_HOME/d' /etc/profile.d/mesos_master.sh > /dev/null 2>&1 || true")
# sudo("echo 'export MESOS_HOME=#{mesos_master_home}' | sudo tee -a /etc/profile.d/mesos_master.sh")
# sudo("sed -i -e '/export PATH/d' /etc/profile.d/mesos_master.sh > /dev/null 2>&1 || true")
# sudo("echo 'export PATH=${PATH}:#{mesos_master_home}/bin' | sudo tee -a /etc/profile.d/mesos_master.sh")
# # Set the scala/mesos_master version to install and do it, check dependencies
# sudo("#{current_path}/lib/bash/debian/java_oracle_license.sh > #{current_path}/log/bash_java_oracle_license.log")
# sudo("#{current_path}/lib/bash/debian/java_8_oracle.sh > #{current_path}/log/bash_java_8_oracle.log")
# sudo("#{current_path}/lib/bash/debian/mesos_master_bin.sh #{mesos_master_ver} > #{current_path}/log/bash_mesos_master_bin.log")
# end
end

###############################
# Configuration notes
#
# Modify the `server.properties` file in each broker:
# - the broker.id should be unique for each broker
# - the zookeeper.connect should be set to point to the same
# ZooKeeper instances
# - for multiple ZooKeeper instances, the zookeeper.connect should be a
# comma-separated string listing the IP addresses and port numbers
# of all the ZooKeeper instances.

desc 'Configure MesosMaster service'
task :configure do
# on roles(:mesos_master), in: :parallel do |host|
# # Replace the content in ${MESOS_HOME}/config/server.properties
# config_file = capture("ls #{mesos_master_home}/config/server.properties")
#
# # Set broker.id
# broker_id = host_settings['broker_id']
# sudo("sed -i -e 's/broker.id=.*/broker.id=#{broker_id}/' #{config_file}")
#
# # Set zookeeper.connect
# zoo_connect = "zookeeper.connect=#{zookeeper_connections}"
# sudo("sed -i -e 's/zookeeper.connect=.*/#{zoo_connect}/' #{config_file}")
#
# # Setup the /etc/hosts file for zookeeper nodes, using private IPs
# etc_hosts_new = ZookeeperHelpers.manager.etc_hosts(false) # use private IPs
# # remove any existing server entries in /etc/hosts
# sudo("sed -i -e '/BEGIN_ZOO_SERVERS/,/END_ZOO_SERVERS/{ d; }' /etc/hosts")
# # append new entries to the /etc/hosts file (one line at a time)
# sudo("echo '### BEGIN_ZOO_SERVERS' | sudo tee -a /etc/hosts > /dev/null")
# # append new entries to the /etc/hosts file (one line at a time)
# etc_hosts_new.each do |etc_host|
# sudo("echo '#{etc_host}' | sudo tee -a /etc/hosts > /dev/null")
# end
# sudo("echo '### END_ZOO_SERVERS' | sudo tee -a /etc/hosts > /dev/null")
#
# # TODO: advertised.listeners=PLAINTEXT://your.host.name:9092
# end
end

desc 'Start MesosMaster service'
task :start do
# on roles(:mesos_master) do |host|
# # Does this command need to use an absolute path to use the default server.properties?
# sudo("#{mesos_master_home}/bin/mesos_master-server-start.sh -daemon #{mesos_master_home}/config/server.properties")
# end
end

# desc 'Status of MesosMaster service'
# task :status do
# on roles(:mesos_master) do |host|
# sudo('service mesos_master status')
# end
# end

desc 'Stop MesosMaster service'
task :stop do
# on roles(:mesos_master) do |host|
# # Ignore the exit(1) status when it's not running already
# sudo("#{mesos_master_home}/bin/mesos_master-server-stop.sh || true")
# end
end
end
end

18 changes: 18 additions & 0 deletions lib/mesos/mesos_master_helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

# Utilities for working with Mesos
module MesosMasterHelpers

module_function

SERVICE = 'mesos_master'.freeze

def settings
@settings ||= ServiceSettings.new SERVICE
end

def manager
@manager ||= ServiceManager.new SERVICE
end

end

0 comments on commit 4b5c3eb

Please sign in to comment.