Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Massive find-and-replace for slave to agent (so very breaking)
Browse files Browse the repository at this point in the history
  • Loading branch information
eherot authored and jeffbyrnes committed Jan 21, 2016
1 parent ed9a172 commit 3438647
Show file tree
Hide file tree
Showing 21 changed files with 184 additions and 184 deletions.
24 changes: 12 additions & 12 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ suites:
- 10.0.0.1
- 10.0.0.2
- 10.0.0.3
slave_ips:
agent_ips:
- 10.0.0.4
- 10.0.0.5
- 10.0.0.6

- name: mesosphere_slave
- name: mesosphere_agent
run_list:
# master recipe is only for asserting mesos-slave healthy startup.
# master recipe is only for asserting mesos-agent healthy startup.
- recipe[et_mesos::master]
- recipe[et_mesos::slave]
- recipe[et_mesos::agent]
attributes:
et_mesos:
type: mesosphere
slave:
agent:
attributes:
rackid: us-east-1b
master: 'zk://localhost:2181/mesos'
Expand All @@ -66,7 +66,7 @@ suites:
- 10.0.0.1
- 10.0.0.2
- 10.0.0.3
slave_ips:
agent_ips:
- 10.0.0.4
- 10.0.0.5
- 10.0.0.6
Expand All @@ -86,24 +86,24 @@ suites:
- 10.0.0.1
- 10.0.0.2
- 10.0.0.3
slave_ips:
agent_ips:
- 10.0.0.4
- 10.0.0.5
- 10.0.0.6

