Skip to content

Commit 82caa5d

Browse files
committed
apply_prep installs openvox-agent via puppet-openvox_bootstrap
1 parent b9bff5a commit 82caa5d

File tree

18 files changed

+77
-75
lines changed

18 files changed

+77
-75
lines changed

Puppetfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ moduledir File.join(File.dirname(__FILE__), 'modules')
66

77
# Core modules used by 'apply'
88
mod 'puppetlabs-service', '3.0.0'
9-
mod 'puppetlabs-puppet_agent', '4.21.0'
9+
mod 'puppet-openvox_bootstrap', '1.0.0'
1010
mod 'puppetlabs-facts', '1.6.0'
1111

1212
# Core types and providers for Puppet 6

bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
require 'bolt/logger'
44
require 'bolt/task'
55

6-
# Installs the `puppet-agent` package on targets if needed, then collects facts,
6+
# Installs the `openvox-agent` package on targets if needed, then collects facts,
77
# including any custom facts found in Bolt's module path. The package is
88
# installed using either the configured plugin or the `task` plugin with the
9-
# `puppet_agent::install` task.
9+
# `openvox_bootstrap::install` task.
1010
#
11-
# Agent installation will be skipped if the target includes the `puppet-agent`
12-
# feature, either as a property of its transport (PCP) or by explicitly setting
11+
# Agent installation will be skipped if the target includes either the `openvox-agent`
12+
# or the `puppet-agent`
13+
# feature, either as a property of its transport or by explicitly setting
1314
# it as a feature in Bolt's inventory.
1415
#
1516
# > **Note:** Not available in apply block
@@ -66,10 +67,11 @@ def run_task(targets, task, args = {}, options = {})
6667
executor.run_task(targets, task, args, options)
6768
end
6869

69-
# Returns true if the target has the puppet-agent feature defined, either from
70+
# Returns true if the target has the openvox-agent or the puppet-agent feature defined, either from
7071
# inventory or transport.
7172
#
7273
private def agent?(target)
74+
inventory.features(target).include?('openvox-agent') ||
7375
inventory.features(target).include?('puppet-agent') ||
7476
executor.transport(target.transport).provided_features.include?('puppet-agent') ||
7577
target.remote?
@@ -93,15 +95,15 @@ def run_task(targets, task, args = {}, options = {})
9395
Puppet::Pops::Types::PSensitiveType::Sensitive.new(tarball)
9496
end
9597

96-
# Install the puppet-agent package on targets that need it.
98+
# Install the openvox-agent package on targets that need it.
9799
#
98100
private def install_agents(targets, options)
99101
results = []
100102

101103
agent_targets, agentless_targets = targets.partition { |target| agent?(target) }
102104

103105
agent_targets.each do |target|
104-
Puppet.debug("Puppet Agent feature declared for #{target}")
106+
Puppet.debug("openvox-agent or puppet-agent feature declared for #{target}")
105107
results << Bolt::Result.new(target)
106108
end
107109

@@ -111,7 +113,7 @@ def run_task(targets, task, args = {}, options = {})
111113

112114
hook_results.each do |result|
113115
next unless result.ok?
114-
inventory.set_feature(result.target, 'puppet-agent')
116+
inventory.set_feature(result.target, 'openvox-agent')
115117
end
116118

117119
results.concat(hook_results).concat(errors)

bolt-modules/boltlib/lib/puppet/functions/get_resources.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# The results are returned as a list of hashes representing each resource.
77
#
88
# Requires the Puppet Agent be installed on the target, which can be accomplished with apply_prep
9-
# or by directly running the `puppet_agent::install` task. In order to be able to reference types without
9+
# or by directly running the `openvox_bootstrap::install` task. In order to be able to reference types without
1010
# string quoting (for example `get_resources($target, Package)` instead of `get_resources($target, 'Package')`),
1111
# run the command `bolt puppetfile generate-types` to generate type references in `$Boldir/.resource_types`.
1212
#

bolt-modules/boltlib/lib/puppet/functions/set_feature.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
# Supported features are:
99
# - `powershell`
1010
# - `shell`
11-
# - `puppet-agent`
11+
# - `openvox-agent`
1212
#
1313
# > **Note:** Not available in apply block
1414
Puppet::Functions.create_function(:set_feature) do
1515
# @param target The Target object to add features to. See {get_targets}.
1616
# @param feature The string identifying the feature.
1717
# @param value Whether the feature is supported.
1818
# @return The target with the updated feature
19-
# @example Add the `puppet-agent` feature to a target
20-
# set_feature($target, 'puppet-agent', true)
19+
# @example Add the `openvox-agent` feature to a target
20+
# set_feature($target, 'openvox-agent', true)
2121
dispatch :set_feature do
2222
param 'Target', :target
2323
param 'String', :feature

