hammer_cli_foreman_puppet 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f92851cfcdf0a8b5ec003d8cbbc5ef6b4d36affce07208844df5608a5f5459b1
4
- data.tar.gz: 565bfa4263e76e6826ed8a30d42e6cdbb611bff5261cd87b07c432273811adfa
3
+ metadata.gz: 2073a0e9ebeae64eec1b55d35fae3735af4b7f4bef12f0dcc24ece34a8d906d2
4
+ data.tar.gz: c0c147e6f74533ed1fcbb8ba2ecc87a6486b831e85234fa79a5734757092fd67
5
5
  SHA512:
6
- metadata.gz: e69a1c28719c4076502b00baddcd54f618c70b3ca8984ff6586134a0cb7d7ef8fac2e0cd4de3ccc1453338bf6c9b4e2e60a7c3256273ce798291a050856ea014
7
- data.tar.gz: c5fa4ef46e9139c3369617a4766bdb71bddb77b94a9279de999e39275337e5766872c8158ce2235027143b881f76d1b9b8d896f89bf388f4e2430b18d0d82b68
6
+ metadata.gz: 8d7ae1eed57c8d48113706af0a82fe1d6f078587e9c021d827311bf06e3ba5dbe49239b7e97f01fd72a120df317722d1a7e739b94b932757bac6b30d494a60ab
7
+ data.tar.gz: 707f9ab99b9665c294f4f0f034f6956374790b60166196f8db0325370f55ed988b006cdc0ee964b40b317e7495b679a30a598c49e059e53f6ba5bc463117db50
data/README.md CHANGED
@@ -1,20 +1,32 @@
1
- [WIP] hammer_cli_foreman_puppet
2
- =========================================
1
+ # Hammer CLI Foreman Puppet
3
2
 
