factfill 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +53 -0
- data/README.md +35 -0
- data/README.rdoc +0 -0
- data/Rakefile +44 -0
- data/bin/factfill +46 -0
- data/factfill.gemspec +23 -0
- data/factfill.rdoc +5 -0
- data/features/factfill.feature +8 -0
- data/features/step_definitions/factfill_steps.rb +6 -0
- data/features/support/env.rb +15 -0
- data/lib/factfill/facts.rb +66 -0
- data/lib/factfill/version.rb +3 -0
- data/lib/factfill.rb +5 -0
- data/test/default_test.rb +14 -0
- data/test/test_helper.rb +9 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2ee6b11e9826ae3133659f501b9b757068d2eda7
|
4
|
+
data.tar.gz: 8f20314d593156f164235f494c8437fc9e67f9b0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 80e8d6e7301ec804d9acda6bf42839bfc0303d626092e86cc610b82b17c7713f2c038a03979f4d3cd1c249b34b31d8f79e3f56d92d53055288abe43fc7040da0
|
7
|
+
data.tar.gz: 98c1c05afc293e88f0d5076dac4ff96363986d5ecc28def17f7ba92bc6bfb57faceb93c497166ec8db248c4adc21a1374aa502669b1c266930193b05bcfe8029
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
factfill (0.0.1)
|
5
|
+
gli (= 2.13.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
aruba (0.9.0)
|
11
|
+
childprocess (~> 0.5.6)
|
12
|
+
contracts (~> 0.9)
|
13
|
+
cucumber (>= 1.3.19)
|
14
|
+
ffi (~> 1.9.10)
|
15
|
+
rspec-expectations (>= 2.99)
|
16
|
+
thor (~> 0.19)
|
17
|
+
builder (3.2.2)
|
18
|
+
childprocess (0.5.6)
|
19
|
+
ffi (~> 1.0, >= 1.0.11)
|
20
|
+
contracts (0.12.0)
|
21
|
+
cucumber (2.1.0)
|
22
|
+
builder (>= 2.1.2)
|
23
|
+
cucumber-core (~> 1.3.0)
|
24
|
+
diff-lcs (>= 1.1.3)
|
25
|
+
gherkin3 (~> 3.1.0)
|
26
|
+
multi_json (>= 1.7.5, < 2.0)
|
27
|
+
multi_test (>= 0.1.2)
|
28
|
+
cucumber-core (1.3.0)
|
29
|
+
gherkin3 (~> 3.1.0)
|
30
|
+
diff-lcs (1.2.5)
|
31
|
+
ffi (1.9.10)
|
32
|
+
gherkin3 (3.1.1)
|
33
|
+
gli (2.13.2)
|
34
|
+
json (1.8.3)
|
35
|
+
multi_json (1.11.2)
|
36
|
+
multi_test (0.1.2)
|
37
|
+
rake (10.4.2)
|
38
|
+
rdoc (4.2.0)
|
39
|
+
json (~> 1.4)
|
40
|
+
rspec-expectations (3.3.1)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.3.0)
|
43
|
+
rspec-support (3.3.0)
|
44
|
+
thor (0.19.1)
|
45
|
+
|
46
|
+
PLATFORMS
|
47
|
+
ruby
|
48
|
+
|
49
|
+
DEPENDENCIES
|
50
|
+
aruba
|
51
|
+
factfill!
|
52
|
+
rake
|
53
|
+
rdoc
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
## factfill
|
2
|
+
|
3
|
+
Factfill is a fairly dumb tool that bulk-loads cached facts into PuppetDB.
|
4
|
+
|
5
|
+
The use case this was built for is to import cached facts from one Puppet master to the PuppetDB of a different master, so that you can compile nodes on the second master that only check in to the first master. This faciliates migrations, such as going from an older Puppet 3.3 to Puppet 4.x, where it's difficult to have nodes submit facts to the new infrastructure directly.
|
6
|
+
|
7
|
+
Note that this is pretty rough and has no error handling, test coverage, etc.
|
8
|
+
|
9
|
+
```
|
10
|
+
NAME
|
11
|
+
factfill - Submit cached facts to PuppetDB
|
12
|
+
|
13
|
+
SYNOPSIS
|
14
|
+
factfill [global options] command [command options] [arguments...]
|
15
|
+
|
16
|
+
VERSION
|
17
|
+
0.0.1
|
18
|
+
|
19
|
+
GLOBAL OPTIONS
|
20
|
+
--help - Show this message
|
21
|
+
--version - Display the program version
|
22
|
+
|
23
|
+
COMMANDS
|
24
|
+
help - Shows a list of commands or help for one command
|
25
|
+
submit - Submit yaml-format fact files
|
26
|
+
```
|
27
|
+
|
28
|
+
```shell
|
29
|
+
factfill submit example.yaml
|
30
|
+
submitting example.yaml to localhost:8080
|
31
|
+
Response 200 OK:
|
32
|
+
{
|
33
|
+
"uuid" : "ebe58ec9-16e5-4828-9398-9b8e33827f87"
|
34
|
+
}
|
35
|
+
```
|
data/README.rdoc
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rubygems/package_task'
|
4
|
+
require 'rdoc/task'
|
5
|
+
require 'cucumber'
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
Rake::RDocTask.new do |rd|
|
8
|
+
rd.main = "README.rdoc"
|
9
|
+
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
10
|
+
rd.title = 'Your application title'
|
11
|
+
end
|
12
|
+
|
13
|
+
spec = eval(File.read('factfill.gemspec'))
|
14
|
+
|
15
|
+
Gem::PackageTask.new(spec) do |pkg|
|
16
|
+
end
|
17
|
+
CUKE_RESULTS = 'results.html'
|
18
|
+
CLEAN << CUKE_RESULTS
|
19
|
+
desc 'Run features'
|
20
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
21
|
+
opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
|
22
|
+
opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
|
23
|
+
t.cucumber_opts = opts
|
24
|
+
t.fork = false
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Run features tagged as work-in-progress (@wip)'
|
28
|
+
Cucumber::Rake::Task.new('features:wip') do |t|
|
29
|
+
tag_opts = ' --tags ~@pending'
|
30
|
+
tag_opts = ' --tags @wip'
|
31
|
+
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
|
32
|
+
t.fork = false
|
33
|
+
end
|
34
|
+
|
35
|
+
task :cucumber => :features
|
36
|
+
task 'cucumber:wip' => 'features:wip'
|
37
|
+
task :wip => 'features:wip'
|
38
|
+
require 'rake/testtask'
|
39
|
+
Rake::TestTask.new do |t|
|
40
|
+
t.libs << "test"
|
41
|
+
t.test_files = FileList['test/*_test.rb']
|
42
|
+
end
|
43
|
+
|
44
|
+
task :default => [:test,:features]
|
data/bin/factfill
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'gli'
|
3
|
+
require 'factfill'
|
4
|
+
include GLI::App
|
5
|
+
|
6
|
+
program_desc 'Submit cached facts to PuppetDB'
|
7
|
+
|
8
|
+
version Factfill::VERSION
|
9
|
+
|
10
|
+
subcommand_option_handling :normal
|
11
|
+
arguments :strict
|
12
|
+
|
13
|
+
desc 'Submit yaml-format fact files'
|
14
|
+
arg_name 'YAML file or directory of yaml files'
|
15
|
+
command :submit do |c|
|
16
|
+
c.action do |global_options,options,args|
|
17
|
+
|
18
|
+
args.each do |path|
|
19
|
+
puts "submitting #{path} to localhost:8080"
|
20
|
+
Factfill::Facts.submit(path)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
pre do |global,command,options,args|
|
26
|
+
# Pre logic here
|
27
|
+
# Return true to proceed; false to abort and not call the
|
28
|
+
# chosen command
|
29
|
+
# Use skips_pre before a command to skip this block
|
30
|
+
# on that command only
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
post do |global,command,options,args|
|
35
|
+
# Post logic here
|
36
|
+
# Use skips_post before a command to skip this
|
37
|
+
# block on that command only
|
38
|
+
end
|
39
|
+
|
40
|
+
on_error do |exception|
|
41
|
+
# Error logic here
|
42
|
+
# return false to skip default error handling
|
43
|
+
true
|
44
|
+
end
|
45
|
+
|
46
|
+
exit run(ARGV)
|
data/factfill.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Ensure we require the local version and not one we might have installed already
|
2
|
+
require File.join([File.dirname(__FILE__),'lib','factfill','version.rb'])
|
3
|
+
spec = Gem::Specification.new do |s|
|
4
|
+
s.name = 'factfill'
|
5
|
+
s.version = Factfill::VERSION
|
6
|
+
s.author = 'Your Name Here'
|
7
|
+
s.email = 'your@email.address.com'
|
8
|
+
s.homepage = 'http://your.website.com'
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.summary = 'A description of your project'
|
11
|
+
s.files = `git ls-files`.split("
|
12
|
+
")
|
13
|
+
s.require_paths << 'lib'
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.extra_rdoc_files = ['README.rdoc','factfill.rdoc']
|
16
|
+
s.rdoc_options << '--title' << 'factfill' << '--main' << 'README.rdoc' << '-ri'
|
17
|
+
s.bindir = 'bin'
|
18
|
+
s.executables << 'factfill'
|
19
|
+
s.add_development_dependency('rake')
|
20
|
+
s.add_development_dependency('rdoc')
|
21
|
+
s.add_development_dependency('aruba')
|
22
|
+
s.add_runtime_dependency('gli','2.13.2')
|
23
|
+
end
|
data/factfill.rdoc
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
|
3
|
+
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
4
|
+
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
|
5
|
+
|
6
|
+
Before do
|
7
|
+
# Using "announce" causes massive warnings on 1.9.2
|
8
|
+
@puts = true
|
9
|
+
@original_rubylib = ENV['RUBYLIB']
|
10
|
+
ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
After do
|
14
|
+
ENV['RUBYLIB'] = @original_rubylib
|
15
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'json'
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module Factfill
|
6
|
+
|
7
|
+
class Facts
|
8
|
+
def self.submit(path)
|
9
|
+
submit_dir(path) if File.directory?(path)
|
10
|
+
submit_factfile(path) if File.file?(path)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def self.submit_dir(path)
|
16
|
+
Dir.glob(path + '/*.yaml') do |yaml_file|
|
17
|
+
submit_factfile(yaml_file)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.submit_factfile(filename)
|
22
|
+
data = read_factfile(filename)
|
23
|
+
certname = data['name']
|
24
|
+
values = data['values']
|
25
|
+
environment = data['values']['current_environment']
|
26
|
+
|
27
|
+
payload = {"command" => "replace facts",
|
28
|
+
"version"=>4,"payload"=> {
|
29
|
+
"certname" => certname,
|
30
|
+
"environment" => environment,
|
31
|
+
"values" => values,
|
32
|
+
"producer_timestamp" => Time.now.strftime("%m-%d-%Y")
|
33
|
+
}
|
34
|
+
}
|
35
|
+
host = 'localhost'
|
36
|
+
|
37
|
+
post(host, payload.to_json)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.read_factfile(path)
|
41
|
+
text = ""
|
42
|
+
linenum = 0
|
43
|
+
#path = "pl-lb01-stage.puppetlabs.com.yaml"
|
44
|
+
File.open(path).each_line do |line|
|
45
|
+
# skip first line
|
46
|
+
text += line unless linenum == 0
|
47
|
+
linenum += 1
|
48
|
+
end
|
49
|
+
return YAML.load(text)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.post(host, payload)
|
53
|
+
resource = '/pdb/cmd/v1'
|
54
|
+
port = 8080
|
55
|
+
req = Net::HTTP::Post.new(resource, {
|
56
|
+
'Content-Type' => 'application/json',
|
57
|
+
'Accept' => 'application/json',
|
58
|
+
})
|
59
|
+
req.body = payload
|
60
|
+
response = Net::HTTP.new(host, port).start {|http| http.request(req) }
|
61
|
+
puts "Response #{response.code} #{response.message}:
|
62
|
+
#{response.body}"
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
data/lib/factfill.rb
ADDED
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: factfill
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Your Name Here
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: aruba
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: gli
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.13.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.13.2
|
69
|
+
description:
|
70
|
+
email: your@email.address.com
|
71
|
+
executables:
|
72
|
+
- factfill
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files:
|
75
|
+
- README.rdoc
|
76
|
+
- factfill.rdoc
|
77
|
+
files:
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- README.md
|
81
|
+
- README.rdoc
|
82
|
+
- Rakefile
|
83
|
+
- bin/factfill
|
84
|
+
- factfill.gemspec
|
85
|
+
- factfill.rdoc
|
86
|
+
- features/factfill.feature
|
87
|
+
- features/step_definitions/factfill_steps.rb
|
88
|
+
- features/support/env.rb
|
89
|
+
- lib/factfill.rb
|
90
|
+
- lib/factfill/facts.rb
|
91
|
+
- lib/factfill/version.rb
|
92
|
+
- test/default_test.rb
|
93
|
+
- test/test_helper.rb
|
94
|
+
homepage: http://your.website.com
|
95
|
+
licenses: []
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options:
|
99
|
+
- "--title"
|
100
|
+
- factfill
|
101
|
+
- "--main"
|
102
|
+
- README.rdoc
|
103
|
+
- "-ri"
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.2.2
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: A description of your project
|
123
|
+
test_files: []
|