bolt-modules/boltlib/spec/functions/apply_prep_spec.rb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,31 @@
3636
let(:unknown_targets) { targets.reject { |target| target.protocol == 'pcp' } }
3737
let(:fact) { { 'osfamily' => 'none' } }
3838
let(:custom_facts_task) { Bolt::Task.new('custom_facts_task') }
39-
let(:version_task) { Bolt::Task.new('puppet_agent::version') }
40-
let(:install_task) { Bolt::Task.new('puppet_agent::install') }
39+
let(:version_task) { Bolt::Task.new('openvox_bootstrap::check') }
40+
let(:install_task) { Bolt::Task.new('openvox_bootstrap::install') }
4141
let(:service_task) { Bolt::Task.new('service') }
4242

4343
before(:each) do
4444
applicator.stubs(:build_plugin_tarball).returns(:tarball)
4545
applicator.stubs(:custom_facts_task).returns(custom_facts_task)
4646
inventory.get_targets(targets)
47-
targets.each { |t| inventory.set_feature(t, 'puppet-agent', false) }
47+
targets.each { |t| inventory.set_feature(t, 'openvox-agent', false) }
4848

4949
task1 = mock('version_task')
50-
task1.stubs(:task_hash).returns('name' => 'puppet_agent::version')
50+
task1.stubs(:task_hash).returns('name' => 'openvox_bootstrap::check')
5151
task1.stubs(:runnable_with?).returns(true)
52-
Puppet::Pal::ScriptCompiler.any_instance.stubs(:task_signature).with('puppet_agent::version').returns(task1)
52+
Puppet::Pal::ScriptCompiler.any_instance.stubs(:task_signature).with('openvox_bootstrap::check').returns(task1)
5353
task2 = mock('install_task')
54-
task2.stubs(:task_hash).returns('name' => 'puppet_agent::install')
54+
task2.stubs(:task_hash).returns('name' => 'openvox_bootstrap::install')
5555
task2.stubs(:runnable_with?).returns(true)
56-
Puppet::Pal::ScriptCompiler.any_instance.stubs(:task_signature).with('puppet_agent::install').returns(task2)
56+
Puppet::Pal::ScriptCompiler.any_instance.stubs(:task_signature).with('openvox_bootstrap::install').returns(task2)
5757
task3 = mock('service_task')
5858
task3.stubs(:task_hash).returns('name' => 'service')
5959
task3.stubs(:runnable_with?).returns(true)
6060
Puppet::Pal::ScriptCompiler.any_instance.stubs(:task_signature).with('service').returns(task3)
6161
end
6262

63-
it 'sets puppet-agent feature and gathers facts' do
63+
it 'sets openvox-agent feature and gathers facts' do
6464
facts = Bolt::ResultSet.new(targets.map { |t| Bolt::Result.new(t, value: fact) })
6565
executor.expects(:run_task)
6666
.with(anything, custom_facts_task, includes('plugins'), {})
@@ -73,7 +73,7 @@
7373

7474
is_expected.to run.with_params(hostnames.join(','))
7575
targets.each do |target|
76-
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'pcp'
76+
expect(inventory.features(target)).to include('openvox-agent') unless target.transport == 'pcp'
7777
expect(inventory.facts(target)).to eq(fact)
7878
end
7979
end
@@ -91,7 +91,7 @@
9191

9292
is_expected.to run.with_params(hostnames, '_run_as' => 'root')
9393
targets.each do |target|
94-
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'pcp'
94+
expect(inventory.features(target)).to include('openvox-agent') unless target.transport == 'pcp'
9595
expect(inventory.facts(target)).to eq(fact)
9696
end
9797
end
@@ -109,7 +109,7 @@
109109

110110
is_expected.to run.with_params(hostnames, '_noop' => true)
111111
targets.each do |target|
112-
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'pcp'
112+
expect(inventory.features(target)).to include('openvox-agent') unless target.transport == 'pcp'
113113
expect(inventory.facts(target)).to eq(fact)
114114
end
115115
end
@@ -141,7 +141,7 @@
141141
'plugin_hooks' => {
142142
'puppet_library' => {
143143
'plugin' => 'task',
144-
'task' => 'puppet_agent::install'
144+
'task' => 'openvox_bootstrap::install'
145145
}
146146
}
147147
}]
@@ -161,7 +161,7 @@
161161
.returns(task_hook)
162162

