Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: resolved merge conflicts and added tests #196

Merged
merged 7 commits into from
Jul 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 36 additions & 1 deletion .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,22 @@ platforms:
- name: ubuntu-12.04
- name: centos-7.0
- name: centos-6.5
<% if ENV['TEST_WINDOWS'] %>

This comment was marked as outdated.

- name: windows-2012r2-wrock
driver_config:
network:
- ["forwarded_port", {guest: 5985, host: 5985}]
communicator: winrm
gui: true
box_url: https://wrock.blob.core.windows.net/vhds/vbox2012r2.box
customize:
usbehci: "off"
<% end %>

suites:
- name: default
excludes:
- windows-2012r2-wrock
run_list:
- recipe[consul::default]
attributes:
Expand All @@ -22,6 +35,8 @@ suites:
advertise_interface: eth0
encrypt: CGXC2NsXW4AvuB4h5ODYzQ==
- name: source
excludes:
- windows-2012r2-wrock
run_list:
- recipe[consul::default]
attributes:
Expand All @@ -40,14 +55,19 @@ suites:
excludes:
- centos-7.0
- centos-6.5
- windows-2012r2-wrock
- name: runit
excludes:
- windows-2012r2-wrock
run_list:
- recipe[consul::default]
attributes:
consul:
datacenter: FortMeade
init_style: runit
- name: ui
excludes:
- windows-2012r2-wrock
run_list:
- recipe[consul::default]
- recipe[consul::ui]
Expand All @@ -56,17 +76,32 @@ suites:
serve_ui: true
client_interface: eth0
- name: cluster
excludes:
- windows-2012r2-wrock
run_list:
- recipe[consul::default]
attributes:
consul:
service_mode: cluster
bootstrap_expect: 1
- name: atlas
excludes:
- windows-2012r2-wrock
run_list:
- recipe[consul::default]
attributes:
consul:
atlas_autojoin: true
atlas_cluster: <%= ENV.fetch('ATLAS_CLUSTER', 'example/cluster') %>
atlas_token: <%= ENV.fetch('ATLAS_TOKEN', 'NOT_REAL') %>
atlas_token: <%= ENV.fetch('ATLAS_TOKEN', 'NOT_REAL') %>
<% if ENV['TEST_WINDOWS'] %>

This comment was marked as outdated.

- name: windows
includes:
- windows-2012r2-wrock
run_list:
- recipe[consul::default]
attributes:
consul:
install_method: windows
service_user: vagrant
<% end %>
52 changes: 42 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Installs and configures [Consul][1] client, server and UI.
- RHEL 6.5, 7.0
- Ubuntu 12.04, 14.04
- Arch Linux
- Windows

## Attributes

Expand Down Expand Up @@ -44,14 +45,26 @@ Installs and configures [Consul][1] client, server and UI.
<tr>
<td><tt>['consul']['install_method']</tt></td>
<td>String</td>
<td>Method to install consul with when using default recipe: binary or source</td>
<td><tt>binary</tt></td>
<td>Method to install consul with when using default recipe: 'binary', 'source' or 'windows'</td>
<td>
\*nix: <tt> binary</tt></br>
Windows: <tt>binary</tt>
</td>
</tr>
<tr>
<td><tt>['consul']['choco_source']</tt></td>
<td>String</td>
<td>Source to use for fetching the chocolatey package. Defaults to the chocolatey public feed</td>
<td><tt>https://chocolatey.org/api/v2/</tt></td>
</tr>
<tr>
<td><tt>['consul']['install_dir']</tt></td>
<td>String</td>
<td>Directory to install binary to.</td>
<td><tt>/usr/local/bin</tt></td>
<td>
\*nix: <tt>/usr/local/bin</tt></br>
Windows: <tt>{chocolatey_install_dir}\lib\consul.{consul_version}</tt>
</td>
</tr>
<tr>
<td><tt>['consul']['service_mode']</tt></td>
Expand All @@ -69,13 +82,29 @@ Installs and configures [Consul][1] client, server and UI.
<td><tt>['consul']['data_dir']</tt></td>
<td>String</td>
<td>Location to store consul's data in</td>
<td><tt>/var/lib/consul</tt></td>
<td>
\*nix: <tt>/var/lib/consul</tt></br>
Windows: <tt>C:\ProgramData\consul\data</tt>
</td>
</tr>
<tr>
<td><tt>['consul']['config_dir']</tt></td>
<td>String</td>
<td>Location to read service definitions from (directoy will be created)</td>
<td><tt>/etc/consul.d</tt></td>
<td>
\*nix: <tt>/etc/consul.d</tt></br>
Windows: <tt>C:\ProgramData\consul\config</tt>
</td>
</tr>
<tr>
<td><tt>['consul']['etc_config_dir']</tt></td>
<td>String</td>
<td>Misc. configuration directory that might need to be execute during service start</td>
<td>
Debian: <tt>/etc/default/consul</tt></br>
Windows: <tt>{chocolatey_install_dir}\lib\consul.{consul_version}\tools</tt></br>
Other: <tt>/etc/sysconfig/consul</tt>
</td>
</tr>
<tr>
<td><tt>['consul']['servers']</tt></td>
Expand Down Expand Up @@ -117,8 +146,7 @@ Installs and configures [Consul][1] client, server and UI.
<td><tt>['consul']['log_level']</tt></td>
<td>String</td>
<td>
The level of logging to show after the Consul agent has started.
Available: "trace", "debug", "info", "warn", "err"
The level of logging to show after the Consul agent has started: 'trace', 'debug', 'info', 'warn', or 'err'
</td>
<td><tt>info</tt></td>
</tr>
Expand All @@ -137,8 +165,11 @@ Installs and configures [Consul][1] client, server and UI.
<tr>
<td><tt>['consul']['init_style']</tt></td>
<td>String</td>
<td>Service init mode for running consul as: init, runit or systemd</td>
<td><tt>init</tt></td>
<td>Service init mode for running consul as: 'init', 'runit', 'systemd', or 'windows'</td>
<td>
\*nix: <tt>init</tt></br>
Windows: <tt>windows</tt>
</td>
</tr>
<tr>
<td><tt>['consul']['service_user']</tt></td>
Expand Down Expand Up @@ -421,7 +452,8 @@ the application.

