Skip to content

Commit

Permalink
Fixing merge conflict.
Browse files Browse the repository at this point in the history
  • Loading branch information
dudemcbacon committed Feb 24, 2016
1 parent d7f26af commit c84c4ad
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 142 deletions.
30 changes: 26 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
*.gem
*.rbc
.*.sw?
pkg
spec/fixtures
.DS_Store
.bundle/
.dat*
.repl_history
.rspec_system
.rvmrc
/.bundle/
/.config
/.yardoc/
/InstalledFiles
/_yardoc/
/coverage/
/doc/
/lib/bundler/man/
/pkg/
/rdoc/
/spec/examples.txt
/spec/reports/
/test/tmp/
/test/version_tmp/
/tmp/
/vendor/bundle
Gemfile.lock
build/
log/
pkg
spec/fixtures
vendor/
.bundle/
.DS_Store
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Kenny Gatdula <[email protected]>
Simon Croome <[email protected]>
Dan Tehranian <[email protected]>
Vik Bhatti <[email protected]>
Brandon Burnett <[email protected]>
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end
group :test do
gem "json"
gem "rake"
gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.7.0'
gem "puppet", ENV['PUPPET_VERSION'] || '~> 4'
gem "puppet-lint"

# Pin for 1.8.7 compatibility for now
Expand Down
92 changes: 53 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,74 @@
# puppet-consul

## Compatibility

| Consul Version | Recommended Puppet Module Version |
| ---------------- | ----------------------------------- |
| >= 0.6.0 | latest |
| 0.5.x | 1.0.3 |
| 0.4.x | 0.4.6 |
| 0.3.x | 0.3.0 |
# puppet-nomad

### What This Module Affects

* Installs the consul daemon (via url or package)
* Installs the nomad daemon (via url or package)
* If installing from zip, you *must* ensure the unzip utility is available.
* Optionally installs a user to run it under
* Installs a configuration file (/etc/consul/config.json)
* Installs a configuration file (/etc/nomad/config.json)
* Manages the consul service via upstart, sysv, or systemd
* Optionally installs the Web UI

## Usage

To set up a single consul server, with several agents attached:
To set up a single nomad server, with several agents attached:
On the server:
```puppet
class { '::consul':
config_hash => {
'bootstrap_expect' => 1,
'data_dir' => '/opt/consul',
'datacenter' => 'east-aws',
'log_level' => 'INFO',
'node_name' => 'server',
'server' => true,
class { '::nomad':
config_hash = {
'region' => 'us-west',
'datacenter' => 'ptk',
'log_level' => 'INFO',
'bind_addr' => '0.0.0.0',
'data_dir' => '/opt/nomad',
'server' => {
'enabled' => true,
'bootstrap_expect' => 3,
}
}
}
```
On the agent(s):
```puppet
class { '::consul':
config_hash => {
'data_dir' => '/opt/consul',
'datacenter' => 'east-aws',
class { 'nomad':
config_hash => {
'region' => 'us-west',
'datacenter' => 'ptk',
'log_level' => 'INFO',
'node_name' => 'agent',
'retry_join' => ['172.16.0.1'],
}
'bind_addr' => '0.0.0.0',
'data_dir' => '/opt/nomad',
'client' => {
'enabled' => true,
'servers' => [
"nomad01.your-org.pvt4647",
"nomad02.your-org.pvt:4647",
"nomad03.your-org.pvt:4647"
]
}
},
}
```
Disable install and service components:
```puppet
class { '::consul':
class { '::nomad':
install_method => 'none',
init_style => false,
manage_service => false,
config_hash => {
'data_dir' => '/opt/consul',
'datacenter' => 'east-aws',
config_hash => {
'region' => 'us-west',
'datacenter' => 'ptk',
'log_level' => 'INFO',
'node_name' => 'agent',
'retry_join' => ['172.16.0.1'],
}
'bind_addr' => '0.0.0.0',
'data_dir' => '/opt/nomad',
'client' => {
'enabled' => true,
'servers' => [
"nomad01.your-org.pvt4647",
"nomad02.your-org.pvt:4647",
"nomad03.your-org.pvt:4647"
]
}
},
}
```