4
- This [Hammer CLI](https://github.com/theforeman/hammer-cli) plugin contains
5
- set of commands for puppet.
6
- Configuration
7
- -------------
3
+ This Hammer CLI plugin contains a set of commands for [foreman_puppet](https://github.com/theforeman/foreman_puppet), a plugin that adds Puppet functionality to Foreman.
8
4
 
9
- Configuration is expected to be placed in one of hammer's configuration directories for plugins:
10
- - `/etc/hammer/cli.modules.d/`
11
- - `~/.hammer/cli.modules.d/`
12
- - `./.config/cli.modules.d/` (config dir in CWD)
5
+ ## Compatibility
13
6
 
14
- If you install `hammer_cli_foreman_puppet` from source you'll have to copy the config file manually
15
- from `config/foreman_puppet.yml`.
7
+ This is the list of which version of Foreman Puppet and Foreman are needed for which version of this plugin.
16
8
 
17
- License
18
- -------
9
+ |foreman |foreman_puppet|hammer-cli-puppet | Notes |
10
+ |---------------|--------------|----------------- |--------------------------- |
11
+ | >= 3.0 | ~> 1.0 | >= 0.0.3 | Required |
12
+ | <= 2.5 | ~> 0.1 | - | Not supported (functionality is in [hammer-cli-foreman](https://github.com/theforeman/hammer-cli-foreman)) |
19
13
 
20
- This project is licensed under the GPLv3+.
14
+ ## Installation
15
+
16
+ $ gem install hammer_cli_foreman_puppet
17
+
18
+ $ mkdir -p ~/.hammer/cli.modules.d/
19
+
20
+ $ cat <<EOQ > ~/.hammer/cli.modules.d/foreman_puppet.yml
21
+ :foreman_puppet:
22
+ :enable_module: true
23
+ EOQ
24
+
25
+ ## Problems
26
+
27
+ Please feel free to open a [new Github issue](https://github.com/theforeman/hammer-cli-foreman-puppet/issues/new) if you encounter any bugs/issues using this plugin.
28
+
29
+ ## More info
30
+
31
+ See our [Hammer CLI installation and configuration instuctions](
32
+ https://github.com/theforeman/hammer-cli/blob/master/doc/installation.md#installation).
@@ -1,13 +1,36 @@
1
1
 
2
2
  require 'hammer_cli_foreman/combination'
3
+ require 'hammer_cli_foreman_puppet/command_extensions/combination'
3
4
 
4
5
  module HammerCLIForemanPuppet
6
+ class Combination < HammerCLIForemanPuppet::Command
7
+ class ListCommand < HammerCLIForemanPuppet::ListCommand
8
+ output do
9
+ field nil, _("Puppet Environment"), Fields::SingleReference, :key => :environment
10
+ end
11
+ end
12
+
13
+ class InfoCommand < HammerCLIForemanPuppet::InfoCommand
14
+ include EnvironmentNameMapping
15
+ output ListCommand.output_definition do
16
+ field :environment_id, _('Puppet Environment ID')
17
+ field :environment_name, _('Puppet Environment name')
18
+ end
19
+ end
20
+ end
21
+
22
+ HammerCLIForeman::Combination::ListCombination.extend_with(
23
+ HammerCLIForemanPuppet::CommandExtensions::ListCombination.new
24
+ )
5
25
  HammerCLIForeman::Combination::InfoCombination.extend_with(
26
+ HammerCLIForemanPuppet::CommandExtensions::InfoCombination.new,
6
27
  HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new
7
28
  )
29
+ HammerCLIForeman::Combination::UpdateCombination.include(HammerCLIForemanPuppet::EnvironmentNameMapping)
8
30
  HammerCLIForeman::Combination::UpdateCombination.extend_with(
9
31
  HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new
10
32
  )
33
+ HammerCLIForeman::Combination::CreateCombination.include(HammerCLIForemanPuppet::EnvironmentNameMapping)
11
34
  HammerCLIForeman::Combination::CreateCombination.extend_with(
12
35
  HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new
13
36
  )
@@ -0,0 +1,15 @@
1
+ module HammerCLIForemanPuppet
2
+ module CommandExtensions
3
+ class ListCombination < HammerCLI::CommandExtensions
4
+ output do |definition|
5
+ definition.insert(:after, :hostgroup, HammerCLIForemanPuppet::Combination::ListCommand.output_definition.fields)
6
+ end
7
+ end
8
+
9
+ class InfoCombination < HammerCLI::CommandExtensions
10
+ output do |definition|
11
+ definition.insert(:after, :hostgroup_name, HammerCLIForemanPuppet::Combination::InfoCommand.output_definition.fields)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ module HammerCLIForemanPuppet
2
+ module CommandExtensions
3
+ class Provision < HammerCLI::CommandExtensions
4
+ option_family(
5
+ format: HammerCLI::Options::Normalizers::List.new,
6
+ aliased_resource: 'puppet-class',
7
+ description: 'Names/Ids of associated Puppet classes'
8
+ ) do
9
+ parent '--puppet-class-ids', 'PUPPET_CLASS_IDS', _('List of Puppet class ids'),
10
+ attribute_name: :option_puppetclass_ids
11
+ child '--puppet-classes', 'PUPPET_CLASS_NAMES', '',
12
+ attribute_name: :option_puppetclass_names
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ require 'hammer_cli_foreman_discovery/discovery'
2
+ require 'hammer_cli_foreman_puppet/command_extensions/discovery'
3
+ require 'hammer_cli_foreman_puppet/command_extensions/environment'
4
+
5
+ module HammerCLIForemanPuppet
6
+ HammerCLIForemanDiscovery::DiscoveredHost::ProvisionCommand.extend_with(
7
+ HammerCLIForemanPuppet::CommandExtensions::Provision.new,
8
+ HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new
9
+ )
10
+ end
@@ -1,5 +1,4 @@
1
1
  require 'hammer_cli_foreman/hostgroup'
2
- require 'hammer_cli_foreman_puppet/references'
3
2
  require 'hammer_cli_foreman_puppet/command_extensions/hostgroup.rb'
4
3
 
5
4
  module HammerCLIForemanPuppet
@@ -42,7 +41,7 @@ module HammerCLIForemanPuppet
42
41
  field nil, _("Puppet Environment"), Fields::SingleReference, :key => :environment
43
42
  field nil, _("Puppet CA Proxy"), Fields::SingleReference, :key => :puppet_ca_proxy
44
43
  field nil, _("Puppet Master Proxy"), Fields::SingleReference, :key => :puppet_proxy
45
- HammerCLIForemanPuppet::References.puppetclasses(self)
44
+ HammerCLIForemanPuppet::PuppetReferences.puppetclasses(self)
46
45
  end
47
46
  end
48
47
  end
@@ -1,19 +1,11 @@
1
1
  require 'hammer_cli_foreman/location'
2
- require 'hammer_cli_foreman_puppet/references'
3
2
  require 'hammer_cli_foreman_puppet/command_extensions/location'
4
3
 
5
4
  module HammerCLIForemanPuppet
6
- module LocationAddAssociatedCommand
7
- def self.included(base)
8
- HammerCLIForemanPuppet::AssociatingCommands::PuppetEnvironment.extend_command(base)
9
- base.create_subcommand
10
- end
11
- end
12
-
13
5
  class Location < HammerCLIForemanPuppet::Command
14
6
  class InfoCommand < HammerCLIForemanPuppet::InfoCommand
15
7
  output do
16
- HammerCLIForemanPuppet::References.environments(self)
8
+ HammerCLIForemanPuppet::PuppetReferences.environments(self)
17
9
  end
18
10
  end
19
11
  end
@@ -27,9 +19,4 @@ module HammerCLIForemanPuppet
27
19
  HammerCLIForeman::Location::InfoCommand.extend_with(
28
20
  HammerCLIForemanPuppet::CommandExtensions::LocationInfo.new
29
21
  )
30
-
31
- HammerCLIForeman::Location.class_eval do
32
- extend HammerCLIForemanPuppet::AssociatingCommands::ExtendCommands
33
- include HammerCLIForemanPuppet::LocationAddAssociatedCommand
34
- end
35
22
  end
@@ -1,19 +1,11 @@
1
1
  require 'hammer_cli_foreman/organization'
2
- require 'hammer_cli_foreman_puppet/references'
3
2
  require 'hammer_cli_foreman_puppet/command_extensions/organization'
4
3
 
5
4
  module HammerCLIForemanPuppet
6
- module OrganizationAddAssociatedCommand
7
- def self.included(base)
8
- HammerCLIForemanPuppet::AssociatingCommands::PuppetEnvironment.extend_command(base)
9
- base.create_subcommand
10
- end
11
- end
12
-
13
5
  class Organization < HammerCLIForemanPuppet::Command
14
6
  class InfoCommand < HammerCLIForemanPuppet::InfoCommand
15
7
  output do
16
- HammerCLIForemanPuppet::References.environments(self)
8
+ HammerCLIForemanPuppet::PuppetReferences.environments(self)
17
9
  end
18
10
  end
19
11
  end
@@ -27,9 +19,4 @@ module HammerCLIForemanPuppet
27
19
  HammerCLIForeman::Organization::InfoCommand.extend_with(
28
20
  HammerCLIForemanPuppet::CommandExtensions::OrganizationInfo.new
29
21
  )
30
-
31
- HammerCLIForeman::Organization.class_eval do
32
- extend HammerCLIForemanPuppet::AssociatingCommands::ExtendCommands
33
- include HammerCLIForemanPuppet::OrganizationAddAssociatedCommand
34
- end
35
22
  end
@@ -1,5 +1,5 @@
1
1
  module HammerCLIForemanPuppet
2
2
  def self.version
3
- @version ||= Gem::Version.new '0.0.3'
3
+ @version ||= Gem::Version.new '0.0.4'
4
4
  end
5
5
  end
@@ -1,5 +1,6 @@
1
1
  module HammerCLIForemanPuppet
2
2
  require 'hammer_cli'
3
+ require 'hammer_cli/logger'
3
4
  require 'hammer_cli_foreman'
4
5
 
5
6
  require 'hammer_cli_foreman_puppet/version'
@@ -8,7 +9,6 @@ module HammerCLIForemanPuppet
8
9
  require 'hammer_cli_foreman_puppet/commands'
9
10
  require 'hammer_cli_foreman_puppet/command_extensions'
10
11
  require 'hammer_cli_foreman_puppet/option_sources'
11
- require 'hammer_cli_foreman_puppet/associating_commands'
12
12
  require 'hammer_cli_foreman_puppet/id_resolver'
13
13
 
14
14
  # Puppet commands
@@ -49,4 +49,12 @@ module HammerCLIForemanPuppet
49
49
  'HammerCLIForemanPuppet::SmartClassParameter',
50
50
  'hammer_cli_foreman_puppet/smart_class_parameter'
51
51
  )
52
+
53
+ # Plugins extensions
54
+ begin
55
+ require 'hammer_cli_foreman_puppet/discovery'
56
+ rescue Exception => e
57
+ logger = Logging.logger['HammerCLIForemanPuppet::Discovery']
58
+ logger.debug("Discovery plugin was not found: #{e}")
59
+ end
52
60
  end
@@ -10,10 +10,10 @@ describe 'template' do
10
10
  params = ['create', '--provisioning-template-id=10', '--hostgroup-id=1', '--puppet-environment-id=1']
11
11
  expected_result = success_result("Template combination created.\n")
12
12
  api_expects(:template_combinations, :create, 'Create template combination') do |p|
13
- p['provisioning_template_id'] == 10 &&
14
- p['hostgroup_id'] == 1 &&
13
+ p['provisioning_template_id'] == '10' &&
14
+ p['hostgroup_id'] == '1' &&
15
15
  p['environment_id'] == 1 &&
16
- p['template_combination'] == { 'environment_id' => 1, 'hostgroup_id' => 1 }
16
+ p['template_combination'] == { 'environment_id' => 1, 'hostgroup_id' => '1' }
17
17
  end
18
18
 
19
19
  result = run_cmd(@cmd + params)
@@ -25,10 +25,10 @@ describe 'template' do
25
25
  expected_result = success_result("Template combination updated.\n")
26
26
  api_expects(:template_combinations, :update, 'Update template combination') do |p|
27
27
  p['id'] == '3' &&
28
- p['provisioning_template_id'] == 10 &&
29
- p['hostgroup_id'] == 1 &&
28
+ p['provisioning_template_id'] == '10' &&
29
+ p['hostgroup_id'] == '1' &&
30
30
  p['environment_id'] == 1 &&
31
- p['template_combination'] == { 'environment_id' => 1, 'hostgroup_id' => 1 }
31
+ p['template_combination'] == { 'environment_id' => 1, 'hostgroup_id' => '1' }
32
32
  end
33
33
 
34
34
  result = run_cmd(@cmd + params)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_foreman_puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amir Fefer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-05 00:00:00.000000000 Z
11
+ date: 2021-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hammer_cli_foreman
@@ -30,7 +30,7 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 4.0.0
33
- description:
33
+ description:
34
34
  email:
35
35
  - amirfefer@gmail.com
36
36
  executables: []
@@ -42,10 +42,11 @@ files:
42
42
  - config/foreman_puppet.yml
43
43
  - lib/hammer_cli_foreman_puppet.rb
44
44
  - lib/hammer_cli_foreman_puppet/associating_commands.rb
45
- - lib/hammer_cli_foreman_puppet/associating_commands/associating_commands.rb
46
45
  - lib/hammer_cli_foreman_puppet/class.rb
47
46
  - lib/hammer_cli_foreman_puppet/combination.rb
48
47
  - lib/hammer_cli_foreman_puppet/command_extensions.rb
48
+ - lib/hammer_cli_foreman_puppet/command_extensions/combination.rb
49
+ - lib/hammer_cli_foreman_puppet/command_extensions/discovery.rb
49
50
  - lib/hammer_cli_foreman_puppet/command_extensions/environment.rb
50
51
  - lib/hammer_cli_foreman_puppet/command_extensions/environments.rb
51
52
  - lib/hammer_cli_foreman_puppet/command_extensions/host.rb
@@ -54,6 +55,7 @@ files:
54
55
  - lib/hammer_cli_foreman_puppet/command_extensions/organization.rb
55
56
  - lib/hammer_cli_foreman_puppet/commands.rb
56
57
  - lib/hammer_cli_foreman_puppet/config_group.rb
58
+ - lib/hammer_cli_foreman_puppet/discovery.rb
57
59
  - lib/hammer_cli_foreman_puppet/environment.rb
58
60
  - lib/hammer_cli_foreman_puppet/environment_name_mapping.rb
59
61
  - lib/hammer_cli_foreman_puppet/host.rb
@@ -65,7 +67,6 @@ files:
65
67
  - lib/hammer_cli_foreman_puppet/option_sources/puppet_environment_params.rb
66
68
  - lib/hammer_cli_foreman_puppet/organization.rb
67
69
  - lib/hammer_cli_foreman_puppet/puppet_references.rb
68
- - lib/hammer_cli_foreman_puppet/references.rb
69
70
  - lib/hammer_cli_foreman_puppet/smart_class_parameter.rb
70
71
  - lib/hammer_cli_foreman_puppet/smart_proxy.rb
71
72
  - lib/hammer_cli_foreman_puppet/version.rb
@@ -96,7 +97,7 @@ homepage: https://github.com/theforeman/hammer-cli-foreman-puppet
96
97
  licenses:
97
98
  - GPL-3.0
98
99
  metadata: {}
99
- post_install_message:
100
+ post_install_message:
100
101
  rdoc_options: []
101
102
  require_paths:
102
103
  - lib
@@ -111,32 +112,32 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
112
  - !ruby/object:Gem::Version
112
113
  version: '0'
113
114
  requirements: []
114
- rubyforge_project:
115
- rubygems_version: 2.7.10
116
- signing_key:
115
+ rubyforge_project:
116
+ rubygems_version: 2.7.6.3
117
+ signing_key:
117
118
  specification_version: 4
118
119
  summary: Foreman Puppet plugin for Hammer CLI
119
120
  test_files:
120
- - test/functional/test_helper.rb
121
- - test/functional/smart_class_parameter_test.rb
121
+ - test/data/2.1/foreman_api.json
122
+ - test/data/3.0/foreman_api.json
123
+ - test/data/README.md
124
+ - test/unit/helpers/command.rb
125
+ - test/unit/helpers/fake_searchables.rb
126
+ - test/unit/helpers/resource_disabled.rb
127
+ - test/unit/apipie_resource_mock.rb
128
+ - test/unit/puppet_class_test.rb
129
+ - test/unit/puppet_environment_test.rb
130
+ - test/unit/smart_class_parameter_test.rb
131
+ - test/unit/test_helper.rb
132
+ - test/unit/test_output_adapter.rb
133
+ - test/unit/config_group_test.rb
134
+ - test/test_helper.rb
122
135
  - test/functional/config_group_test.rb
123
- - test/functional/proxy_test.rb
124
- - test/functional/template_test.rb
125
136
  - test/functional/host/create_test.rb
126
137
  - test/functional/host/update_test.rb
127
138
  - test/functional/hostgroup/create_test.rb
128
139
  - test/functional/hostgroup/update_test.rb
129
- - test/test_helper.rb
130
- - test/unit/puppet_environment_test.rb
131
- - test/unit/test_helper.rb
132
- - test/unit/smart_class_parameter_test.rb
133
- - test/unit/config_group_test.rb
134
- - test/unit/test_output_adapter.rb
135
- - test/unit/helpers/resource_disabled.rb
136
- - test/unit/helpers/command.rb
137
- - test/unit/helpers/fake_searchables.rb
138
- - test/unit/puppet_class_test.rb
139
- - test/unit/apipie_resource_mock.rb
140
- - test/data/README.md
141
- - test/data/2.1/foreman_api.json
142
- - test/data/3.0/foreman_api.json
140
+ - test/functional/proxy_test.rb
141
+ - test/functional/smart_class_parameter_test.rb
142
+ - test/functional/test_helper.rb
143
+ - test/functional/template_test.rb
@@ -1,40 +0,0 @@
1
- module HammerCLIForemanPuppet
2
- module AssociatingCommands
3
- module ExtendCommands
4
- def create_subcommand(name = :PuppetEnvironment)
5
- commands = constants.select { |c| c.to_s.include? name.to_s }.map { |p| const_get(p)}
6
- commands.each do |command|
7
- subcommand(command.command_name, command.desc, command, warning: command.warning)
8
- end
9
- end
10
- end
11
-
12
- module PuppetEnvironment
13
- extend HammerCLIForeman::AssociatingCommands::CommandExtension
14
-
15
- class AddPuppetEnvironmentCommand < HammerCLIForemanPuppet::AddAssociatedCommand
16
- include EnvironmentNameMapping
17
- associated_resource :environments
18
- desc _('Associate a Puppet environment')
19
- command_name "add-environment"
20
-
21
- success_message _("The environment has been associated.")
22
- failure_message _("Could not associate the environment")
23
-
24
- extend_with(HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new)
25
- end
26
-
27
- class RemovePuppetEnvironmentCommand < HammerCLIForemanPuppet::RemoveAssociatedCommand
28
- include EnvironmentNameMapping
29
- associated_resource :environments
30
- desc _('Disassociate a Puppet environment')
31
- command_name "remove-environment"
32
-
33
- success_message _("The environment has been disassociated.")
34
- failure_message _("Could not disassociate the environment")
35
-
36
- extend_with(HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new)
37
- end
38
- end
39
- end
40
- end
@@ -1,22 +0,0 @@
1
- module HammerCLIForemanPuppet
2
-
3
- module References
4
-
5
- def self.environments(dsl)
6
- dsl.build do
7
- collection :environments, _("Environments"), :numbered => false do
8
- custom_field Fields::Reference
9
- end
10
- end
11
- end
12
-
13
- def self.puppetclasses(dsl)
14
- dsl.build do
15
- collection :puppetclasses, _("Puppetclasses"), :numbered => false do
16
- custom_field Fields::Reference
17
- end
18
- end
19
- end
20
-
21
- end
22
- end