Skip to content

Commit

Permalink
Merge pull request #398 from rawleto/master
Browse files Browse the repository at this point in the history
Added the ui parameter and removed ui_* ones
  • Loading branch information
solarkennedy authored Dec 29, 2017
2 parents 8908b50 + a6c77c4 commit a8ecd96
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 166 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -509,4 +509,4 @@



\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ new versions of consul. Pin to the version that works for your setup!

| Consul Version | Recommended Puppet Module Version |
| ---------------- | ----------------------------------- |
| >= 0.8.0 | latest |
| >= 0.9.0 | latest |
| 0.8.x | <= 3.2.4 |
| 0.7.0 | <= 2.1.1 |
| 0.6.0 | <= 2.1.1 |
| 0.5.x | 1.0.3 |
Expand Down Expand Up @@ -73,7 +74,7 @@ class { '::consul':

## Web UI

To install and run the Web UI on the server, include `ui_dir` in the
To install and run the Web UI on the server, include `ui => true` in the
`config_hash`. You may also want to change the `client_addr` to `0.0.0.0` from
the default `127.0.0.1`, for example:
```puppet
Expand All @@ -86,7 +87,7 @@ class { '::consul':
'log_level' => 'INFO',
'node_name' => 'server',
'server' => true,
'ui_dir' => '/opt/consul/ui',
'ui' => true,
}
}
```
Expand Down
31 changes: 0 additions & 31 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,6 @@
# [*services*]
# Hash of consul::service resources to create.
#
# [*ui_download_extension*]
# The extension of the archive file containing the consul ui to download.
#
# [*ui_download_url*]
# Fully qualified url to the location of the archive file containing the consul ui.
#
# [*ui_download_url_base*]
# Base url to the location of the archive file containing the consul ui.
#
# [*ui_package_ensure*]
# Only valid when the install_method == package. Defaults to `latest`.
#
# [*ui_package_name*]
# Only valid when the install_method == package. Defaults to `consul_ui`.
#
# [*user*]
# Name of the user that should own the consul configuration files.
#
Expand Down Expand Up @@ -183,11 +168,6 @@
Boolean $service_enable = $consul::params::service_enable,
Enum['stopped', 'running'] $service_ensure = $consul::params::service_ensure,
Hash $services = $consul::params::services,
$ui_download_extension = $consul::params::ui_download_extension,
Optional[Stdlib::HTTPUrl] $ui_download_url = undef,
Stdlib::HTTPUrl $ui_download_url_base = $consul::params::ui_download_url_base,
$ui_package_ensure = $consul::params::ui_package_ensure,
$ui_package_name = $consul::params::ui_package_name,
$user = $consul::params::user,
$version = $consul::params::version,
Hash $watches = $consul::params::watches,
Expand All @@ -196,7 +176,6 @@

# lint:ignore:140chars
$real_download_url = pick($download_url, "${download_url_base}${version}/${package_name}_${version}_${os}_${arch}.${download_extension}")
$real_ui_download_url = pick($ui_download_url, "${ui_download_url_base}${version}/${package_name}_${version}_web_ui.${ui_download_extension}")
# lint:endignore

$config_hash_real = deep_merge($config_defaults, $config_hash)
Expand All @@ -218,16 +197,6 @@
$data_dir = undef
}

if $config_hash_real['ui_dir'] {
$ui_dir = $config_hash_real['ui_dir']
} else {
$ui_dir = undef
}

if ($ui_dir and ! $data_dir) {
warning('data_dir must be set to install consul web ui')
}

if ($config_hash_real['ports'] and $config_hash_real['ports']['http']) {
$http_port = $config_hash_real['ports']['http']
} else {
Expand Down
36 changes: 0 additions & 36 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -55,49 +55,13 @@
notify => $do_notify_service,
target => "${install_path}/consul-${consul::version}/consul";
}