163163
is_expected.to run.with_params(hostname)
164-
expect(inventory.features(target)).to include('puppet-agent')
164+
expect(inventory.features(target)).to include('openvox-agent')
165165
expect(inventory.facts(target)).to eq(fact)
166166
end
167167
end
@@ -192,7 +192,7 @@
192192
.returns(task_hook)
193193

194194
is_expected.to run.with_params(hostname)
195-
expect(inventory.features(target)).to include('puppet-agent')
195+
expect(inventory.features(target)).to include('openvox-agent')
196196
expect(inventory.facts(target)).to eq(fact)
197197
end
198198
end
@@ -217,13 +217,13 @@
217217

218218
is_expected.to run.with_params(hostnames.join(','))
219219
targets.each do |target|
220-
expect(inventory.features(target)).to include('puppet-agent') unless target.transport == 'pcp'
220+
expect(inventory.features(target)).to include('openvox-agent') unless target.transport == 'pcp'
221221
expect(inventory.facts(target)).to eq(fact)
222222
end
223223
end
224224
end
225225

226-
context 'with targets assigned the puppet-agent feature' do
226+
context 'with targets assigned the openvox-agent feature' do
227227
let(:hostnames) { %w[foo bar] }
228228
let(:targets) { hostnames.map { |h| inventory.get_target(h) } }
229229
let(:fact) { { 'osfamily' => 'none' } }
@@ -232,7 +232,7 @@
232232
before(:each) do
233233
applicator.stubs(:build_plugin_tarball).returns(:tarball)
234234
applicator.stubs(:custom_facts_task).returns(custom_facts_task)
235-
targets.each { |target| inventory.set_feature(target, 'puppet-agent') }
235+
targets.each { |target| inventory.set_feature(target, 'openvox-agent') }
236236
end
237237

238238
it 'sets feature and gathers facts' do
@@ -243,7 +243,7 @@
243243

244244
is_expected.to run.with_params(hostnames.join(','))
245245
targets.each do |target|
246-
expect(inventory.features(target)).to include('puppet-agent')
246+
expect(inventory.features(target)).to include('openvox-agent')
247247
expect(inventory.facts(target)).to eq(fact)
248248
end
249249
end
@@ -258,7 +258,7 @@
258258
before(:each) do
259259
applicator.stubs(:build_plugin_tarball).returns(:tarball)
260260
applicator.stubs(:custom_facts_task).returns(custom_facts_task)
261-
targets.each { |target| inventory.set_feature(target, 'puppet-agent') }
261+
targets.each { |target| inventory.set_feature(target, 'openvox-agent') }
262262
end
263263

264264
it 'only uses required plugins' do

lib/bolt/inventory/target.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def set_local_defaults
6565
old_config = @config
6666
@config = Bolt::Util.deep_merge(defaults, @config)
6767
invalidate_config_cache! if old_config != @config
68-
set_feature('puppet-agent')
68+
set_feature('openvox-agent')
6969
@set_local_default = true
7070
end
7171

lib/bolt/pal.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ def plan_hierarchy_lookup(key, plan_vars: {})
792792
end
793793

794794
def lookup(key, targets, inventory, executor, plan_vars: {})
795-
# Install the puppet-agent package and collect facts. Facts are
795+
# Install the openvox-agent package and collect facts. Facts are
796796
# automatically added to the targets.
797797
in_plan_compiler(executor, inventory, nil) do |compiler|
798798
compiler.call_function('apply_prep', targets)

spec/bolt_spec/run_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
end
106106
end
107107

