arfor 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -0
- data/arfor.gemspec +5 -0
- data/exe/arfor +11 -0
- data/lib/arfor/control_repo.rb +1 -0
- data/lib/arfor/github_module.rb +104 -0
- data/lib/arfor/platform_installer.rb +2 -3
- data/lib/arfor/util/github.rb +49 -0
- data/lib/arfor/version.rb +1 -1
- data/lib/arfor.rb +9 -0
- data/res/puppet_module/README.md.erb +46 -0
- metadata +74 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37e69a377781896f58d64cf952d3d3adb5354ba9
|
4
|
+
data.tar.gz: 5ad856f55141de3e2aac963903fcb5910e9bf491
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 768207f612154e3a9e06171f7ee78fe92e0c599596b5ef3754a4d06debc0d2bd05b60f42b0ed5e3692963178b29db867d3c1010649b58921fef6105bb6c4fe68
|
7
|
+
data.tar.gz: 300175aa21e004da8fa7f38dd3719cf844ee7e8367be9762fe99e3ae2d19cddaee0ce50c3651489425febc2a615ccb8050059e8de9e209f267626b9f4da63e39
|
data/README.md
CHANGED
@@ -22,6 +22,20 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
+
### Making control repositories
|
26
|
+
```
|
27
|
+
arfor control_repo
|
28
|
+
```
|
29
|
+
|
30
|
+
#### Control Repository features
|
31
|
+
* Fully documented
|
32
|
+
* Based on upstream puppetlabs example
|
33
|
+
* Built-in onceover support
|
34
|
+
* Built-in mock-Puppetfile for use by onceover during testing
|
35
|
+
* Hieradata validation
|
36
|
+
* Creates a local git repo with master branch replaced with production
|
37
|
+
|
38
|
+
|
25
39
|
### Agent installers
|
26
40
|
#### PE 2016.4.2 (LTS)
|
27
41
|
```
|
data/arfor.gemspec
CHANGED
@@ -31,4 +31,9 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_runtime_dependency "escort", "0.4.0"
|
32
32
|
spec.add_runtime_dependency "pe_info", "0.1.4"
|
33
33
|
spec.add_runtime_dependency 'ruby-progressbar', '1.8.1'
|
34
|
+
spec.add_runtime_dependency "octokit", "~> 4.0"
|
35
|
+
spec.add_runtime_dependency "highline", "1.7.8"
|
36
|
+
spec.add_runtime_dependency "puppet"
|
37
|
+
spec.add_runtime_dependency "pdqtest", "0.4.3"
|
38
|
+
spec.add_runtime_dependency "travis"
|
34
39
|
end
|
data/exe/arfor
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
+
# Copyright 2017 Geoff Williams for Declarative Systems PTY LTD
|
3
4
|
# Copyright 2016 Geoff Williams for Puppet Inc.
|
4
5
|
#
|
5
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -21,6 +22,7 @@ require 'arfor/gems'
|
|
21
22
|
require 'arfor/platform_installer'
|
22
23
|
require 'pe_info/tarball'
|
23
24
|
require 'arfor/control_repo'
|
25
|
+
require 'arfor/github_module'
|
24
26
|
|
25
27
|
# display help if nothing specified
|
26
28
|
ARGV.push('-h') if ARGV.empty?
|
@@ -116,5 +118,14 @@ Escort::App.create do |app|
|
|
116
118
|
Arfor::ControlRepo::create()
|
117
119
|
end
|
118
120
|
end
|
121
|
+
|
122
|
+
app.command :github_module do |command|
|
123
|
+
command.summary "Github Module"
|
124
|
+
command.description "Create a new Puppet module enabled with PDQTest and upload to GitHub"
|
125
|
+
command.action do |options, arguments|
|
126
|
+
puts Arfor::GithubModule::create()
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
119
130
|
end
|
120
131
|
end
|
data/lib/arfor/control_repo.rb
CHANGED
@@ -0,0 +1,104 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright 2017 Geoff Williams for Declarative Systems PTY LTD
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
require 'octokit'
|
17
|
+
require "highline/import"
|
18
|
+
require "arfor/util/github"
|
19
|
+
require "json"
|
20
|
+
|
21
|
+
module Arfor
|
22
|
+
module GithubModule
|
23
|
+
PUPPET_METADATA = 'metadata.json'
|
24
|
+
README_FILE = 'README.md'
|
25
|
+
README_ERB = "../../res/puppet_module/#{README_FILE}.erb"
|
26
|
+
|
27
|
+
def self.create()
|
28
|
+
|
29
|
+
# http://stackoverflow.com/a/2889747/3441106
|
30
|
+
forge_name = ask("#{Arfor::QUESTION} Forge module name: ") do |q|
|
31
|
+
q.validate = /[\w_]+-[\w_]+/
|
32
|
+
end
|
33
|
+
description = ask("#{Arfor::QUESTION} Module description: ")
|
34
|
+
|
35
|
+
forge_name_split = forge_name.split('-')
|
36
|
+
forge_user = forge_name_split[0]
|
37
|
+
module_name = forge_name_split[1]
|
38
|
+
|
39
|
+
git_name = "puppet-#{module_name}"
|
40
|
+
|
41
|
+
git_opts = {
|
42
|
+
:description => description,
|
43
|
+
}
|
44
|
+
|
45
|
+
# Step 1 - generate puppet module
|
46
|
+
if system("puppet module generate --skip-interview #{forge_name}")
|
47
|
+
|
48
|
+
Dir.chdir(module_name) {
|
49
|
+
|
50
|
+
# temporary ;-) fix for needing to replace the Gemfile
|
51
|
+
File.delete('Gemfile')
|
52
|
+
|
53
|
+
# Step 2 - install PDQtest
|
54
|
+
system("pdqtest init")
|
55
|
+
|
56
|
+
# Step 3 - make remote git repo
|
57
|
+
begin
|
58
|
+
resp = Arfor::Util::Github::create_repository(git_name, git_opts)
|
59
|
+
full_name = resp.full_name
|
60
|
+
rescue Octokit::UnprocessableEntity => e
|
61
|
+
raise "Repository creation error: #{e.message}"
|
62
|
+
end
|
63
|
+
|
64
|
+
# Step 4 - doco template
|
65
|
+
template = File.read(File.join(File.dirname(File.expand_path(__FILE__)), README_ERB))
|
66
|
+
content = ERB.new(template, nil, '-').result(binding)
|
67
|
+
File.write(README_FILE, content)
|
68
|
+
|
69
|
+
# Step 5 - checkout local copy of git repo, merge changes and upload
|
70
|
+
system("git init && git remote add origin #{resp.clone_url}")
|
71
|
+
|
72
|
+
# Step 6 - update puppet metdata.json with settings from git
|
73
|
+
metadata = JSON.parse(File.read(PUPPET_METADATA))
|
74
|
+
metadata['source'] = resp.clone_url
|
75
|
+
metadata['project_url'] = resp.clone_url
|
76
|
+
metadata['issues_url'] = resp.issues_url
|
77
|
+
metadata['summary'] = description
|
78
|
+
File.write(PUPPET_METADATA, JSON.pretty_generate(metadata))
|
79
|
+
|
80
|
+
# Step 7 - cleanup backup crud files
|
81
|
+
Dir.glob("**/*.pdqtest_old").each { |f|
|
82
|
+
File.delete(f)
|
83
|
+
}
|
84
|
+
|
85
|
+
# Step 8 - Enable travis (you need to have already logged yourself in)
|
86
|
+
# the sleep is to allow time for the apis to settle before travis does
|
87
|
+
# its scans
|
88
|
+
puts "sleep for sync"
|
89
|
+
sleep(30)
|
90
|
+
system("travis enable --no-interactive")
|
91
|
+
|
92
|
+
# Step 9 - initial git commit and upload changes
|
93
|
+
system("git add -A && git commit -m 'initial' && git push origin master")
|
94
|
+
}
|
95
|
+
else
|
96
|
+
raise "module generation error"
|
97
|
+
end
|
98
|
+
|
99
|
+
Arfor::OK
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
@@ -19,7 +19,6 @@ require 'etc'
|
|
19
19
|
module Arfor
|
20
20
|
module PlatformInstaller
|
21
21
|
BASE_URL = "https://pm.puppetlabs.com/cgi-bin/download.cgi?"
|
22
|
-
LICENCE_FILE = "#{Etc.getpwuid.dir}/.arfor/licence.key"
|
23
22
|
BASE_TARGET = "puppet-enterprise-"
|
24
23
|
SUFFIX_TARGET = ".tar.gz"
|
25
24
|
|
@@ -30,8 +29,8 @@ module Arfor
|
|
30
29
|
|
31
30
|
def self.licence_check
|
32
31
|
licenced = false
|
33
|
-
if File.exist?(LICENCE_FILE)
|
34
|
-
licenced = File.foreach(LICENCE_FILE).grep(/thanks for registering/)
|
32
|
+
if File.exist?(Arfor::LICENCE_FILE)
|
33
|
+
licenced = File.foreach(Arfor::LICENCE_FILE).grep(/thanks for registering/)
|
35
34
|
end
|
36
35
|
|
37
36
|
if ! licenced
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright 2017 Geoff Williams for Declarative Systems PTY LTD
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require "highline/import"
|
18
|
+
|
19
|
+
module Arfor
|
20
|
+
module Util
|
21
|
+
module Github
|
22
|
+
|
23
|
+
def self.read_token
|
24
|
+
if File.exists?(Arfor::TOKEN_FILE)
|
25
|
+
token = File.read(Arfor::TOKEN_FILE)
|
26
|
+
else
|
27
|
+
token = ask "#{Arfor::QUESTION} Github token (https://github.com/settings/tokens/new): "
|
28
|
+
write_token(token)
|
29
|
+
end
|
30
|
+
|
31
|
+
token
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.write_token(token)
|
35
|
+
File.write(Arfor::TOKEN_FILE, token)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.create_repository(git_name, git_opts)
|
39
|
+
puts "creating #{git_name}"
|
40
|
+
client = Octokit::Client.new(:access_token => read_token)
|
41
|
+
# user = client.user
|
42
|
+
# puts user.login
|
43
|
+
resp = client.create_repository(git_name, git_opts)
|
44
|
+
|
45
|
+
resp
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/arfor/version.rb
CHANGED
data/lib/arfor.rb
CHANGED
@@ -15,7 +15,16 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require "arfor/version"
|
18
|
+
require "etc"
|
18
19
|
|
19
20
|
module Arfor
|
20
21
|
# Your code goes here...
|
22
|
+
CONFIG_DIR = "#{Etc.getpwuid.dir}/.arfor"
|
23
|
+
LICENCE_FILE = "#{CONFIG_DIR}/licence.key"
|
24
|
+
TOKEN_FILE = "#{CONFIG_DIR}/github_token"
|
25
|
+
TRAVIS_CONF = "#{Etc.getpwuid.dir}/.travis/config.yml"
|
26
|
+
QUESTION = "🤖"
|
27
|
+
OK = "👍"
|
28
|
+
ERROR = "💩"
|
29
|
+
|
21
30
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/<%= full_name %>.svg?branch=master)](https://travis-ci.org/<%= full_name %>)
|
2
|
+
# <%= module_name %>
|
3
|
+
|
4
|
+
#### Table of Contents
|
5
|
+
|
6
|
+
1. [Description](#description)
|
7
|
+
1. [Usage - Configuration options and additional functionality](#usage)
|
8
|
+
1. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
|
9
|
+
1. [Limitations - OS compatibility, etc.](#limitations)
|
10
|
+
1. [Development - Guide for contributing to the module](#development)
|
11
|
+
|
12
|
+
## Description
|
13
|
+
|
14
|
+
<%= description %>
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
See reference and examples
|
18
|
+
|
19
|
+
## Reference
|
20
|
+
[generated documentation](https://rawgit.com/<%= full_name %>/master/doc/index.html).
|
21
|
+
|
22
|
+
Reference documentation is generated directly from source code using [puppet-strings](https://github.com/puppetlabs/puppet-strings). You may regenerate the documentation by running:
|
23
|
+
|
24
|
+
```shell
|
25
|
+
bundle exec puppet strings
|
26
|
+
```
|
27
|
+
|
28
|
+
## Limitations
|
29
|
+
* Not supported by Puppet, Inc.
|
30
|
+
|
31
|
+
## Development
|
32
|
+
|
33
|
+
PRs accepted :)
|
34
|
+
|
35
|
+
## Testing
|
36
|
+
This module supports testing using [PDQTest](https://github.com/declarativesystems/pdqtest).
|
37
|
+
|
38
|
+
|
39
|
+
Test can be executed with:
|
40
|
+
|
41
|
+
```
|
42
|
+
bundle install
|
43
|
+
make
|
44
|
+
```
|
45
|
+
|
46
|
+
See `.travis.yml` for a working CI example
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arfor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoff Williams
|
@@ -122,6 +122,76 @@ dependencies:
|
|
122
122
|
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.8.1
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: octokit
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '4.0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '4.0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: highline
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 1.7.8
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.7.8
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: puppet
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: pdqtest
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.4.3
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 0.4.3
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: travis
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
125
195
|
description: make puppet installers quicker and more reliable
|
126
196
|
email:
|
127
197
|
- geoff.williams@puppet.com
|
@@ -146,12 +216,15 @@ files:
|
|
146
216
|
- lib/arfor/control_repo.rb
|
147
217
|
- lib/arfor/download.rb
|
148
218
|
- lib/arfor/gems.rb
|
219
|
+
- lib/arfor/github_module.rb
|
149
220
|
- lib/arfor/platform_installer.rb
|
221
|
+
- lib/arfor/util/github.rb
|
150
222
|
- lib/arfor/version.rb
|
151
223
|
- res/control_repo/Gemfile
|
152
224
|
- res/control_repo/Makefile
|
153
225
|
- res/control_repo/Puppetfile.mock
|
154
226
|
- res/control_repo/README.md
|
227
|
+
- res/puppet_module/README.md.erb
|
155
228
|
homepage: https://github.com/GeoffWilliams/arfor/
|
156
229
|
licenses:
|
157
230
|
- Apache-2.0
|