dop_common 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.rspec +2 -0
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +176 -0
  6. data/Gemfile +11 -0
  7. data/LICENSE.txt +177 -0
  8. data/README.md +48 -0
  9. data/Rakefile +49 -0
  10. data/Vagrantfile +25 -0
  11. data/bin/dop-puppet-autosign +56 -0
  12. data/doc/examples/example_deploment_plan_v0.0.1.yaml +302 -0
  13. data/doc/plan_format_v0.0.1.md +919 -0
  14. data/doc/plan_format_v0.0.2_snippets.md +56 -0
  15. data/dop_common.gemspec +44 -0
  16. data/lib/dop_common/affinity_group.rb +57 -0
  17. data/lib/dop_common/cli/global_options.rb +37 -0
  18. data/lib/dop_common/cli/log.rb +51 -0
  19. data/lib/dop_common/cli/node_selection.rb +62 -0
  20. data/lib/dop_common/command.rb +125 -0
  21. data/lib/dop_common/config/helper.rb +39 -0
  22. data/lib/dop_common/config.rb +66 -0
  23. data/lib/dop_common/configuration.rb +37 -0
  24. data/lib/dop_common/credential.rb +152 -0
  25. data/lib/dop_common/data_disk.rb +62 -0
  26. data/lib/dop_common/dns.rb +55 -0
  27. data/lib/dop_common/hash_parser.rb +241 -0
  28. data/lib/dop_common/hooks.rb +81 -0
  29. data/lib/dop_common/infrastructure.rb +160 -0
  30. data/lib/dop_common/infrastructure_properties.rb +185 -0
  31. data/lib/dop_common/interface.rb +113 -0
  32. data/lib/dop_common/log.rb +78 -0
  33. data/lib/dop_common/network.rb +85 -0
  34. data/lib/dop_common/node/config.rb +159 -0
  35. data/lib/dop_common/node.rb +442 -0
  36. data/lib/dop_common/node_filter.rb +74 -0
  37. data/lib/dop_common/plan.rb +188 -0
  38. data/lib/dop_common/plan_cache.rb +83 -0
  39. data/lib/dop_common/plan_store.rb +263 -0
  40. data/lib/dop_common/pre_processor.rb +73 -0
  41. data/lib/dop_common/run_options.rb +56 -0
  42. data/lib/dop_common/signal_handler.rb +58 -0
  43. data/lib/dop_common/state_store.rb +95 -0
  44. data/lib/dop_common/step.rb +200 -0
  45. data/lib/dop_common/step_set.rb +41 -0
  46. data/lib/dop_common/thread_context_logger.rb +77 -0
  47. data/lib/dop_common/utils.rb +106 -0
  48. data/lib/dop_common/validator.rb +53 -0
  49. data/lib/dop_common/version.rb +3 -0
  50. data/lib/dop_common.rb +32 -0
  51. data/lib/hiera/backend/dop_backend.rb +94 -0
  52. data/lib/hiera/dop_logger.rb +20 -0
  53. data/spec/data/fake_hook_file_invalid +1 -0
  54. data/spec/data/fake_hook_file_valid +5 -0
  55. data/spec/data/fake_keyfile +1 -0
  56. data/spec/dop-puppet-autosign_spec_disable.rb +33 -0
  57. data/spec/dop_common/affinity_group_spec.rb +41 -0
  58. data/spec/dop_common/command_spec.rb +83 -0
  59. data/spec/dop_common/credential_spec.rb +73 -0
  60. data/spec/dop_common/data_disk_spec.rb +165 -0
  61. data/spec/dop_common/dns_spec.rb +33 -0
  62. data/spec/dop_common/hash_parser_spec.rb +181 -0
  63. data/spec/dop_common/hooks_spec.rb +33 -0
  64. data/spec/dop_common/infrastructure_properties_spec.rb +224 -0
  65. data/spec/dop_common/infrastructure_spec.rb +77 -0
  66. data/spec/dop_common/interface_spec.rb +192 -0
  67. data/spec/dop_common/network_spec.rb +92 -0
  68. data/spec/dop_common/node_filter_spec.rb +70 -0
  69. data/spec/dop_common/node_spec.rb +623 -0
  70. data/spec/dop_common/plan_cache_spec.rb +46 -0
  71. data/spec/dop_common/plan_spec.rb +136 -0
  72. data/spec/dop_common/plan_store_spec.rb +194 -0
  73. data/spec/dop_common/pre_processor_spec.rb +27 -0
  74. data/spec/dop_common/run_options_spec.rb +65 -0
  75. data/spec/dop_common/signal_handler_spec.rb +31 -0
  76. data/spec/dop_common/step_set_spec.rb +21 -0
  77. data/spec/dop_common/step_spec.rb +175 -0
  78. data/spec/dop_common/utils_spec.rb +27 -0
  79. data/spec/dop_common/validator_spec.rb +47 -0
  80. data/spec/example_plans_spec.rb +16 -0
  81. data/spec/fixtures/example_ssh_key +27 -0
  82. data/spec/fixtures/example_ssh_key.pub +1 -0
  83. data/spec/fixtures/incl/root_part.yaml +1 -0
  84. data/spec/fixtures/incl/some_list.yaml +2 -0
  85. data/spec/fixtures/other_plan_same_nodes.yaml +19 -0
  86. data/spec/fixtures/simple_include.yaml +6 -0
  87. data/spec/fixtures/simple_include_with_errors.yaml +4 -0
  88. data/spec/fixtures/simple_plan.yaml +19 -0
  89. data/spec/fixtures/simple_plan_invalid.yaml +18 -0
  90. data/spec/fixtures/simple_plan_modified.yaml +21 -0
  91. data/spec/spec_helper.rb +106 -0
  92. metadata +381 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3101843e67bfd39402248c6690b277251588340a