Expand All @@ -67,6 +77,10 @@ class { '::consul':
Depends on the JSON gem, or a modern ruby. (Ruby 1.8.7 is not officially supported)

## Development
Open an [issue](https://github.com/solarkennedy/puppet-consul/issues) or
[fork](https://github.com/solarkennedy/puppet-consul/fork) and open a
[Pull Request](https://github.com/solarkennedy/puppet-consul/pulls)
Open an [issue](https://github.com/dudemcbacon/puppet-nomad/issues) or
[fork](https://github.com/dudemcbacon/puppet-nomad/fork) and open a
[Pull Request](https://github.com/dudemcbacon/puppet-nomad/pulls)

## Acknowledgement

Must of this module was refactored from Kyle Anderson's great [consul](https://github.com/solarkennedy/puppet-consul) module available on the puppet forge. Go give him stars and likes and what not -- he deserves them!
24 changes: 0 additions & 24 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@
$manage_service = true,
$restart_on_change = true,
$init_style = $nomad::params::init_style,
$services = {},
$watches = {},
$checks = {},
$acls = {},
) inherits nomad::params {

$real_download_url = pick($download_url, "${download_url_base}${version}/${package_name}_${version}_${os}_${arch}.${download_extension}")
Expand All @@ -91,10 +87,6 @@
validate_hash($config_defaults)
validate_bool($pretty_config)
validate_integer($pretty_config_indent)
validate_hash($services)
validate_hash($watches)
validate_hash($checks)
validate_hash($acls)

$config_hash_real = deep_merge($config_defaults, $config_hash)
validate_hash($config_hash_real)
Expand All @@ -120,22 +112,6 @@
$rpc_addr = $::ipaddress_lo
}

if $services {
create_resources(nomad::service, $services)
}

if $watches {
create_resources(nomad::watch, $watches)
}

if $checks {
create_resources(nomad::check, $checks)
}

if $acls {
create_resources(nomad_acl, $acls)
}

$notify_service = $restart_on_change ? {
true => Class['nomad::run_service'],
default => undef,
Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$package_ensure = 'latest'
$download_url_base = 'https://releases.hashicorp.com/nomad/'
$download_extension = 'zip'
$version = '0.5.2'
$version = '0.2.3'
$config_mode = '0660'

case $::architecture {
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dudemcbacon-consul",
"version": "1.0.0",
"version": "0.0.1",
"author": "Kyle Anderson <[email protected]>",
"summary": "Configures Nomad by Hashicorp",
"license": "Apache-2.0",
Expand Down
10 changes: 4 additions & 6 deletions spec/acceptance/nodesets/default.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
HOSTS:
ubuntu-12-04:
platform: ubuntu-12.04-x64
image: solarkennedy/ubuntu-12.04-puppet
hypervisor: docker
docker_cmd: '["/sbin/init"]'
docker_preserve_image: true
centos-7-puppet:
platform: centos-7.2-x64
box: puppetlabs/centos-7.2-64-puppet
hypervisor: vagrant
CONFIG:
type: foss
18 changes: 11 additions & 7 deletions spec/acceptance/standard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
it 'should work with no errors based on the example' do
pp = <<-EOS
class { 'nomad':
version => '0.5.2',
version => '0.2.3',
config_hash => {
'datacenter' => 'east-aws',
'data_dir' => '/opt/nomad',
'log_level' => 'INFO',
'node_name' => 'foobar',
'server' => true
"region" => 'us-west',
"datacenter" => 'ptk',
"log_level" => 'INFO',
"bind_dir" => "0.0.0.0",
"data_dir" => "/var/lib/nomad",
"server" => {
"enabled" => true,
"bootstrap_expect" => 1
}
}
}
EOS
Expand All @@ -32,7 +36,7 @@ class { 'nomad':
end

describe command('nomad version') do
its(:stdout) { should match /Consul v0\.5\.2/ }
its(:stdout) { should match /Nomad v0\.2\.3/ }
end

end
Expand Down
40 changes: 3 additions & 37 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
end

context "When installing via URL by default" do
it { should contain_staging__file('nomad-0.5.2.zip').with(:source => 'https://releases.hashicorp.com/nomad/0.5.2/nomad_0.5.2_linux_amd64.zip') }
it { should contain_staging__file('nomad-0.2.3.zip').with(:source => 'https://releases.hashicorp.com/nomad/0.2.3/nomad_0.2.3_linux_amd64.zip') }
it { should contain_file('/usr/local/bin/nomad').that_notifies('Class[nomad::run_service]') }
#it { should contain_notify(['Class[nomad::run_service]']) }
end
Expand All @@ -101,7 +101,7 @@
let(:params) {{
:download_url => 'http://myurl',
}}
it { should contain_staging__file('nomad-0.5.2.zip').with(:source => 'http://myurl') }
it { should contain_staging__file('nomad-0.2.3.zip').with(:source => 'http://myurl') }
it { should contain_file('/usr/local/bin/nomad').that_notifies('Class[nomad::run_service]') }
end

Expand Down Expand Up @@ -228,23 +228,13 @@
context "When a reload_service is triggered with service_ensure stopped" do
let (:params) {{
:service_ensure => 'stopped',
:services => {
'test_service1' => {
'port' => '5'
}
}
}}
it { should_not contain_exec('reload nomad service') }
end

context "When a reload_service is triggered with manage_service false" do
let (:params) {{
:manage_service => false,
:services => {
'test_service1' => {
'port' => '5'
}
}
}}
it { should_not contain_exec('reload nomad service') }
end
Expand Down Expand Up @@ -274,11 +264,6 @@
end

context "When nomad is reloaded" do
let (:params) {{
:services => {
'test_service1' => {}
}
}}
let (:facts) {{
:ipaddress_lo => '127.0.0.1'
}}
Expand All @@ -290,9 +275,6 @@

context "When nomad is reloaded on a custom port" do
let (:params) {{
:services => {
'test_service1' => {}
},
:config_hash => {
'ports' => {
'rpc' => '9999'
Expand All @@ -310,9 +292,6 @@

context "When nomad is reloaded with a default client_addr" do
let (:params) {{
:services => {
'test_service1' => {}
},
:config_hash => {
'client_addr' => '192.168.34.56',
}
Expand All @@ -323,19 +302,6 @@
}
end

context "When the user provides a hash of services" do
let (:params) {{
:services => {
'test_service1' => {
'port' => '5'
}
}
}}
it { should contain_nomad__service('test_service1').with_port('5') }
it { should have_nomad__service_resource_count(1) }
it { should contain_exec('reload nomad service') }
end

context "When using sysv" do
let (:params) {{
:init_style => 'sysv'
Expand Down Expand Up @@ -571,7 +537,7 @@
let(:params) {{
:extra_options => '-some-extra-argument'
}}
it { should contain_file('/etc/init/nomad.conf').with_content(/\$CONSUL -S -- agent .*-some-extra-argument$/) }
it { should contain_file('/etc/init/nomad.conf').with_content(/\$NOMAD -S -- agent .*-some-extra-argument$/) }
end
# Service Stuff

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'beaker-rspec/helpers/serverspec'
require 'beaker/puppet_install_helper'

run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no'
#run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no'

RSpec.configure do |c|
# Project root
Expand Down
Loading

0 comments on commit c84c4ad

Please sign in to comment.