2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
modulesync_config_version: '1.0.0'
modulesync_config_version: '1.1.0'
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ script:
matrix:
fast_finish: true
include:
- rvm: 2.1.9
- rvm: 2.4.1
bundler_args: --without development
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-16.04 CHECK=beaker
services: docker
sudo: required
- rvm: 2.1.9
- rvm: 2.4.1
bundler_args: --without development
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/centos-7 CHECK=beaker
services: docker
sudo: required
- rvm: 2.4.1
- rvm: 2.1.9
bundler_args: --without system_tests development
env: PUPPET_VERSION="~> 4.0" CHECK=test
- rvm: 2.4.1
Expand Down
44 changes: 40 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,34 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not affect the functionality of the module.

## [v7.1.0](https://github.com/voxpupuli/puppet-rabbitmq/tree/v7.1.0) (2017-10-03)

[Full Changelog](https://github.com/voxpupuli/puppet-rabbitmq/compare/v7.0.0...v7.1.0)

**Implemented enhancements:**

- Rework apt to use packagecloud repos as well \(\#640\) [\#641](https://github.com/voxpupuli/puppet-rabbitmq/pull/641) ([wyardley](https://github.com/wyardley))
- Refactor rabbitmq\_user provider \(mpolenchuk\) [\#598](https://github.com/voxpupuli/puppet-rabbitmq/pull/598) ([wyardley](https://github.com/wyardley))

**Closed issues:**

- Please switch to Package Cloud apt repository; rabbitmq.com's one becomes read-only in a few months [\#640](https://github.com/voxpupuli/puppet-rabbitmq/issues/640)

**Merged pull requests:**

- Switch back to "include foo" \(without leading colons\) syntax [\#639](https://github.com/voxpupuli/puppet-rabbitmq/pull/639) ([wyardley](https://github.com/wyardley))
- Lower required Puppet version from 4.8.0 to 4.7.1 [\#637](https://github.com/voxpupuli/puppet-rabbitmq/pull/637) ([wyardley](https://github.com/wyardley))
- 7.0.0 release [\#633](https://github.com/voxpupuli/puppet-rabbitmq/pull/633) ([wyardley](https://github.com/wyardley))

## [v7.0.0](https://github.com/voxpupuli/puppet-rabbitmq/tree/v7.0.0) (2017-09-14)

[Full Changelog](https://github.com/voxpupuli/puppet-rabbitmq/compare/v6.0.0...v7.0.0)

**Breaking changes:**

- BREAKING: Ensure python package \(adds manage\_python option\) [\#623](https://github.com/voxpupuli/puppet-rabbitmq/pull/623) ([wyardley](https://github.com/wyardley))
- BREAKING: Adds config\_ranch parameter \(default: true\) to suppress config lines \(\#618\) [\#621](https://github.com/voxpupuli/puppet-rabbitmq/pull/621) ([wyardley](https://github.com/wyardley))

**Implemented enhancements:**

- Add additional SSL configuration options \(original PR from xepa\) [\#632](https://github.com/voxpupuli/puppet-rabbitmq/pull/632) ([wyardley](https://github.com/wyardley))
Expand All @@ -24,7 +49,7 @@ These should not affect the functionality of the module.
- Error on using puppet resource rabbitmq\_user [\#147](https://github.com/voxpupuli/puppet-rabbitmq/issues/147)
- Resolve issue with "puppet resource rabbitmq\_user" failing \(\#147\) [\#629](https://github.com/voxpupuli/puppet-rabbitmq/pull/629) ([wyardley](https://github.com/wyardley))
- BREAKING: Ensure python package \(adds manage\_python option\) [\#623](https://github.com/voxpupuli/puppet-rabbitmq/pull/623) ([wyardley](https://github.com/wyardley))
- BREAKING: Adds config\\_ranch parameter \\(default: true\\) to suppress config lines \\(\\#618\\) [\#621](https://github.com/voxpupuli/puppet-rabbitmq/pull/621) ([wyardley](https://github.com/wyardley))
- BREAKING: Adds config\_ranch parameter \(default: true\) to suppress config lines \(\#618\) [\#621](https://github.com/voxpupuli/puppet-rabbitmq/pull/621) ([wyardley](https://github.com/wyardley))
- Switch back to using rabbitmq-plugins from system path \(\#566\) [\#570](https://github.com/voxpupuli/puppet-rabbitmq/pull/570) ([wyardley](https://github.com/wyardley))

**Closed issues:**
Expand All @@ -44,8 +69,17 @@ These should not affect the functionality of the module.
- Update fixtures to voxpupuli/archive \(from puppet-community\) [\#619](https://github.com/voxpupuli/puppet-rabbitmq/pull/619) ([wyardley](https://github.com/wyardley))

## [v6.0.0](https://github.com/voxpupuli/puppet-rabbitmq/tree/v6.0.0) (2017-09-07)

[Full Changelog](https://github.com/voxpupuli/puppet-rabbitmq/compare/5.6.0...v6.0.0)

**Breaking changes:**

- BREAKING: Drop Ruby 1.8 support. Rubocop auto-fixes in preparation for modulesync [\#575](https://github.com/voxpupuli/puppet-rabbitmq/pull/575) ([wyardley](https://github.com/wyardley))
- BREAKING: Switch from 'UNSET' to undef, rename management\_ip to management\_ip\_address [\#559](https://github.com/voxpupuli/puppet-rabbitmq/pull/559) ([wyardley](https://github.com/wyardley))
- BREAKING: Drop Puppet 3 support. Replace validate\_\* with datatypes [\#536](https://github.com/voxpupuli/puppet-rabbitmq/pull/536) ([bastelfreak](https://github.com/bastelfreak))
- Updated app.pp to address deprecation warnings [\#497](https://github.com/voxpupuli/puppet-rabbitmq/pull/497) ([ilium007](https://github.com/ilium007))
- BREAKING: manage\_repos is now repos\_ensure \(default false\), version is now unused, switch to RabbitMQ's "packagecloud" repos [\#493](https://github.com/voxpupuli/puppet-rabbitmq/pull/493) ([wyardley](https://github.com/wyardley))

**Implemented enhancements:**

- Convert to use 'archive' instead of 'staging' for rabbitmqadmin install [\#604](https://github.com/voxpupuli/puppet-rabbitmq/pull/604) ([wyardley](https://github.com/wyardley))
Expand All @@ -62,6 +96,7 @@ These should not affect the functionality of the module.
- Add ssl\_depth and password params for configuration [\#530](https://github.com/voxpupuli/puppet-rabbitmq/pull/530) ([bostrowski13](https://github.com/bostrowski13))
- Allow Configuring Management IP Binding [\#506](https://github.com/voxpupuli/puppet-rabbitmq/pull/506) ([naftulikay](https://github.com/naftulikay))
- Support multiple routing keys for bindings using separate parameters [\#504](https://github.com/voxpupuli/puppet-rabbitmq/pull/504) ([wyardley](https://github.com/wyardley))
- BREAKING: manage\_repos is now repos\_ensure \(default false\), version is now unused, switch to RabbitMQ's "packagecloud" repos [\#493](https://github.com/voxpupuli/puppet-rabbitmq/pull/493) ([wyardley](https://github.com/wyardley))

**Fixed bugs:**

Expand All @@ -70,6 +105,7 @@ These should not affect the functionality of the module.
- Avoid error when rabbitmqctl is not present\), update spec syntax \(\#614\) [\#615](https://github.com/voxpupuli/puppet-rabbitmq/pull/615) ([wyardley](https://github.com/wyardley))
- fix a couple of problems with erl\_ssl\_path fact [\#609](https://github.com/voxpupuli/puppet-rabbitmq/pull/609) ([costela](https://github.com/costela))
- Switch $releasevar to ${::os\[release\]\[major\]} [\#577](https://github.com/voxpupuli/puppet-rabbitmq/pull/577) ([wyardley](https://github.com/wyardley))
- Fix regex double escaping of rabbitmqctl list\_policies [\#561](https://github.com/voxpupuli/puppet-rabbitmq/pull/561) ([wyardley](https://github.com/wyardley))
- Update file / directory permissions [\#560](https://github.com/voxpupuli/puppet-rabbitmq/pull/560) ([wyardley](https://github.com/wyardley))
- Update regexp for rabbitmq\_nodename fact [\#545](https://github.com/voxpupuli/puppet-rabbitmq/pull/545) ([SergK](https://github.com/SergK))
- \[Bugfix\] convert $ssl\_depth from string to integer [\#539](https://github.com/voxpupuli/puppet-rabbitmq/pull/539) ([bastelfreak](https://github.com/bastelfreak))
Expand Down Expand Up @@ -143,23 +179,23 @@ These should not affect the functionality of the module.
- \(MODULES-3704\) Update gemfile template to be identical [\#519](https://github.com/voxpupuli/puppet-rabbitmq/pull/519) ([hunner](https://github.com/hunner))
- Fix sync [\#518](https://github.com/voxpupuli/puppet-rabbitmq/pull/518) ([hunner](https://github.com/hunner))
- Allows deprecation errors [\#516](https://github.com/voxpupuli/puppet-rabbitmq/pull/516) ([pmcmaw](https://github.com/pmcmaw))
- Updated app.pp to address deprecation warnings [\#497](https://github.com/voxpupuli/puppet-rabbitmq/pull/497) ([ilium007](https://github.com/ilium007))
- Bug fix for when queue names include spaces [\#512](https://github.com/voxpupuli/puppet-rabbitmq/pull/512) ([Bubbad](https://github.com/Bubbad))
- Do not check cert when acquiring rabbitmqadmin with wget. [\#478](https://github.com/voxpupuli/puppet-rabbitmq/pull/478) ([modax](https://github.com/modax))
- Cleanup void tcp options [\#464](https://github.com/voxpupuli/puppet-rabbitmq/pull/464) ([mpolenchuk](https://github.com/mpolenchuk))

## [5.6.0](https://github.com/voxpupuli/puppet-rabbitmq/tree/5.6.0) (2016-10-25)

[Full Changelog](https://github.com/voxpupuli/puppet-rabbitmq/compare/5.5.0...5.6.0)

**Implemented enhancements:**

- Allow ha-sync-batch-size for rabbitmq\_policy definition to be integer [\#500](https://github.com/voxpupuli/puppet-rabbitmq/pull/500) ([mxftw](https://github.com/mxftw))
- Ability to set management\_hostname in rabbitmqadmin.conf [\#498](https://github.com/voxpupuli/puppet-rabbitmq/pull/498) ([tampakrap](https://github.com/tampakrap))
- BREAKING: manage\_repos is now repos\_ensure \(default false\), version is now unused, switch to RabbitMQ's "packagecloud" repos [\#493](https://github.com/voxpupuli/puppet-rabbitmq/pull/493) ([wyardley](https://github.com/wyardley))

**Merged pull requests:**

- \(MODULES-3983\) Update parallel\_tests for ruby 2.0.0 moduleSync [\#514](https://github.com/voxpupuli/puppet-rabbitmq/pull/514) ([pmcmaw](https://github.com/pmcmaw))
- \[FM-5719\] Release prep for unsupported release 5.6.0 [\#513](https://github.com/voxpupuli/puppet-rabbitmq/pull/513) ([wilson208](https://github.com/wilson208))
- Bug fix for when queue names include spaces [\#512](https://github.com/voxpupuli/puppet-rabbitmq/pull/512) ([Bubbad](https://github.com/Bubbad))
- set $real\_package\_source to undef instead of empty [\#507](https://github.com/voxpupuli/puppet-rabbitmq/pull/507) ([bastelfreak](https://github.com/bastelfreak))
- Release 5.5.0 [\#503](https://github.com/voxpupuli/puppet-rabbitmq/pull/503) ([eputnam](https://github.com/eputnam))
- Update modulesync\_config \[a3fe424\] [\#501](https://github.com/voxpupuli/puppet-rabbitmq/pull/501) ([DavidS](https://github.com/DavidS))
Expand Down
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ group :test do
gem 'rspec-puppet', '~> 2.5', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'rspec-puppet-utils', :require => false
gem 'puppet-lint-absolute_classname-check', :require => false
gem 'puppet-lint-leading_zero-check', :require => false
gem 'puppet-lint-trailing_comma-check', :require => false
gem 'puppet-lint-version_comparison-check', :require => false
Expand Down Expand Up @@ -64,7 +63,7 @@ end
if facterversion = ENV['FACTER_GEM_VERSION']
gem 'facter', facterversion.to_s, :require => false, :groups => [:test]
else
gem 'facter', :require => false, :groups => [:test]
gem 'facter', :require => false, :groups => [:test]
end

ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 5.0' : puppetversion = ENV['PUPPET_VERSION'].to_s
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ you can control many parameters relating to the package and service, such as
disabling puppet support of the service:

```puppet
class { '::rabbitmq':
class { 'rabbitmq':
service_manage => false,
port => '5672',
delete_guest_user => true,
Expand Down
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ begin
require 'github_changelog_generator/task'
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
version = (Blacksmith::Modulefile.new).version
config.future_release = "v#{version}"
config.header = "# Change log\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not impact the functionality of the module."
config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync}
config.future_release = "v#{version}" if version =~ /^\d+\.\d+.\d+$/
config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module."
config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog}
config.user = 'voxpupuli'
end
rescue LoadError
Expand Down
4 changes: 2 additions & 2 deletions examples/erlang_deps.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# install first the garethr-erlang module. See README.md
include '::erlang'
include erlang

class { '::erlang': epel_enable => true}
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
4 changes: 2 additions & 2 deletions examples/full.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class { '::rabbitmq::repo::apt':
class { 'rabbitmq::repo::apt':
pin => '900',
}

-> class { '::rabbitmq::server':
-> class { 'rabbitmq::server':
delete_guest_user => true,
# version => '2.4.1',
}
Expand Down
2 changes: 1 addition & 1 deletion examples/plugin.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class { '::rabbitmq::server':
class { 'rabbitmq::server':
config_stomp => true,
}

Expand Down
2 changes: 1 addition & 1 deletion examples/server.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class { '::rabbitmq::server':
class { 'rabbitmq::server':
port => '5672',
delete_guest_user => true,
version => 'latest',
Expand Down
2 changes: 1 addition & 1 deletion examples/service.pp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
class { '::rabbitmq::service': }
class { 'rabbitmq::service': }
2 changes: 1 addition & 1 deletion examples/site.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$rabbitmq_plugins = [ 'amqp_client', 'rabbitmq_stomp' ]

class { '::rabbitmq::server':
class { 'rabbitmq::server':
config => '[ {rabbit_stomp, [{tcp_listeners, [1234]} ]} ].',
}

Expand Down
127 changes: 70 additions & 57 deletions lib/puppet/provider/rabbitmq_user/rabbitmqctl.rb
Original file line number Diff line number Diff line change
@@ -1,78 +1,92 @@
require 'puppet'
require 'set'
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rabbitmqctl'))
Puppet::Type.type(:rabbitmq_user).provide(:rabbitmqctl, parent: Puppet::Provider::Rabbitmqctl) do
if Puppet::PUPPETVERSION.to_f < 3
commands rabbitmqctl: 'rabbitmqctl'
else
has_command(:rabbitmqctl, 'rabbitmqctl') do
environment HOME: '/tmp'
end
Puppet::Type.type(:rabbitmq_user).provide(
:rabbitmqctl,
parent: Puppet::Provider::Rabbitmqctl
) do
has_command(:rabbitmqctl, 'rabbitmqctl') do
environment HOME: '/tmp'
end

defaultfor feature: :posix

def initialize(value = {})
super(value)
@property_flush = {}
end

def self.instances
user_list = run_with_retries do
rabbitmqctl('-q', 'list_users')
end

user_list.split(%r{\n}).map do |line|
raise Puppet::Error, "Cannot parse invalid user line: #{line}" unless line =~ %r{^(\S+)(\s+\[.*?\]|)$}
new(name: Regexp.last_match(1))
raise Puppet::Error, "Cannot parse invalid user line: #{line}" unless line =~ %r{^(\S+)\s+\[(.*?)\]$}
user = Regexp.last_match(1)
tags = Regexp.last_match(2).split(%r{,\s*})
new(
ensure: :present,
name: user,
tags: tags
)
end
end

def self.prefetch(resources)
users = instances
resources.each_key do |user|
if (provider = users.find { |u| u.name == user })
resources[user].provider = provider
end
end
end

def exists?
@property_hash[:ensure] == :present
end

def create
# Fail here (rather than a validate block in the type) if password is not
# set, so that "puppet resource" still works.
raise Puppet::Error, "Password is a required parameter for rabbitmq_user (user: #{name})" if @resource[:password].nil?

rabbitmqctl('add_user', resource[:name], resource[:password])
make_user_admin if resource[:admin] == :true
set_user_tags(resource[:tags]) unless resource[:tags].empty?
end
rabbitmqctl('add_user', @resource[:name], @resource[:password])

def change_password
rabbitmqctl('change_password', resource[:name], resource[:password])
end
tags = @resource[:tags]
tags << admin_tag if @resource[:admin] == :true
rabbitmqctl('set_user_tags', @resource[:name], tags) unless tags.empty?

def password
nil
@property_hash[:ensure] = :present
end

def check_password
response = self.class.run_with_retries do
rabbitmqctl('eval', 'rabbit_access_control:check_user_pass_login(list_to_binary("' + resource[:name] + '"), list_to_binary("' + resource[:password] + '")).')
end
if response.include? 'refused'
false
else
true
end
def destroy
rabbitmqctl('delete_user', @resource[:name])
@property_hash[:ensure] = :absent
end

def destroy
rabbitmqctl('delete_user', resource[:name])
def password=(password)
rabbitmqctl('change_password', @resource[:name], password)
end

def exists?
user_list = self.class.run_with_retries do
rabbitmqctl('-q', 'list_users')
end
def password; end

user_list.split(%r{\n}).find do |line|
line.match(%r{^#{Regexp.escape(resource[:name])}(\s+(\[.*?\]|\S+)|)$})
end
def check_password(password)
check_access_control = [
'rabbit_access_control:check_user_pass_login(',
%[list_to_binary("#{@resource[:name]}"), ],
%[list_to_binary("#{password}")).]
]

response = rabbitmqctl('eval', check_access_control.join)
!response.include? 'refused'
end

def tags
tags = get_user_tags
# do not expose the administrator tag for admins
tags.delete('administrator') if resource[:admin] == :true
tags.entries.sort
@property_hash[:tags].reject { |tag| tag == admin_tag }
end

def tags=(tags)
set_user_tags(tags) unless tags.nil?
@property_flush[:tags] = tags
end

def admin
Expand All @@ -91,26 +105,25 @@ def admin=(state)
end
end

def set_user_tags(tags) # rubocop:disable Style/AccessorMethodName
is_admin = get_user_tags.member?('administrator') \
|| resource[:admin] == :true
usertags = Set.new(tags)
usertags.add('administrator') if is_admin
rabbitmqctl('set_user_tags', resource[:name], usertags.entries.sort)
def admin
@property_hash[:tags].include?(admin_tag) ? :true : :false
end

def make_user_admin
usertags = get_user_tags
usertags.add('administrator')
rabbitmqctl('set_user_tags', resource[:name], usertags.entries.sort)
def admin=(state)
@property_flush[:admin] = state
end

def flush
return if @property_flush.empty?
tags = @property_flush[:tags] || @resource[:tags]
tags << admin_tag if @resource[:admin] == :true
rabbitmqctl('set_user_tags', @resource[:name], tags)
@property_flush.clear
end

private

def get_user_tags # rubocop:disable Style/AccessorMethodName
match = rabbitmqctl('-q', 'list_users').split(%r{\n}).map do |line|
line.match(%r{^#{Regexp.escape(resource[:name])}\s+\[(.*?)\]})
end.compact.first
Set.new(match[1].split(' ').map { |x| x.gsub(%r{,$}, '') }) if match
def admin_tag
'administrator'
end
end
Loading