ref_arch_setup 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b8c6aca4691fde2196748ac621990f7b9c401ab0
4
+ data.tar.gz: be7e2c0c347e402d5482b68e0f26a74347b26144
5
+ SHA512:
6
+ metadata.gz: 004016af7b7d615cd4c6f40b4ecea50f2b05fd65ba428516c05e2af52ded69a271de7aa9993220fcbf042d4f9dd6a69357a75723acd835977eda2449e0464679
7
+ data.tar.gz: daadb2ae7760654854e2e9b8fc4f0638d417bd3f0332c44cee99af3cf18f7775d5f0453fbe5cdad771130a01a84b492652238111d6e6d1e2353b0bc91d4b5cd5
@@ -0,0 +1,112 @@
1
+ # How To Contribute To RefArchSetup
2
+
3
+ ## Getting Started
4
+
5
+ * Create a [Jira](http://tickets.puppetlabs.com) account.
6
+ * Make sure you have a [GitHub](https://github.com) account.
7
+ * Submit a ticket for your issue, assuming one does not already exist.
8
+ * Clearly describe the issue including steps to reproduce when it is a bug.
9
+ * File a ticket in the [SLV project](https://tickets.puppetlabs.com/projects/SLV/)
10
+ * Clone the [ref_arch_setup](https://github.com/puppetlabs/ref_arch_setup) repository on GitHub.
11
+
12
+ ## Making Changes
13
+
14
+ ### GitHub
15
+ * Create a topic branch from your local copy of the repository.
16
+ * Please title the branch after the ticket you intend to address, ie `SLV-111`.
17
+ * Make commits of logical units.
18
+ * Check for unnecessary whitespace with `git diff --check` before committing.
19
+ * Make sure your commit messages are in the proper format.
20
+
21
+ ````
22
+ (SLV-111) Make the example in CONTRIBUTING imperative and concrete
23
+
24
+ Without this patch applied the example commit message in the CONTRIBUTING
25
+ document is not a concrete example. This is a problem because the
26
+ contributor is left to imagine what the commit message should look like
27
+ based on a description rather than an example. This patch fixes the
28
+ problem by making the example concrete and imperative.
29
+
30
+ The first line is a real life imperative statement with a ticket number
31
+ from our issue tracker. The body describes the behavior without the patch,
32
+ why this is a problem, and how the patch fixes the problem when applied.
33
+ ````
34
+
35
+ * During the time that you are working on your patch the master branch may have changed - you'll want to [rebase](http://git-scm.com/book/en/Git-Branching-Rebasing) on top of the master branch before you submit your PR.
36
+ A successful rebase ensures that your PR will cleanly merge.
37
+
38
+ ### Testing
39
+
40
+ * Submitted PR's will be tested in a series of spec and acceptance level tests - the results of these tests will be evaluated by an SLV team member, as test results are currently not accessible by the public. Testing failures that require code changes will be communicated in the PR discussion.
41
+ * Make sure you have added [RSpec](http://rspec.info/) tests that exercise your new code.
42
+
43
+ ### Documentation
44
+
45
+ * Make sure that you have added documentation using [Yard](http://yardoc.org/) as necessary for any new code introduced.
46
+ * More user friendly documentation will be required for PRs unless exempted. Documentation lives in the [docs/ folder](docs).
47
+
48
+ ## Making Trivial Changes
49
+
50
+ ### Maintenance
51
+
52
+ For changes of a trivial nature, it is not always necessary to create a new ticket in Jira. In this case, it is appropriate to start the first line of a commit with `(MAINT)` instead of a ticket/issue number.
53
+
54
+ ````
55
+ (MAINT) Fix whitespace
56
+
57
+ - remove additional spaces that appear at EOL
58
+ ````
59
+
60
+ ## Submitting Changes
61
+
62
+ * Push your changes to a topic branch of the repository.
63
+ * Submit a pull request to [ref_arch_setup](https://github.com/puppetlabs/ref_arch_setup)
64
+ * Update your [Jira](https://tickets.puppetlabs.com) ticket
65
+ * Update the status to "Ready for Merge".
66
+ * Include a link to the pull request in the ticket.
67
+
68
+ ## Building And Publishing The Gem
69
+
70
+ ### RubyGems.org
71
+ * Create a [rubygems.org](rubygems.org) account if you don't already have one.
72
+ * Use your email and password when pushing the gem. The credentials will be stored in ~/.gem/credentials.
73
+
74
+ ### Bundler Release Tasks
75
+
76
+ RefArchSetup includes the [Bundler release rake tasks](https://bundler.io/v1.12/guides/creating_gem.html#releasing-the-gem) via [gem_of](https://github.com/puppetlabs/gem_of) which simplifies the build and release process.
77
+ The following tasks are included:
78
+ ````
79
+ rake gem:build # Build ref_arch_setup-0.0.1.gem into the pkg directory
80
+ rake gem:clean # Remove any temporary products
81
+ rake gem:clobber # Remove any generated files
82
+ rake gem:install # Build and install ref_arch_setup-0.0.1.gem into system gems
83
+ rake gem:install:local # Build and install ref_arch_setup-0.0.1.gem into system gems without network access
84
+ rake gem:release[remote] # Create tag v0.0.1 and build and push ref_arch_setup-0.0.1.gem to rubygems.org
85
+ ````
86
+
87
+ To publish the gem to RubyGems.org, use the `release` task:
88
+
89
+ ````
90
+ $ rake gem:release
91
+ ````
92
+
93
+ This will create a new tag for the release, push it to GitHub, build the gem, and push it to RubyGems.org.
94
+
95
+ ### Version Bump For Gem Release
96
+
97
+ * Update the `version.rb` file with the upcoming gem version number to prepare for the next gem release.
98
+ * Commit the update with `(GEM)` instead of a ticket/issue number.
99
+
100
+ ````
101
+ (GEM) Update version for ref_arch_setup 1.11.1
102
+ ````
103
+ * Submit a pull request for the version update to [ref_arch_setup](https://github.com/puppetlabs/ref_arch_setup)
104
+
105
+ # Additional Resources
106
+
107
+ * [Puppet community guidelines](https://docs.puppet.com/community/community_guidelines.html)
108
+ * [Bug tracker (Jira)](http://tickets.puppetlabs.com)
109
+ * [SLV Jira Project](https://tickets.puppetlabs.com/projects/SLV/)
110
+ * [General GitHub documentation](http://help.github.com/)
111
+ * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
112
+
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": 1,
3
+ "file_format": "This MAINTAINERS file format is described at https://github.com/puppetlabs/maintainers",
4
+ "issues": "https://tickets.puppetlabs.com/projects/SLV/",
5
+ "internal_list": "https://groups.google.com/a/puppet.com/forum/?hl=en#!forum/silver-team",
6
+ "people": [
7
+ {
8
+ "github": "RandellP",
9
+ "email": "team-system-level-validation@puppet.com",
10
+ "name": "Randell Pelak"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,30 @@
1
+ # RefArchSetup
2
+
3
+ ## Overview
4
+
5
+ RefArchSetup is a gem designed to help install the various puppet reference architectures
6
+
7
+ # Installation
8
+
9
+ $ gem install ref_arch_setup
10
+
11
+ # Usage
12
+
13
+ TBD
14
+
15
+ # License
16
+
17
+ See [LICENSE](LICENSE) file.
18
+
19
+ # Support & Issues
20
+
21
+ Please log tickets and issues in the
22
+ [SLV project](https://tickets.puppetlabs.com/projects/SLV/).
23
+
24
+ For additional information on filing tickets, please check out our
25
+ [CONTRIBUTOR doc](CONTRIBUTING.md).
26
+
27
+ # Maintainers
28
+
29
+ For information on project maintainers, please check out our
30
+ [MAINTAINERS doc](MAINTAINERS.md).
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env ruby
2
+ STDOUT.sync
3
+
4
+ require "rubygems" unless defined?(Gem)
5
+ require "ref_arch_setup"
6
+ require "optparse"
7
+
8
+ available_commands = [
9
+ "install"
10
+ ]
11
+
12
+ options = {}
13
+ # options["some_option"] = "some value" #to set a default value
14
+
15
+ global = OptionParser.new do |opt|
16
+ opt.banner = <<-BANNER
17
+ Usage: ref_arch_setup [options] <subcommand> [options]
18
+
19
+ Available Commands:
20
+
21
+ install - Install a bootstrapped mono PE on target_host
22
+
23
+ Available Options:
24
+
25
+ BANNER
26
+ opt.on("-h", "--help", "Prints this help") do
27
+ puts opt
28
+ exit
29
+ end
30
+ opt.on("-v", "--version", "Show currently running version of ref_arch_setup") do
31
+ puts RefArchSetup::Version::STRING
32
+ exit 0
33
+ end
34
+ end
35
+
36
+ subcommands = {
37
+ "install" => OptionParser.new do |opt|
38
+ opt.banner = "Usage: ref_arch_setup install [options]"
39
+ opt.on("--target-host value", "Host to install PE on") do |value|
40
+ options["target_host"] = value
41
+ end
42
+ opt.on("--pe-tarball-path value", "Path to PE tarball") do |value|
43
+ options["pe_tarball_path"] = value
44
+ end
45
+ opt.on("--pe-conf-path value", "Path to pe.conf file") do |value|
46
+ options["pe_conf_path"] = value
47
+ end
48
+ end
49
+ }
50
+
51
+ global.order!(ARGV)
52
+ command_string = ARGV[0]
53
+
54
+ if command_string.nil?
55
+ puts global.help
56
+ exit 0
57
+ end
58
+
59
+ unless available_commands.include?(command_string)
60
+ puts "# ERROR, #{cmd} is not an available command"
61
+ puts
62
+ puts global.help
63
+ exit 1
64
+ end
65
+
66
+ subcommands[command_string].parse!
67
+
68
+ cli = RefArchSetup::CLI.new(options)
69
+ cli.send(command_string)
@@ -0,0 +1,8 @@
1
+ # General namespace for RAS
2
+ module RefArchSetup
3
+ %w[cli version install].each do |lib|
4
+ require "ref_arch_setup/#{lib}"
5
+ end
6
+ # location of modules shipped with RAS (Ref Arch Setup)
7
+ RAS_MODULE_PATH = File.dirname(__FILE__) + "/../modules"
8
+ end
@@ -0,0 +1,89 @@
1
+ require "optparse"
2
+
3
+ module RefArchSetup
4
+ # Implements the command line subcommands
5
+ #
6
+ # @author Randell Pelak
7
+ # @attr [hash] options Options from the command line
8
+ class CLI
9
+ # Initialize class
10
+ #
11
+ # @author Randell Pelak
12
+ #
13
+ # @param [Hash] options The options from the command line
14
+ # @option options [String] something not yet defined
15
+ #
16
+ # @return [void]
17
+ def initialize(options)
18
+ @options = options
19
+ end
20
+
21
+ # Check values of options to see if they are really an option
22
+ #
23
+ # optparse will gobble up the next option if no value is given
24
+ # This checks option values for things that start with --
25
+ # and then assumes the user forgot to provide a value
26
+ # This is okay as long as we don't need to support values with --
27
+ #
28
+ # @author Randell Pelak
29
+ #
30
+ # @raise [OptionParser::MissingArgument] Thrown if an option is missing and argument
31
+ #
32
+ # @example check_for_missing_value
33
+ #
34
+ # @return [void]
35
+ def check_for_missing_value
36
+ @options.each do |key, value|
37
+ raise OptionParser::MissingArgument, key if value =~ /^--/
38
+ end
39
+ end
40
+
41
+ # Checks for an option that is required by the sub command
42
+ #
43
+ # @author Randell Pelak
44
+ #
45
+ # @param [string] option the name of the option
46
+ # @param [string] subcommand the name of the subcommand
47
+ #
48
+ # @example check_option("target_host", "install")
49
+ #
50
+ # @raise [OptionParser::MissingOption] Thrown if option is missing
51
+ #
52
+ # @return [void]
53
+ def check_option(option, subcommand)
54
+ return unless @options[option].nil? || @options[option].empty?
55
+ option.tr!("_", "-")
56
+ raise OptionParser::MissingOption, \
57
+ "option --#{option} is required for the #{subcommand} subcommand"
58
+ end
59
+
60
+ # Installs a bootstrap version of mono on the target host using the provided tarball and pe.conf
61
+ #
62
+ # @author Randell Pelak
63
+ #
64
+ # @return [boolean] success of install
65
+ def install
66
+ check_for_missing_value
67
+ check_option("target_host", "install")
68
+ check_option("pe_tarball_path", "install")
69
+ check_option("pe_conf_path", "install")
70
+ install_obj = RefArchSetup::Install.new(@options["target_host"])
71
+ success = install_obj.bootstrap_mono(@options["pe_conf_path"], @options["pe_tarball_path"])
72
+ return success
73
+ end
74
+ end
75
+ end
76
+
77
+ # from optparse
78
+ class OptionParser
79
+ # Adds an exception for missing a required option
80
+ #
81
+ # OptionParser doesn't handle required options, only required arguments to the options
82
+ # And even that it doesn't do all that well.
83
+ # This creates a missing argument exception for use by this CLI class
84
+ #
85
+ # @author Randell Pelak
86
+ class MissingOption < ParseError
87
+ const_set(:Reason, "missing option".freeze)
88
+ end
89
+ end
@@ -0,0 +1,44 @@
1
+ # General namespace for RAS
2
+ module RefArchSetup
3
+ # Installation helper
4
+ #
5
+ # @author Randell Pelak
6
+ #
7
+ # @attr [string] target_master Host to install on
8
+ class Install
9
+ # Initialize class
10
+ #
11
+ # @author Randell Pelak
12
+ #
13
+ # @param [string] target_master Host to install on
14
+ #
15
+ # @return [void]
16
+ def initialize(target_master)
17
+ @target_master = target_master
18
+ end
19
+
20
+ # Runs the initial bootstrapping install
21
+ #
22
+ # @author Randell Pelak
23
+ #
24
+ # @param [string] pe_conf_path Path to pe.conf
25
+ # @param [string] pe_tarball_path Path to pe tarball
26
+ # @param [string] target_master Host to install on
27
+ #
28
+ # @return [true,false] Based on exit status of the bolt task
29
+ def bootstrap_mono(pe_conf_path, pe_tarball_path, target_master = @target_master)
30
+ env_vars = "PE_CONF_PATH=#{pe_conf_path};"
31
+ env_vars << "PE_TARBALL_PATH=#{pe_tarball_path};"
32
+ env_vars << "PE_TARGET_MASTER=#{target_master};"
33
+ command = env_vars.to_s + "bolt task run bogus::foo "
34
+ command << "--modulepath #{RAS_MODULE_PATH} --nodes #{target_master}"
35
+ puts "Running: #{command}"
36
+ output = `#{command}`
37
+ success = $?.success? # rubocop:disable Style/SpecialGlobalVars
38
+ puts "ERROR: bolt command failed!" unless success
39
+ puts "Exit status was: #{$?.exitstatus}" # rubocop:disable Style/SpecialGlobalVars
40
+ puts "Output was: #{output}"
41
+ return success
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,7 @@
1
+ module RefArchSetup
2
+ # Module for holding version info
3
+ module Version
4
+ # Version number
5
+ STRING = "0.0.1".freeze
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ref_arch_setup
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Puppet, Inc.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-06-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bolt
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.17'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.17'
27
+ description: |-
28
+ This gem provides methods for for setting up /
29
+ Puppet Enterprise reference architectures
30
+ email:
31
+ - team-system-level-validation@puppet.com
32
+ executables:
33
+ - ref_arch_setup
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - CONTRIBUTING.md
38
+ - MAINTAINERS
39
+ - README.md
40
+ - bin/ref_arch_setup
41
+ - lib/ref_arch_setup.rb
42
+ - lib/ref_arch_setup/cli.rb
43
+ - lib/ref_arch_setup/install.rb
44
+ - lib/ref_arch_setup/version.rb
45
+ homepage: https://github.com/puppetlabs/ref_arch_setup
46
+ licenses:
47
+ - Apache2
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 2.5.2
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Tool for setting up reference architectures
69
+ test_files: []