### consul::ui
Installing the separate Consul UI simply requires you to include
the `consul::ui` recipe in your node's `run_list`.
the `consul::ui` recipe in your node's `run_list`. Consul UI is not supported
on Windows platform.

```json
{
Expand Down
39 changes: 27 additions & 12 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@

default['consul']['base_url'] = "https://dl.bintray.com/mitchellh/consul/%{version}.zip"
default['consul']['version'] = '0.5.2'
if node['platform_family'] == 'windows'
default['consul']['version'] = '0.5.0'
end
default['consul']['install_method'] = 'binary'
default['consul']['install_dir'] = '/usr/local/bin'
default['consul']['checksums'] = {
default['consul']['choco_source'] = "https://chocolatey.org/api/v2/"

default['consul']['checksums'] = {
'0.3.0_darwin_amd64' => '9dfbc70c01ebbc3e7dba0e4b31baeddbdcbd36ef99f5ac87ca6bbcc7405df405',
'0.3.0_linux_386' => '2513496374f8f15bda0da4da33122e93f82ce39f661ee3e668c67a5b7e98fd5f',
'0.3.0_linux_amd64' => 'da1337ab3b236bad19b791a54a8df03a8c2a340500a392000c21608696957b15',
Expand Down Expand Up @@ -66,15 +71,23 @@
default['consul']['use_packagecloud_repo'] = true

# Service attributes
default['consul']['service_mode'] = 'bootstrap'
default['consul']['service_mode'] = 'bootstrap'
default['consul']['retry_on_join'] = false

# In the cluster mode, set the default cluster size to 3
default['consul']['bootstrap_expect'] = 3
default['consul']['data_dir'] = '/var/lib/consul'
default['consul']['config_dir'] = '/etc/consul.d'
default['consul']['logfile'] = '/var/log/consul.log'
default['consul']['init_style'] = 'init' # 'init', 'runit', 'systemd'
case node['platform_family']
when 'windows'
default['consul']['install_method'] = 'windows'
default['consul']['init_style'] = 'windows'
default['consul']['config_dir'] = "#{ENV['SystemDrive']}\\ProgramData\\consul\\config"
default['consul']['data_dir'] = "#{ENV['SystemDrive']}\\ProgramData\\consul\\data"
default['consul']['install_dir'] = "#{ChocolateyHelpers.chocolatey_install}\\lib\\consul.#{node['consul']['version']}"
default['consul']['etc_config_dir'] = "#{ChocolateyHelpers.chocolatey_install}\\lib\\consul.#{node['consul']['version']}\\tools"
when 'debian'
default['consul']['etc_config_dir'] = '/etc/default/consul'
when 'rhel'
Expand All @@ -84,14 +97,16 @@
end

default['consul']['servers'] = []
default['consul']['init_style'] = 'init' # 'init', 'runit', 'systemd'

case node['consul']['init_style']
when 'runit' || 'systemd'
default['consul']['service_user'] = 'consul'
default['consul']['service_user'] = 'consul'
default['consul']['service_group'] = 'consul'
when 'windows'
default['consul']['service_user'] = 'Administrator'
default['consul']['service_group'] = 'Administrators'
else
default['consul']['service_user'] = 'root'
default['consul']['service_user'] = 'root'
default['consul']['service_group'] = 'root'
end
default['consul']['system_account'] = false
Expand All @@ -106,28 +121,28 @@
}

# Consul DataBag
default['consul']['data_bag'] = 'consul'
default['consul']['data_bag'] = 'consul'
default['consul']['data_bag_encrypt_item'] = 'encrypt'

# Gossip encryption
default['consul']['encrypt_enabled'] = false
default['consul']['encrypt'] = nil
default['consul']['encrypt'] = nil
# TLS support
default['consul']['verify_incoming'] = false
default['consul']['verify_outgoing'] = false
# Cert in pem format
default['consul']['ca_cert'] = nil
default['consul']['ca_path'] = "%{config_dir}/ca.pem"
default['consul']['ca_cert'] = nil
default['consul']['ca_path'] = "%{config_dir}/ca.pem"
default['consul']['cert_file'] = nil
default['consul']['cert_path'] = "%{config_dir}/cert.pem"
# Cert in pem format. It can be unique for each host
default['consul']['key_file'] = nil
default['consul']['key_file'] = nil
default['consul']['key_file_path'] = "%{config_dir}/key.pem"

# Optionally bind to a specific interface
default['consul']['bind_interface'] = nil
default['consul']['bind_interface'] = nil
default['consul']['advertise_interface'] = nil
default['consul']['client_interface'] = nil
default['consul']['client_interface'] = nil

# UI attributes
default['consul']['client_addr'] = '0.0.0.0'
Expand Down
5 changes: 5 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
supports 'ubuntu', '= 12.04'
supports 'ubuntu', '= 14.04'
supports 'arch'
supports 'windows'

recommends 'chef-provisioning'

Expand All @@ -27,3 +28,7 @@
depends 'runit'
depends 'yum-repoforge'
depends 'packagecloud'

# for windows
depends 'windows'
depends "chocolatey"
8 changes: 6 additions & 2 deletions providers/check_def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@
end

file new_resource.path do
user node['consul']['service_user']
group node['consul']['service_group']
if node['platform'] == 'windows'
rights :full_control, node['consul']['service_user'], :applies_to_children => true
else
user node['consul']['service_user']
group node['consul']['service_group']
end
mode 0600
content new_resource.to_json

Expand Down
8 changes: 6 additions & 2 deletions providers/event_watch_def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@

action :create do
file new_resource.path do
user node['consul']['service_user']
group node['consul']['service_group']
if node['platform'] == 'windows'
rights :full_control, node['consul']['service_user'], :applies_to_children => true
else
user node['consul']['service_user']
group node['consul']['service_group']
end
mode 0600
content new_resource.to_json

Expand Down
8 changes: 6 additions & 2 deletions providers/key_watch_def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@

action :create do
file new_resource.path do
user node['consul']['service_user']
group node['consul']['service_group']
if node['platform'] == 'windows'
rights :full_control, node['consul']['service_user'], :applies_to_children => true
else
user node['consul']['service_user']
group node['consul']['service_group']
end
mode 0600
content new_resource.to_json

Expand Down
8 changes: 6 additions & 2 deletions providers/service_def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ def set_updated
action :create do
set_updated do
file new_resource.path do
user node['consul']['service_user']
group node['consul']['service_group']
if node['platform'] == 'windows'
rights :full_control, node['consul']['service_user'], :applies_to_children => true
else
user node['consul']['service_user']
group node['consul']['service_group']
end
mode 0600
content new_resource.to_json
action :create
Expand Down
8 changes: 6 additions & 2 deletions providers/service_watch_def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@

action :create do
file new_resource.path do
user node['consul']['service_user']
group node['consul']['service_group']
if node['platform'] == 'windows'
rights :full_control, node['consul']['service_user'], :applies_to_children => true
else
user node['consul']['service_user']
group node['consul']['service_group']
end
mode 0600
content new_resource.to_json

Expand Down
2 changes: 2 additions & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
include_recipe 'consul::install_source'
when 'packages'
include_recipe 'consul::install_packages'
when 'windows'
include_recipe 'consul::install_windows'
else
Chef::Application.fatal!("[consul::default] unknown install method, method=#{node['consul']['install_method']}")
end
Expand Down