bolt 0.18.1 → 0.18.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bolt might be problematic. Click here for more details.

@@ -16,11 +16,11 @@ plan aggregate::count(
16
16
  }
17
17
 
18
18
  if ($type_count == 0) {
19
- fail_plan("Must specify a command, script, or task to run", 'canary/invalid-params')
19
+ fail_plan("Must specify a command, script, or task to run", 'aggregate/invalid-params')
20
20
  }
21
21
 
22
22
  if ($type_count > 1) {
23
- fail_plan("Must specify only one command, script, or task to run", 'canary/invalid-params')
23
+ fail_plan("Must specify only one command, script, or task to run", 'aggregate/invalid-params')
24
24
  }
25
25
 
26
26
  $res = if ($task) {
@@ -16,11 +16,11 @@ plan aggregate::nodes(
16
16
  }
17
17
 
18
18
  if ($type_count == 0) {
19
- fail_plan("Must specify a command, script, or task to run", 'canary/invalid-params')
19
+ fail_plan("Must specify a command, script, or task to run", 'aggregate/invalid-params')
20
20
  }
21
21
 
22
22
  if ($type_count > 1) {
23
- fail_plan("Must specify only one command, script, or task to run", 'canary/invalid-params')
23
+ fail_plan("Must specify only one command, script, or task to run", 'aggregate/invalid-params')
24
24
  }
25
25
 
26
26
  $res = if ($task) {
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A simple wrapper of the ruby's group_by function.
4
+ Puppet::Functions.create_function(:'facts::group_by') do
5
+ dispatch :native_group_by do
6
+ param 'Iterable', :collection
7
+ block_param
8
+ return_type 'Hash'
9
+ end
10
+
11
+ def native_group_by(collection, &block)
12
+ collection.group_by(&block)
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ # A plan that prints basic OS information for the specified nodes. It first
2
+ # runs the facts::retrieve plan to retrieve facts from the nodes, then
3
+ # compiles the desired OS information from the os fact value of each nodes.
4
+ #
5
+ # The $nodes parameter is a list of the nodes for which to print the OS
6
+ # information.
7
+ plan facts::info(TargetSpec $nodes) {
8
+ run_plan(facts::retrieve, nodes => $nodes).reduce([]) |$info, $r| {
9
+ if ($r.ok) {
10
+ $info + "${r.target.name}: ${r[os][name]} ${r[os][release][full]} (${r[os][family]})"
11
+ } else {
12
+ $info # don't include any info for nodes which failed
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,16 @@
1
+ # A plan that stores facts retrieved by the facts::retrieve plan
2
+ # from the specified nodes into the inventory.
3
+ #
4
+ # The $nodes parameter is a list of nodes to retrieve the facts for.
5
+ plan facts(TargetSpec $nodes) {
6
+ $result_set = run_plan(facts::retrieve, nodes => $nodes)
7
+
8
+ $result_set.each |$result| {
9
+ # Store facts for nodes from which they were succefully retrieved
10
+ if ($result.ok) {
11
+ add_facts($result.target, $result.value)
12
+ }
13
+ }
14
+
15
+ $result_set
16
+ }
@@ -0,0 +1,32 @@
1
+ # A plan that retrieves facts from the specified nodes by running
2
+ # an appropriate facts::* task on each. Care is taken to run a
3
+ # facts::* task corresponding to the node's platfrom on each
4
+ # node.
5
+ #
6
+ # The $nodes parameter is a list of the nodes to retrieve the facts
7
+ # from.
8
+ plan facts::retrieve(TargetSpec $nodes) {
9
+ $targets = get_targets($nodes)
10
+
11
+ # Build a mapping from the names of the tasks to run to the lists of
12
+ # targets to run the tasks on
13
+ $task_targets = $targets.facts::group_by |$target| {
14
+ $target.protocol ? {
15
+ 'ssh' => 'facts::bash',
16
+ 'winrm' => 'facts::powershell',
17
+ 'pcp' => 'facts::ruby',
18
+ 'local' => 'facts::bash',
19
+ }
20
+ }
21
+
22
+ # Return a single result set composed of results from the result sets
23
+ # returned by the individual task runs.
24
+ ResultSet(
25
+ $task_targets.map |$task, $targets| {
26
+ run_task($task, $targets, '_catch_errors' => true)
27
+ }.reduce([]) |$results, $result_set| {
28
+ # Collect the results from the individual result sets
29
+ $results + $result_set.results
30
+ }
31
+ )
32
+ }
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Delegate to facter if available
4
+ command -v facter > /dev/null 2>&1 && exec facter --json
5
+
6
+ minor () {
7
+ minor="${*#*.}"
8
+ [ "$minor" == "$*" ] || echo "${minor%%.*}"
9
+ }
10
+
11
+ # Determine the OS name
12
+ if [ -f /etc/redhat-release ]; then
13
+ if egrep -iq centos /etc/redhat-release; then
14
+ name=CentOS
15
+ elif egrep -iq 'Fedora release' /etc/redhat-release; then
16
+ name=Fedora
17
+ fi
18
+ release=$(sed -r -e 's/^.* release ([0-9]+(\.[0-9]+)?).*$/\1/' \
19
+ /etc/redhat-release)
20
+ fi
21
+
22
+ if [ -z "${name}" ]; then
23
+ LSB_RELEASE=$(command -v lsb_release)
24
+ if [ -n "$LSB_RELEASE" ]; then
25
+ if [ -z "$name" ]; then
26
+ name=$($LSB_RELEASE -i | sed -re 's/^.*:[ \t]*//')
27
+ fi
28
+ release=$($LSB_RELEASE -r | sed -re 's/^.*:[ \t]*//')
29
+ fi
30
+ fi
31
+
32
+ if [ -z "${name}" ]; then
33
+ name=$(uname)
34
+ release=$(uname -r)
35
+ fi
36
+
37
+ case $name in
38
+ RedHat|Fedora|CentOS|Scientific|SLC|Ascendos|CloudLinux)
39
+ family=RedHat;;
40
+ HuaweiOS|LinuxMint|Ubuntu|Debian)
41
+ family=Debian;;
42
+ *)
43
+ family=$name;;
44
+ esac
45
+
46
+ # Print it all out
47
+ if [ -z "$name" ]; then
48
+ cat <<JSON
49
+ {
50
+ "_error": {
51
+ "kind": "facts/noname",
52
+ "msg": "Could not determine OS name"
53
+ }
54
+ }
55
+ JSON
56
+ else
57
+ cat <<JSON
58
+ {
59
+ "os": {
60
+ "name": "${name}",
61
+ JSON
62
+ [ -n "$release" ] && cat <<JSON
63
+ "release": {
64
+ "full": "${release}",
65
+ "major": "${release%%.*}",
66
+ "minor": "`minor "${release}"`"
67
+ },
68
+ JSON
69
+ cat <<JSON
70
+ "family": "${family}"
71
+ }
72
+ }
73
+ JSON
74
+ fi
@@ -0,0 +1,61 @@
1
+ #!powershell.exe
2
+
3
+ # Delegate to facter if available
4
+ if (Get-Command facter -ErrorAction SilentlyContinue) {
5
+ facter --json
6
+ }
7
+ else {
8
+ if ([System.Environment]::OSVersion.Platform -gt 2) {
9
+ # [System.PlatformID]::Win32NT
10
+ @'
11
+ {
12
+ "_error": {
13
+ "kind": "facts/noname",
14
+ "msg": "Could not determine OS name"
15
+ }
16
+ }
17
+ '@
18
+ }
19
+ else {
20
+ $release = [System.Environment]::OSVersion.Version.ToString() -replace '\.[^.]*\z'
21
+ $version = $release -replace '\.[^.]*\z'
22
+
23
+ # This fails for regular users unless explicitly enabled
24
+ $os = Get-CimInstance Win32_OperatingSystem -ErrorAction SilentlyContinue
25
+ $consumerrel = $os.ProductType -eq '1'
26
+
27
+ if ($version -eq '10.0') {
28
+ $release = if ($consumerrel) { '10' } else { '2016' }
29
+ }
30
+ elseif ($version -eq '6.3') {
31
+ $release = if ($consumerrel) { '8.1' } else { '2012 R2' }
32
+ }
33
+ elseif ($version -eq '6.2') {
34
+ $release = if ($consumerrel) { '8' } else { '2012' }
35
+ }
36
+ elseif ($version -eq '6.1') {
37
+ $release = if ($consumerrel) { '7' } else { '2008 R2' }
38
+ }
39
+ elseif ($version -eq '6.0') {
40
+ $release = if ($consumerrel) { 'Vista' } else { '2008' }
41
+ }
42
+ elseif ($version -eq '5.2') {
43
+ $release = if ($consumerrel) { 'XP' } else {
44
+ if ($os.OtherTypeDescription -eq 'R2') { '2003 R2' } else { '2003' }
45
+ }
46
+ }
47
+
48
+ @"
49
+ {
50
+ "os": {
51
+ "name": "windows",
52
+ "release": {
53
+ "full": "$release",
54
+ "major": "$release"
55
+ },
56
+ "family": "windows"
57
+ }
58
+ }
59
+ "@
60
+ }
61
+ }
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ def facter_executable
5
+ if ENV.key? 'Path'
6
+ ENV['Path'].split(';').each do |p|
7
+ if p =~ /Puppet\\bin\\?$/
8
+ return File.join(p, 'facter')
9
+ end
10
+ end
11
+ 'C:\Program Files\Puppet Labs\Puppet\bin\facter'
12
+ else
13
+ '/opt/puppetlabs/puppet/bin/facter'
14
+ end
15
+ end
16
+
17
+ # Delegate to facter
18
+ exec(facter_executable, '--json')
@@ -7,4 +7,4 @@ plan puppetdb_fact(TargetSpec $nodes) {
7
7
  }
8
8
 
9
9
  return $pdb_facts
10
- }
10
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.1
4
+ version: 0.18.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-29 00:00:00.000000000 Z
11
+ date: 2018-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -367,6 +367,7 @@ files:
367
367
  - lib/bolt/transport/winrm.rb
368
368
  - lib/bolt/transport/winrm/connection.rb
369
369
  - lib/bolt/util.rb
370
+ - lib/bolt/util/on_access.rb
370
371
  - lib/bolt/version.rb
371
372
  - lib/bolt_ext/puppetdb_inventory.rb
372
373
  - modules/aggregate/lib/puppet/functions/aggregate/count.rb
@@ -377,6 +378,13 @@ files:
377
378
  - modules/canary/lib/puppet/functions/canary/random_split.rb
378
379
  - modules/canary/lib/puppet/functions/canary/skip.rb
379
380
  - modules/canary/plans/init.pp
381
+ - modules/facts/lib/puppet/functions/facts/group_by.rb
382
+ - modules/facts/plans/info.pp
383
+ - modules/facts/plans/init.pp
384
+ - modules/facts/plans/retrieve.pp
385
+ - modules/facts/tasks/bash.sh
386
+ - modules/facts/tasks/powershell.ps1
387
+ - modules/facts/tasks/ruby.rb
380
388
  - modules/puppetdb_fact/plans/init.pp
381
389
  - vendored/facter/lib/facter.rb
382
390
  - vendored/facter/lib/facter/Cfkey.rb