if ($consul::ui_dir and $consul::data_dir) {

# The 'dist' dir was removed from the web_ui archive in Consul version 0.6.0
if (versioncmp($consul::version, '0.6.0') < 0) {
$archive_creates = "${install_path}/consul-${consul::version}_web_ui/dist"
$ui_symlink_target = $archive_creates
} else {
$archive_creates = "${install_path}/consul-${consul::version}_web_ui/index.html"
$ui_symlink_target = "${install_path}/consul-${consul::version}_web_ui"
}

file { "${install_path}/consul-${consul::version}_web_ui":
ensure => directory,
}
-> archive { "${install_path}/consul_web_ui-${consul::version}.zip":
ensure => present,
source => $consul::real_ui_download_url,
proxy_server => $consul::proxy_server,
extract => true,
extract_path => "${install_path}/consul-${consul::version}_web_ui",
creates => $archive_creates,
}
->file { $consul::ui_dir:
ensure => 'symlink',
target => $ui_symlink_target,
}
}
}
'package': {
package { $consul::package_name:
ensure => $consul::package_ensure,
notify => $consul::notify_service
}

if $consul::ui_dir {
package { $consul::ui_package_name:
ensure => $consul::ui_package_ensure,
require => Package[$consul::package_name],
notify => $consul::notify_service
}
}

if $consul::manage_user {
User[$consul::user_real] -> Package[$consul::package_name]
}
Expand Down
4 changes: 0 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
$service_enable = true
$service_ensure = 'running'
$services = {}
$ui_download_extension = 'zip'
$ui_download_url_base = 'https://releases.hashicorp.com/consul/'
$ui_package_ensure = 'latest'
$ui_package_name = 'consul_ui'
$user = 'consul'
$version = '0.7.4'
$watches = {}
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": "KyleAnderson-consul",
"version": "3.2.4",
"version": "3.3.0",
"author": "Kyle Anderson <kyle@xkyle.com>",
"summary": "Configures Consul by Hashicorp",
"license": "Apache-2.0",
Expand Down
9 changes: 2 additions & 7 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
package { 'zip': ensure => present } ->
# Don't manage the service as it doesn't work well in docker
class { 'consul':
version => '0.8.5',
version => '1.0.1',
manage_service => false,
config_hash => {
'datacenter' => 'east-aws',
'data_dir' => '/opt/consul',
'ui_dir' => '/opt/consul/ui',
'log_level' => 'INFO',
'node_name' => 'foobar',
'server' => true,
Expand All @@ -34,16 +33,12 @@ class { 'consul':
it { should be_directory }
end

describe file('/opt/consul/ui') do
it { should be_linked_to '/opt/consul/archives/consul-0.8.5_web_ui' }
end

describe service('consul') do
it { should be_enabled }
end

describe command('consul version') do
its(:stdout) { should match /Consul v0\.8\.5/ }
its(:stdout) { should match /Consul v1\.0\.1/ }
end

end
Expand Down
89 changes: 6 additions & 83 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,85 +108,28 @@
it { should contain_package('consul').with(:ensure => 'latest') }
end

context 'When requesting to install UI via a custom package and version' do
let(:params) {{
:install_method => 'package',
:ui_package_ensure => 'specific_ui_release',
:ui_package_name => 'custom_consul_ui_package',
:config_hash => {
'data_dir' => '/dir1',
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_package('custom_consul_ui_package').with(:ensure => 'specific_ui_release') }
end

context 'When requesting to not to install' do
let(:params) {{
:install_method => 'none'
}}
it { should_not contain_package('consul') }
it { should_not contain_package('consul_ui') }
it { should_not contain_staging__file('consul.zip') }
it { should_not contain_staging__file('consul_web_ui-0.7.4.zip') }
end

context "When installing UI via URL by default" do
context "When installing UI" do
let(:params) {{
:config_hash => {
'data_dir' => '/dir1',
'ui_dir' => '/dir1/dir2',
'ui' => true
},
}}
it { should contain_archive('/dir1/archives/consul_web_ui-0.7.4.zip').with(:source => 'https://releases.hashicorp.com/consul/0.7.4/consul_0.7.4_web_ui.zip') }
it { should contain_file('/dir1/dir2').that_requires('Archive[/dir1/archives/consul_web_ui-0.7.4.zip]') }
it { should contain_file('/dir1/dir2').with(:ensure => 'symlink') }
it { should contain_file('consul config.json').with_content(/"ui":true/) }
end

context "When installing UI via URL with a special version" do
context "When not installing UI" do
let(:params) {{
:version => '42',
:config_hash => {
'data_dir' => '/dir1',
'ui_dir' => '/dir1/dir2',
},
:config_hash => { },
}}
it { should contain_archive('/dir1/archives/consul_web_ui-42.zip').with(:source => 'https://releases.hashicorp.com/consul/42/consul_42_web_ui.zip') }
end

context "When installing UI via URL when version < 0.6.0" do
let(:params) {{
'version' => '0.5.99',
:config_hash => {
'data_dir' => '/dir1',
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_archive('/dir1/archives/consul_web_ui-0.5.99.zip').with(:creates => %r{/dist$}) }
it { should contain_file('/dir1/dir2').with(:target => %r{/dist$}) }
end

context "When installing UI via URL when version >= 0.6.0" do
let(:params) {{
'version' => '0.6.0',
:config_hash => {
'data_dir' => '/dir1',
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_archive('/dir1/archives/consul_web_ui-0.6.0.zip').with(:creates => %r{/index\.html$}) }
it { should contain_file('/dir1/dir2').with(:target => %r{_web_ui$}) }
end

context "When installing UI via URL by with a custom url" do
let(:params) {{
:ui_download_url => 'http://myurl',
:config_hash => {
'data_dir' => '/dir1',
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_archive('/dir1/archives/consul_web_ui-0.7.4.zip').with(:source => 'http://myurl') }
it { should_not contain_file('consul config.json').with_content(/"ui":true/) }
end

context "By default, a user and group should be installed" do
Expand All @@ -209,26 +152,6 @@
it { should contain_file('/opt/consul/archives').with(:ensure => :directory) }
end

context "When ui_dir is provided but not data_dir" do
let(:params) {{
:config_hash => {
'ui_dir' => '/dir1/dir2',
},
}}
it { should_not contain_file('/dir1/dir2') }
end

context "When ui_dir and data_dir is provided" do
let(:params) {{
:config_hash => {
'data_dir' => '/dir1',
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_file('/dir1') }
it { should contain_file('/dir1/dir2') }
end

context 'The bootstrap_expect in config_hash is an int' do
let(:params) {{
:config_hash =>
Expand Down

0 comments on commit a8ecd96

Please sign in to comment.