|
5 | 5 | confine feature: :posix |
6 | 6 |
|
7 | 7 | def self.plugin_list |
| 8 | + retry_iter = 0 |
8 | 9 | list = run_with_retries do |
9 | | - # Starting in RabbitMQ 3.6.7 pass in -e to list both implicitly and explicitly enabled plugins. |
10 | | - # If you pass in -E instead, then only explicitly enabled plugins are listed. |
11 | | - # Implicitly enabled plugins are those that were enabled as a dependency of another plugin/ |
12 | | - # If we do not pass in -e then the order if plugin installation matters within the puppet |
13 | | - # code. Example, if Plugin A depends on Plugin B and we install Plugin B first it will |
14 | | - # implicitly enable Plugin A. Then when we go to run Puppet a second time without the |
15 | | - # -e parameter, we won't see Plugin A as being enabled so we'll try to install it again. |
16 | | - # To preserve idempotency we should get all enabled plugins regardless of implicitly or |
17 | | - # explicitly enabled. |
18 | | - if Puppet::Util::Package.versioncmp(rabbitmq_version, '3.6.7') >= 0 |
19 | | - # also pass in -q to suppress informational messages that break our parsing |
20 | | - rabbitmqplugins('list', '-e', '-m', '-q') |
21 | | - else |
22 | | - rabbitmqplugins('list', '-E', '-m') |
| 10 | + begin |
| 11 | + # Starting in RabbitMQ 3.6.7 pass in -e to list both implicitly and explicitly enabled plugins. |
| 12 | + # If you pass in -E instead, then only explicitly enabled plugins are listed. |
| 13 | + # Implicitly enabled plugins are those that were enabled as a dependency of another plugin/ |
| 14 | + # If we do not pass in -e then the order if plugin installation matters within the puppet |
| 15 | + # code. Example, if Plugin A depends on Plugin B and we install Plugin B first it will |
| 16 | + # implicitly enable Plugin A. Then when we go to run Puppet a second time without the |
| 17 | + # -e parameter, we won't see Plugin A as being enabled so we'll try to install it again. |
| 18 | + # To preserve idempotency we should get all enabled plugins regardless of implicitly or |
| 19 | + # explicitly enabled. |
| 20 | + # |
| 21 | + # if we can't determine the running version of rabbitmq, then try the new options |
| 22 | + # vs old options every other time (modulo 2) |
| 23 | + if rabbitmq_running |
| 24 | + if Puppet::Util::Package.versioncmp(rabbitmq_version, '3.6.7') >= 0 |
| 25 | + # also pass in -q to suppress informational messages that break our parsing |
| 26 | + Puppet.info('Running new plugins command because rabbitmq version is good') |
| 27 | + rabbitmqplugins('list', '-e', '-m', '-q') |
| 28 | + else |
| 29 | + Puppet.info('Running new plugins command because rabbitmq version is old') |
| 30 | + rabbitmqplugins('list', '-E', '-m') |
| 31 | + end |
| 32 | + elsif retry_iter.modulo(2).zero? |
| 33 | + Puppet.info('Running new plugins command because rabbitmq isnt running iter mod 0') |
| 34 | + rabbitmqplugins('list', '-e', '-m', '-q') |
| 35 | + else |
| 36 | + Puppet.info('Running new plugins command because rabbitmq isnt running iter mod 1') |
| 37 | + rabbitmqplugins('list', '-E', '-m') |
| 38 | + end |
| 39 | + ensure |
| 40 | + retry_iter += 1 |
23 | 41 | end |
24 | 42 | end |
25 | | - list.split(%r{\n}) |
| 43 | + plugins = list.split(%r{\n}) |
| 44 | + Puppet.info("Existing plugins list: #{plugins}") |
| 45 | + plugins |
26 | 46 | end |
27 | 47 |
|
28 | 48 | def self.instances |
|
0 commit comments