108-
context 'with a target that has a puppet-agent installed' do
108+
context 'with a target that has a openvox-agent installed' do
109109
def root_config
110110
{ 'ssh' => {
111111
'run-as' => 'root',
@@ -115,22 +115,22 @@ def root_config
115115
end
116116

117117
before(:all) do
118-
result = run_task('puppet_agent::version', 'ssh', {}, inventory: conn_inventory, config: root_config)
118+
result = run_task('openvox_bootstrap::check', 'ssh', {}, inventory: conn_inventory, config: root_config)
119119
expect(result.first['status']).to eq('success')
120120
unless result.first['value']['version']
121-
result = run_task('puppet_agent::install', 'ssh', {}, inventory: conn_inventory, config: root_config)
121+
result = run_task('openvox_bootstrap::install', 'ssh', {}, inventory: conn_inventory, config: root_config)
122122
end
123123
expect(result.first['status']).to eq('success')
124124
end
125125

126126
after(:all) do
127-
uninstall = '/opt/puppetlabs/bin/puppet resource package puppet-agent ensure=absent'
127+
uninstall = '/opt/puppetlabs/bin/puppet resource package openvox-agent ensure=absent'
128128
run_command(uninstall, 'ssh', inventory: conn_inventory, config: root_config)
129129
end
130130

131131
describe 'apply_manifest' do
132132
it 'should apply a manifest file' do
133-
bolt_inventory['features'] = ['puppet-agent']
133+
bolt_inventory['features'] = ['openvox-agent']
134134
with_tempfile_containing('manifest', "notify { 'hello world': }", '.pp') do |manifest|
135135
results = apply_manifest(manifest.path, 'ssh')
136136
results.each do |result|
@@ -142,7 +142,7 @@ def root_config
142142
end
143143

144144
it 'should apply a manifest code block' do
145-
bolt_inventory['features'] = ['puppet-agent']
145+
bolt_inventory['features'] = ['openvox-agent']
146146
results = apply_manifest("notify { 'hello world': }", 'ssh', execute: true)
147147
results.each do |result|
148148
expect(result['status']).to eq('success')
@@ -152,15 +152,15 @@ def root_config
152152
end
153153

154154
it 'should raise an error when manifest file does not exist' do
155-
bolt_inventory['features'] = ['puppet-agent']
155+
bolt_inventory['features'] = ['openvox-agent']
156156
expect do
157157
apply_manifest("missing.na", 'ssh')
158158
end.to raise_error(Bolt::FileError)
159159
bolt_inventory.delete('features')
160160
end
161161

162162
it 'should return a failure' do
163-
bolt_inventory['features'] = ['puppet-agent']
163+
bolt_inventory['features'] = ['openvox-agent']
164164
results = apply_manifest("fail()", 'ssh', execute: true)
165165
results.each do |result|
166166
expect(result['status']).to eq('failure')

spec/integration/apply_error_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
let(:tflags) { %w[--no-host-key-check] }
2020

2121
it 'prints a helpful error if Puppet is not present' do
22-
uninstall = '/opt/puppetlabs/bin/puppet resource package puppet-agent ensure=absent'
22+
uninstall = '/opt/puppetlabs/bin/puppet resource package openvox-agent ensure=absent'
2323
run_cli_json(%W[command run #{uninstall} --run-as root --sudo-password #{password}] + config_flags)
2424

2525
result = run_cli_json(%w[plan run basic::class] + config_flags)

spec/integration/apply_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
let(:user) { conn_info('ssh')[:user] }
7676
let(:password) { conn_info('ssh')[:password] }
7777

78-
# Run tests that require the puppet-agent package to be installed on the target.
78+
# Run tests that require the openvox-agent package to be installed on the target.
7979
# Each test is run against all agent targets unless otherwise noted.
8080
context 'with puppet installed' do
8181
# Set up a project directory for the tests. Include an inventory file so Bolt
@@ -304,7 +304,7 @@
304304
end
305305
end
306306

307-
# Run tests for installing the puppet-agent package using apply_prep.
307+
# Run tests for installing the openvox-agent package using apply_prep.
308308
context 'installing puppet' do
309309
let(:config) do
310310
{
@@ -391,7 +391,7 @@
391391
'plugin_hooks' => {
392392
'puppet_library' => {
393393
'plugin' => 'task',
394-
'task' => 'puppet_agent::install',
394+
'task' => 'openvox_bootstrap::install',
395395
'parameters' => {
396396
'version' => '7.0.0'
397397
}
@@ -412,7 +412,7 @@
412412
report = result[0]['value']['report']
413413
expect(report['resource_statuses']).to include("Notify[Hello #{uri}]")
414414

415-
results = run_cli_json(%W[task run puppet_agent::version -t #{uri}], project: project)
415+
results = run_cli_json(%W[task run openvox_bootstrap::check -t #{uri}], project: project)
416416

417417
result = results['items']
418418
expect(result.count).to eq(1)

0 commit comments

Comments
 (0)