4
+ data.tar.gz: 9c633c5f114fc5488f701c99a1fdbfd209476ef9
5
+ SHA512:
6
+ metadata.gz: 67b40c4e3dbb0b59325d9af71adb5ae7fd52fcc68dc114fae952954e3ed7764f3a047d0f582cb6d6118f918b5c28bb8979b37ceb820aaeb19cd32a2ec6ca8401
7
+ data.tar.gz: c56ea64374f39925c35e0fbe4c78acba7c54e7f7a6a53aa473ae5f363213392116c02fd46acd2922015670ae1eb74ba589048383570a8d5b2f6c830a0710cd4d
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+ *.swp
18
+ *.swo
19
+ .vagrant/
20
+ vendor
21
+ tags
22
+ TAGS
23
+ .byebug*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-1.8.7-p358
data/CHANGELOG.md ADDED
@@ -0,0 +1,176 @@
1
+ # Change Log
2
+ All notable changes to dop_common will be documented in this file.
3
+
4
+ ## [0.13.0] - 2017-03-28
5
+ ### Added
6
+ - Moved thread context logger from dopi to dop_common and reworked it so it is
7
+ easier to understand.
8
+ - Some common global cli options for all clis
9
+
10
+ ### Fixed
11
+ - Include loops are now detected
12
+
13
+ ## [0.12.2] - 2017-03-06
14
+ ### Fixed
15
+ - Added stale lockfile detection to the plan store which detects if the locking
16
+ process is still running.
17
+
18
+ ## [0.12.1] - 2017-02-14
19
+ ### Fixed
20
+ - Floating IP network should refer to a network name rather than to IP
21
+
22
+ ## [0.12.0] - 2017-01-25
23
+ ### Added
24
+ - Configuration class moved and reworked from Dopi
25
+ - Support import of external files in plans
26
+ - Signal handler class was moved from Dopi
27
+
28
+ ### Changed
29
+ - The roles and config selection for nodes should now work in all tools since the
30
+ hiera part was moved to dop_common from DOPi
31
+
32
+ ## [0.11.3] - 2017-01-11
33
+ ### Changed
34
+ - Add caching to the credential lookups
35
+
36
+ ## [0.11.2] - 2016-12-22
37
+ ### Added
38
+ - Add `max_in_flight` options into `infrastructure`
39
+
40
+ ### Fixed
41
+ - Raise an exception in case a program that generates credentials fails
42
+
43
+ ## [0.11.1] - 2016-12-14
44
+ ### Changed
45
+ - will raise a specific exeption if the plan already exists when adding
46
+
47
+ ## [0.11.0] - 2016-12-07
48
+ ### Changed
49
+ - Remove Dopi and keep Dopv state per default to avoid confusion for the user
50
+
51
+ ## [0.10.3] - 2016-12-06
52
+ ### Fixed
53
+ - Create valid hooks even if they are not present in the deployment file
54
+
55
+ ## [0.10.2] - 2016-12-05
56
+ ### Fixed
57
+ - Make hooks available to node subparser as this is required by DOPv
58
+
59
+ ## [0.10.1] - 2016-12-03
60
+ ### Changed
61
+ - Hooks parser moved to global context
62
+
63
+ ## [0.10.0] - 2016-11-30
64
+ ### Added
65
+ - Hooks parser
66
+ - Move the node parser code from Dopi to DopCommon
67
+
68
+ ## [0.9.2] - 2016-11-28
69
+ ### Fixed
70
+ - Add zero padding to the version string for the plan store
71
+ - Removed a misleading error message when a plan was updated and the state was still new
72
+ - Add lower version boundry for hashdiff to make sure the fixed version is used
73
+
74
+ ## [0.9.1] - 2016-11-15
75
+ ### Fixed
76
+ - Sanitize shell environment before command(s) execution
77
+
78
+ ## [0.9.0] - 2016-11-07
79
+ ### Added
80
+ - DNS parser
81
+ - Data disks
82
+ - Security groups
83
+ - Support for V3 identity API
84
+ - Implementation of an actual plan cache
85
+ - Implementation of a general state store with locking and transactions
86
+
87
+ ### Changed
88
+ - Node credentials
89
+ - Infrastructure properties -> config drive
90
+ - Infrastructure properties -> keep_ha
91
+ - Utils -> redesign of data sizing
92
+ - Reimplementation of the plan store
93
+ - Reimplementation of the Hiera plugin and update to the latest Backend API
94
+
95
+ ## [0.8.0] - 2016-05-25
96
+ ### Added
97
+ - Parsing for max_per_role on step and plan level
98
+
99
+ ### Removed
100
+ - Deprecated ssh_root_pass
101
+ - Deprecated plan subhash for plan settings
102
+
103
+ ## [0.7.0] - 2016-04-18
104
+ ### Added
105
+ - Implemented `use_config_drive` infrastructure property, which is used to
106
+ select a configuration backend of OpenStack providers. By default a config
107
+ drive is used. A user should specify `false` should he require metadata
108
+ service fo configuration.
109
+ - Credentials support for the nodes class
110
+
111
+ ### Changed
112
+ - Credentials can now all be specified inline or loaded from a file
113
+ - Support multiple commands in a single step
114
+
115
+ ## [0.6.1] - 2016-01-27
116
+ ### Fixed
117
+ - Fixed a bug which filtered all the log output away if a credential other than
118
+ username_password was defined
119
+
120
+ ## [0.6.0] - 2016-01-27
121
+ ### Added
122
+ - dop_common can now get secrets in credentials from external files or return values of executables.
123
+
124
+ ## [0.5.0] - 2015-11-17
125
+ ### Added
126
+ - Allow defaults overwrites from plugins
127
+ - Infrastructure property parser
128
+
129
+ ### Fixed
130
+ - Support all types of objects with log filters, not just strings
131
+
132
+ ## [0.4.0] - 2015-11-09
133
+ ### Added
134
+ - dop_common now filters all the secrets from the logs
135
+
136
+ ## [0.3.0] - 2015-10-12
137
+ ### Added
138
+ - The dop hiera plugin now supports merging operations
139
+ - New step set parsing
140
+
141
+ ### Changed
142
+ - Infrastructure hash parsing
143
+ - Extended node hash parsing
144
+
145
+ ## [0.2.0] - 2015-08-16
146
+ ### Added
147
+ - Basic interface hash parsing in node
148
+ - Parsing for generic command plugin option 'verify_after_run'
149
+
150
+ ### Changed
151
+ - Allow dashes in plan names
152
+
153
+ ## [0.1.0] - 2015-07-31
154
+ ### Added
155
+ - Credentials hash parsing (username_password, kerberos, ssh_key)
156
+ - set_plugin_defaults and delete_plugin_defaults parsing
157
+
158
+ ### Changed
159
+ - if ssh_root_pass gets parsed it will output a deprication warning now.
160
+
161
+ ## [0.0.15] - 2015-07-15
162
+ ### Added
163
+ - node_by_config and exclude patterns (also for node and role) parsing
164
+
165
+ ### Changed
166
+ - max_in_flight and ssh_root_pass are now global keys and no longer under 'plan'.
167
+ The old location will still work, but dop_common will show a deprecation warning.
168
+ - max_in_flight now supports the values 0 and -1. More info about this is in the
169
+ Documentation of the DOP plan format.
170
+ - Make it possible to set max_in_flight and canary_host globaly and per step
171
+
172
+ ## [0.0.14] - 2015-07-01
173
+ ### Added
174
+ - Parsing for new plan name attribute in the plan
175
+ - New executable for puppet policy auto-signing of hosts in the DOP plan cache
176
+
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ if Gem::Version.new(RUBY_VERSION.dup) <= Gem::Version.new('1.8.7')
4
+ gem 'rake', '~> 10'
5
+ end
6
+
7
+ if Gem::Version.new(RUBY_VERSION.dup) <= Gem::Version.new('1.9.3')
8
+ gem 'json', '~> 1'
9
+ end
10
+
11
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # DopCommon
2
+
3
+ This gem is part of the Deployment and Orchestration for Puppet
4
+ or DOP for short. dop_common is a library for the parsing and
5
+ validation of DOP plan files.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'dop_common'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install dop_common
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## DOP Plan Format
26
+
27
+ [DOP Plan Format v 0.0.1](doc/plan_format_v0.0.1.md)
28
+
29
+ ## Tests
30
+
31
+ To run the tests for your current machine run:
32
+
33
+ $ bundle install
34
+ $ bundle exec rake
35
+
36
+ To run the tests on all the supportet platform you will need
37
+ a vagrant installation with virtualbox.
38
+
39
+ $ bundle install
40
+ $ bundle exec rake vagrant:spec
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new('spec')
5
+
6
+ task :default => :spec
7
+ task :test => :spec
8
+
9
+ task :console do
10
+ require 'pry'
11
+ require 'dop_common'
12
+ ARGV.clear
13
+ Pry.start
14
+ end
15
+
16
+ namespace :vagrant do
17
+ test_machines = {
18
+ 'rhel6.example.com' => ['system', 'ruby193', 'rh-ruby22'],
19
+ 'rhel7.example.com' => ['system', 'ruby193', 'rh-ruby22'],
20
+ }
21
+
22
+ task :prep do
23
+ Bundler.with_clean_env do
24
+ sh 'vagrant up'
25
+ sh 'vagrant rsync'
26
+ end
27
+ end
28
+
29
+ desc 'execute the rspec tests in vagrant boxes'
30
+ task :spec => ['vagrant:prep'] do
31
+ test_machines.each do |machine, scls|
32
+ scls.each do |scl|
33
+ commands = [
34
+ 'cd /vagrant',
35
+ 'rm -rf Gemfile.lock',
36
+ "bundle install --path ~/.bundle_#{scl}",
37
+ 'bundle exec rspec',
38
+ ]
39
+ Bundler.with_clean_env do
40
+ if scl == 'system'
41
+ sh "vagrant ssh #{machine} -c '#{commands.join(' && ')}'"
42
+ else
43
+ sh "vagrant ssh #{machine} -c 'scl enable #{scl} \"#{commands.join(' && ')}\"'"
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
data/Vagrantfile ADDED
@@ -0,0 +1,25 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure(2) do |config|
5
+
6
+ config.vm.synced_folder '.', '/vagrant', type: 'rsync',
7
+ rsync__exclude: ['.bundle/'], rsync__auto: true
8
+
9
+ config.vm.define 'rhel6.example.com' do |machine|
10
+ machine.vm.box = 'puppetlabs/centos-6.6-64-nocm'
11
+ machine.vm.provision 'shell', inline: 'yum install -y gcc git epel-release centos-release-scl'
12
+ machine.vm.provision 'shell', inline: 'yum install -y ruby ruby-devel rubygem-bundler'
13
+ machine.vm.provision 'shell', inline: 'yum install -y ruby193 ruby193-ruby-devel ruby193-rubygem-bundler'
14
+ machine.vm.provision 'shell', inline: 'yum install -y rh-ruby22 rh-ruby22-ruby-devel rh-ruby22-rubygem-bundler'
15
+ end
16
+
17
+ config.vm.define 'rhel7.example.com' do |machine|
18
+ machine.vm.box = 'puppetlabs/centos-7.0-64-nocm'
19
+ machine.vm.provision 'shell', inline: 'yum install -y gcc git centos-release-scl'
20
+ machine.vm.provision 'shell', inline: 'yum install -y ruby ruby-devel rubygem-bundler'
21
+ machine.vm.provision 'shell', inline: 'yum install -y ruby193 ruby193-ruby-devel ruby193-rubygem-bundler'
22
+ machine.vm.provision 'shell', inline: 'yum install -y rh-ruby22 rh-ruby22-ruby-devel rh-ruby22-rubygem-bundler'
23
+ end
24
+
25
+ end
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # DOP COMMON Puppet autosign policy tool
4
+ #
5
+ require 'dop_common'
6
+ require 'optparse'
7
+ require 'yaml'
8
+
9
+ options = {}
10
+ option_parser = OptionParser.new do |opts|
11
+ opts.banner = "Usage: dop-puppet-autosign [options] certname"
12
+
13
+ options[:verbosity] = 'WARN'
14
+ opts.on("-v", "--verbosity VERBOSITY", "Set the verbosity level. Default is warn") do |v|
15
+ options[:verbosity] = v
16
+ end
17
+
18
+ options[:plan_cache] = '/var/lib/dop/cache'
19
+ opts.on("-p", "--plan_cache PLAN_CACHE_DIR", "Set the dop plan cache dir. Default is #{options[:plan_cache]}") do |p|
20
+ options[:plan_cache] = p
21
+ end
22
+
23
+ opts.on( '-v', '--version', 'Show version of dop_common' ) do
24
+ puts DopCommon::VERSION
25
+ exit
26
+ end
27
+
28
+ opts.on( '-h', '--help', 'Display this screen' ) do
29
+ puts opts
30
+ exit
31
+ end
32
+
33
+ end
34
+
35
+ begin option_parser.parse!
36
+ rescue OptionParser::InvalidOption => e
37
+ puts e
38
+ puts
39
+ puts option_parser
40
+ exit(-1)
41
+ end
42
+
43
+ node_name = ARGV[0]
44
+
45
+ if node_name.nil?
46
+ puts option_parser
47
+ exit(-1)
48
+ end
49
+
50
+ DopCommon.logger = Logger.new(STDERR)
51
+ DopCommon.log.level = ::Logger.const_get(options[:verbosity].upcase)
52
+
53
+ plan_store = DopCommon::PlanStore.new(options[:plan_cache])
54
+ plan_cache = DopCommon::PlanCache.new(plan_store)
55
+
56
+ plan_cache.plan_by_node(node_name) ? exit(0) : exit(1)