- name: source_slave
- name: source_agent
run_list:
# master recipe is only for asserting mesos-slave healthy startup.
# master recipe is only for asserting mesos-agent healthy startup.
- recipe[et_mesos::master]
- recipe[et_mesos::slave]
- recipe[et_mesos::agent]
attributes:
et_mesos:
type: source
master:
zk: 'zk://localhost:2181/mesos'
ip: 127.0.0.1
quorum: 1
slave:
agent:
attributes:
rackid: us-east-1b
master: 127.0.0.1:5050
Expand All @@ -112,7 +112,7 @@ suites:
- 10.0.0.1
- 10.0.0.2
- 10.0.0.3
slave_ips:
agent_ips:
- 10.0.0.4
- 10.0.0.5
- 10.0.0.6
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mesos Cookbook [![Build Status](https://travis-ci.org/evertrue/mesos-cookbook.png?branch=master)](https://travis-ci.org/evertrue/mesos-cookbook)

Install Mesos (<http://mesos.apache.org/>) and configure mesos master and slave.
Install Mesos (<http://mesos.apache.org/>) and configure mesos master and agent.
This cookbook also supports installation by both bulding from source and with [Mesosphere](http://mesosphere.io) package.
You can switch installation type using the `node[:et_mesos][:type]` attribute (`source` or `mesosphere`).

Expand Down Expand Up @@ -41,7 +41,7 @@ Configure master and cluster deployment configuration files, and start
`mesos-master`.

* `node[:et_mesos][:deploy_dir]/masters`
* `node[:et_mesos][:deploy_dir]/slaves`
* `node[:et_mesos][:deploy_dir]/agents`
* `node[:et_mesos][:deploy_dir]/mesos-deploy-env.sh`
* `node[:et_mesos][:deploy_dir]/mesos-master-env.sh`

Expand Down Expand Up @@ -75,25 +75,25 @@ mesos-master --zk=zk://localhost:2181/mesos --port=5050 --log_dir=/var/log/mesos

See the [latest Mesos config docs](http://mesos.apache.org/documentation/latest/configuration/) for available options or the output of `mesos-master --help`.

### et_mesos::slave
### et_mesos::agent

Configure slave configuration files, and start `mesos-slave`.
Configure agent configuration files, and start `mesos-agent`.

* `node[:et_mesos][:deploy_dir]/mesos-slave-env.sh`
* `node[:et_mesos][:deploy_dir]/mesos-agent-env.sh`

Furthermore, this recipe also configures upstart configuration files.

* `/etc/mesos/zk`
* `/etc/defaults/mesos`
* `/etc/defaults/mesos-slave`
* `/etc/defaults/mesos-agent`

#### How to configure `mesos-slave`
#### How to configure `mesos-agent`

You can configure `mesos-slave` command line options by `node[:et_mesos][:slave]` hash.
You can configure `mesos-agent` command line options by `node[:et_mesos][:agent]` hash.
If you have a configuration as shown below:

```
node[:et_mesos][:slave] = {
node[:et_mesos][:agent] = {
master: 'zk://localhost:2181/mesos',
log_dir: '/var/log/mesos',
containerizers: 'docker,mesos',
Expand All @@ -102,19 +102,19 @@ node[:et_mesos][:slave] = {
}
```

Then `mesos-slave` will be invoked with command line options like this:
Then `mesos-agent` will be invoked with command line options like this:

```
mesos-slave --master=zk://localhost:2181/mesos --log_dir=/var/log/mesos --containerizers=docker,mesos --isolation=cgroups/cpu,cgroups/mem --work_dir=/var/run/work
mesos-agent --master=zk://localhost:2181/mesos --log_dir=/var/log/mesos --containerizers=docker,mesos --isolation=cgroups/cpu,cgroups/mem --work_dir=/var/run/work
```

See the [latest Mesos config docs](http://mesos.apache.org/documentation/latest/configuration/) for available options or the output of `mesos-slave --help`.
See the [latest Mesos config docs](http://mesos.apache.org/documentation/latest/configuration/) for available options or the output of `mesos-agent --help`.

## Usage

Wrap this cookbook, setting the `node[:et_mesos][:type]` attribute as appropriate for your installation, and `include_recipe 'et_mesos::master'` or `include_recipe 'et_mesos::slave'`, depending on what part of the cluster you need to provision.
Wrap this cookbook, setting the `node[:et_mesos][:type]` attribute as appropriate for your installation, and `include_recipe 'et_mesos::master'` or `include_recipe 'et_mesos::agent'`, depending on what part of the cluster you need to provision.

The recommendation would be to have two wrapper cookbooks, one for the master(s), and another for your slave(s).
The recommendation would be to have two wrapper cookbooks, one for the master(s), and another for your agent(s).

## Attributes

Expand Down Expand Up @@ -186,9 +186,9 @@ The recommendation would be to have two wrapper cookbooks, one for the master(s)
<td>[ ]</td>
</tr>
<tr>
<td><tt>[:et_mesos][:slave_ips]</tt></td>
<td><tt>[:et_mesos][:agent_ips]</tt></td>
<td>Array of String</td>
<td>IP list of slaves used in <tt>mesos-[start|stop]-cluster</tt></td>
<td>IP list of agents used in <tt>mesos-[start|stop]-cluster</tt></td>
<td>[ ]</td>
</tr>
<tr>
Expand Down Expand Up @@ -219,15 +219,15 @@ The recommendation would be to have two wrapper cookbooks, one for the master(s)
<td></td>
</tr>
<tr>
<td><tt>[:et_mesos][:slave][:master]</tt></td>
<td><tt>[:et_mesos][:agent][:master]</tt></td>
<td>String</td>
<td>[REQUIRED] mesos master url.This should be ip:port for non-ZooKeeper based masters, otherwise a zk:// . when <tt>mesosphere</tt>, you should set zk:// address. </td>
<td></td>
</tr>
<tr>
<td><tt>[:et_mesos][:slave][:option_name]</tt></td>
<td><tt>[:et_mesos][:agent][:option_name]</tt></td>
<td>String</td>
<td>Like <tt>[:et_mesos][:master][:option_name]</tt> above, arbitrary options may be specified as a key for a slave by replacing `option_name` with your option’s key.</td>
<td>Like <tt>[:et_mesos][:master][:option_name]</tt> above, arbitrary options may be specified as a key for a agent by replacing `option_name` with your option’s key.</td>
<td></td>
</tr>
</table>
Expand All @@ -239,7 +239,7 @@ There are a couple of test suites in place:
* `chefspec` for unit tests.
* `test-kitchen` with `serverspec` for integration tests (using `vagrant`).

These test both `source` and `mesosphere` type installations (using both the `master` and `slave` recipes).
These test both `source` and `mesosphere` type installations (using both the `master` and `agent` recipes).

## Contributing

Expand Down
10 changes: 5 additions & 5 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
default['et_mesos']['deploy_with_sudo'] = '1'
default['et_mesos']['deploy_dir'] = '/usr/etc/mesos'
default['et_mesos']['master_ips'] = []
default['et_mesos']['slave_ips'] = []
default['et_mesos']['agent_ips'] = []

default['et_mesos']['mesosphere']['with_zookeeper'] = false

Expand All @@ -17,11 +17,11 @@
default['et_mesos']['master']['work_dir'] = '/tmp/mesos'
default['et_mesos']['master']['port'] = '5050'

default['et_mesos']['slave']['log_dir'] = '/var/log/mesos'
default['et_mesos']['slave']['work_dir'] = '/tmp/mesos'
default['et_mesos']['slave']['isolation'] = 'cgroups/cpu,cgroups/mem'
default['et_mesos']['agent']['log_dir'] = '/var/log/mesos'
default['et_mesos']['agent']['work_dir'] = '/tmp/mesos'
default['et_mesos']['agent']['isolation'] = 'cgroups/cpu,cgroups/mem'

default['et_mesos']['slave']['cgroups_hierarchy'] = value_for_platform(
default['et_mesos']['agent']['cgroups_hierarchy'] = value_for_platform(
'centos' => {
'default' => '/cgroup'
},
Expand Down
10 changes: 5 additions & 5 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
recipe 'et_mesos::mesosphere', 'install mesos from mesosphere package.'
recipe 'et_mesos::source', 'install mesos from source(default recipe).'
recipe 'et_mesos::master', 'configure the machine as master.'
recipe 'et_mesos::slave', 'configure the machine as slave.'
recipe 'et_mesos::agent', 'configure the machine as agent.'

depends 'java', '~> 1.35'
depends 'python', '~> 1.4'
Expand All @@ -27,7 +27,7 @@
suggests 'zookeeper'

attribute 'et_mesos/type',
recipes: ['et_mesos::source', 'et_mesos::mesosphere', 'et_mesos::master', 'et_mesos::slave'],
recipes: ['et_mesos::source', 'et_mesos::mesosphere', 'et_mesos::master', 'et_mesos::agent'],
display_name: 'installation type',
description: "Value should be 'source' | 'mesosphere'.",
default: 'source'
Expand All @@ -45,7 +45,7 @@
default: 'false'

attribute 'et_mesos/prefix',
recipes: ['et_mesos::source', 'et_mesos::master', 'et_mesos::slave'],
recipes: ['et_mesos::source', 'et_mesos::master', 'et_mesos::agent'],
display_name: 'Prefix value to be passed to configure script',
description: 'prefix value to be passed to configure script',
default: '/usr/local'
Expand Down Expand Up @@ -79,7 +79,7 @@
display_name: 'IP list of masters',
description: 'used in mesos-start/stop-cluster scripts.'

attribute 'et_mesos/slave_ips',
attribute 'et_mesos/agent_ips',
recipes: ['et_mesos::master'],
display_name: 'IP list of slaves',
display_name: 'IP list of agents',
description: 'used in mesos-start/stop-cluster scripts.'
42 changes: 21 additions & 21 deletions recipes/slave.rb → recipes/agent.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#
# Cookbook Name:: et_mesos
# Recipe:: slave
# Recipe:: agent
#

include_recipe 'et_mesos::default'

service 'mesos-slave' do
service 'mesos-agent' do
provider Chef::Provider::Service::Upstart
supports restart: true, reload: true
action :nothing
Expand All @@ -17,53 +17,53 @@
recursive true
end

unless node['et_mesos']['slave']['master']
fail "node['et_mesos']['slave']['master'] is required to configure mesos-slave."
unless node['et_mesos']['agent']['master']
fail "node['et_mesos']['agent']['master'] is required to configure mesos-agent."
end

# configuration files for mesos-daemon.sh provided by both source and mesosphere
template "#{deploy_dir}/mesos-slave-env.sh" do
source 'mesos-slave-env.sh.erb'
notifies :reload, 'service[mesos-slave]', :delayed
notifies :restart, 'service[mesos-slave]', :delayed
template "#{deploy_dir}/mesos-agent-env.sh" do
source 'mesos-agent-env.sh.erb'
notifies :reload, 'service[mesos-agent]', :delayed
notifies :restart, 'service[mesos-agent]', :delayed
end

template '/etc/init/mesos-slave.conf' do
template '/etc/init/mesos-agent.conf' do
source "upstart.conf.for.#{node['et_mesos']['type']}.erb"
variables init_state: 'start', role: 'slave'
notifies :reload, 'service[mesos-slave]'
variables init_state: 'start', role: 'agent'
notifies :reload, 'service[mesos-agent]'
end

# configuration files for service scripts(mesos-init-wrapper) by mesosphere package.
if node['et_mesos']['type'] == 'mesosphere'
template '/etc/mesos/zk' do
source 'etc-mesos-zk.erb'
variables zk: node['et_mesos']['slave']['master']
variables zk: node['et_mesos']['agent']['master']
end

template '/etc/default/mesos' do
source 'etc-default-mesos.erb'
variables log_dir: node['et_mesos']['slave']['log_dir']
variables log_dir: node['et_mesos']['agent']['log_dir']
end

template '/etc/default/mesos-slave' do
source 'etc-default-mesos-slave.erb'
variables isolation: node['et_mesos']['slave']['isolation']
template '/etc/default/mesos-agent' do
source 'etc-default-mesos-agent.erb'
variables isolation: node['et_mesos']['agent']['isolation']
end

directory '/etc/mesos-slave' do
directory '/etc/mesos-agent' do
recursive true
end

# TODO: Refactor this or add a guard to provide idempotency - jeffbyrnes
execute 'rm -rf /etc/mesos-slave/*'
execute 'rm -rf /etc/mesos-agent/*'

node['et_mesos']['slave'].each do |key, val|
node['et_mesos']['agent'].each do |key, val|
next if %w(master_url master isolation log_dir).include?(key)
next if val.nil?
if val.respond_to? :to_path_hash
val.to_path_hash.each do |path_h|
attr_path = "/etc/mesos-slave/#{key}"
attr_path = "/etc/mesos-agent/#{key}"

directory attr_path

Expand All @@ -72,7 +72,7 @@
end
end
else
file "/etc/mesos-slave/#{key}" do
file "/etc/mesos-agent/#{key}" do
content "#{val}\n"
end
end
Expand Down
2 changes: 1 addition & 1 deletion recipes/master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# by both source and mesosphere
template "#{deploy_dir}/masters"

template "#{deploy_dir}/slaves"
template "#{deploy_dir}/agents"

template "#{deploy_dir}/mesos-deploy-env.sh"

Expand Down
Loading

0 comments on commit 3438647

Please sign in to comment.