hammer_cli_foreman_puppet 0.0.3 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +27 -15
- data/lib/hammer_cli_foreman_puppet/combination.rb +23 -0
- data/lib/hammer_cli_foreman_puppet/command_extensions/combination.rb +15 -0
- data/lib/hammer_cli_foreman_puppet/command_extensions/host.rb +27 -2
- data/lib/hammer_cli_foreman_puppet/command_extensions/hostgroup.rb +21 -0
- data/lib/hammer_cli_foreman_puppet/host.rb +5 -0
- data/lib/hammer_cli_foreman_puppet/hostgroup.rb +6 -2
- data/lib/hammer_cli_foreman_puppet/location.rb +1 -14
- data/lib/hammer_cli_foreman_puppet/organization.rb +1 -14
- data/lib/hammer_cli_foreman_puppet/version.rb +1 -1
- data/lib/hammer_cli_foreman_puppet.rb +1 -1
- data/test/data/3.3/foreman_api.json +1 -0
- data/test/functional/host/create_test.rb +35 -4
- data/test/functional/host/update_test.rb +33 -4
- data/test/functional/hostgroup/create_test.rb +34 -5
- data/test/functional/hostgroup/update_test.rb +33 -4
- data/test/functional/template_test.rb +6 -6
- data/test/test_helper.rb +1 -1
- data/test/unit/config_group_test.rb +2 -10
- metadata +26 -26
- data/lib/hammer_cli_foreman_puppet/associating_commands/associating_commands.rb +0 -40
- data/lib/hammer_cli_foreman_puppet/references.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70ea47a81549cde7da9bbdce56937da3c20d4936cc7ebc526cf0d671890e2e80
|
4
|
+
data.tar.gz: 042c018b0757d76f33b5284247a4f84edfceb1d102f48aabd0497399ddc2abb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f4fd40cca5fba2861777cea022d2aed231594e654f73091f0f9861b5f0c15cfa31258dacbf5334988430eb37fed18bc837e10ad52b3ba070016d144d5cbd3cc
|
7
|
+
data.tar.gz: 833af50bdc2165b5b9f93e9dbc056a57379cec64c21251c0ffb707497699df4c76ec9b125fe80b596e2ca91dad4630b4c89654198149d7801ca05ce379a5b3b3
|
data/README.md
CHANGED
@@ -1,20 +1,32 @@
|
|
1
|
-
|
2
|
-
=========================================
|
1
|
+
# Hammer CLI Foreman Puppet
|
3
2
|
|
4
|
-
This
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
@@ -17,8 +17,22 @@ module HammerCLIForemanPuppet
|
|
17
17
|
child '--puppet-classes', 'PUPPET_CLASS_NAMES', '',
|
18
18
|
attribute_name: :option_puppetclass_names
|
19
19
|
end
|
20
|
-
|
21
|
-
|
20
|
+
option_family(
|
21
|
+
format: HammerCLI::Options::Normalizers::List.new,
|
22
|
+
aliased_resource: 'config_group',
|
23
|
+
description: 'Names/Ids of associated config groups'
|
24
|
+
) do
|
25
|
+
parent '--config-group-ids', 'CONFIG_GROUP_IDS', _('IDs of associated config groups'),
|
26
|
+
attribute_name: :option_config_group_ids
|
27
|
+
child '--config-groups', 'CONFIG_GROUP_NAMES', '',
|
28
|
+
attribute_name: :option_config_group_names
|
29
|
+
end
|
30
|
+
option_family associate: 'puppet_proxy' do
|
31
|
+
child '--puppet-proxy', 'PUPPET_PROXY_NAME', _('Name of Puppet proxy')
|
32
|
+
end
|
33
|
+
option_family associate: 'puppet_ca_proxy' do
|
34
|
+
child '--puppet-ca-proxy', 'PUPPET_CA_PROXY_NAME', _('Name of Puppet CA proxy')
|
35
|
+
end
|
22
36
|
|
23
37
|
request_params do |params, command_object|
|
24
38
|
if command_object.option_puppet_proxy
|
@@ -36,6 +50,17 @@ module HammerCLIForemanPuppet
|
|
36
50
|
def self.proxy_id(resolver, name)
|
37
51
|
resolver.smart_proxy_id('option_name' => name)
|
38
52
|
end
|
53
|
+
|
54
|
+
def self.delete_deprecated_options(command_class)
|
55
|
+
%w[--puppetclass-ids --environment-id --config-group-ids].each do |switch|
|
56
|
+
family = command_class.option_families.find do |f|
|
57
|
+
f.head.switches.include?(switch)
|
58
|
+
end
|
59
|
+
command_class.declared_options.delete_if do |o|
|
60
|
+
family.all.include?(o)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
39
64
|
end
|
40
65
|
end
|
41
66
|
end
|
@@ -23,6 +23,16 @@ module HammerCLIForemanPuppet
|
|
23
23
|
child '--puppet-classes', 'PUPPET_CLASS_NAMES', '',
|
24
24
|
attribute_name: :option_puppetclass_names
|
25
25
|
end
|
26
|
+
option_family(
|
27
|
+
format: HammerCLI::Options::Normalizers::List.new,
|
28
|
+
aliased_resource: 'config_group',
|
29
|
+
description: 'Names/Ids of associated config groups'
|
30
|
+
) do
|
31
|
+
parent '--config-group-ids', 'CONFIG_GROUP_IDS', _('IDs of associated config groups'),
|
32
|
+
attribute_name: :option_config_group_ids
|
33
|
+
child '--config-groups', 'CONFIG_GROUP_NAMES', '',
|
34
|
+
attribute_name: :option_config_group_names
|
35
|
+
end
|
26
36
|
option '--puppet-ca-proxy', 'PUPPET_CA_PROXY_NAME', _('Name of Puppet CA proxy')
|
27
37
|
option '--puppet-proxy', 'PUPPET_PROXY_NAME', _('Name of Puppet proxy')
|
28
38
|
|
@@ -42,6 +52,17 @@ module HammerCLIForemanPuppet
|
|
42
52
|
def self.proxy_id(resolver, name)
|
43
53
|
resolver.smart_proxy_id('option_name' => name)
|
44
54
|
end
|
55
|
+
|
56
|
+
def self.delete_deprecated_options(command_class)
|
57
|
+
%w[--puppetclass-ids --environment-id --config-group-ids].each do |switch|
|
58
|
+
family = command_class.option_families.find do |f|
|
59
|
+
f.head.switches.include?(switch)
|
60
|
+
end
|
61
|
+
command_class.declared_options.delete_if do |o|
|
62
|
+
family.all.include?(o)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
45
66
|
end
|
46
67
|
end
|
47
68
|
end
|
@@ -55,11 +55,16 @@ module HammerCLIForemanPuppet
|
|
55
55
|
HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new
|
56
56
|
)
|
57
57
|
HammerCLIForeman::Host::CreateCommand.include(HammerCLIForemanPuppet::EnvironmentNameMapping)
|
58
|
+
# Delete deprecated options explicitly until they are deleted from API
|
59
|
+
HammerCLIForemanPuppet::CommandExtensions::HostPuppetProxy.delete_deprecated_options(HammerCLIForeman::Host::CreateCommand)
|
58
60
|
HammerCLIForeman::Host::CreateCommand.extend_with(
|
59
61
|
HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new,
|
60
62
|
HammerCLIForemanPuppet::CommandExtensions::HostPuppetProxy.new
|
61
63
|
)
|
64
|
+
|
62
65
|
HammerCLIForeman::Host::UpdateCommand.include(HammerCLIForemanPuppet::EnvironmentNameMapping)
|
66
|
+
# Delete deprecated options explicitly until they are deleted from API
|
67
|
+
HammerCLIForemanPuppet::CommandExtensions::HostPuppetProxy.delete_deprecated_options(HammerCLIForeman::Host::UpdateCommand)
|
63
68
|
HammerCLIForeman::Host::UpdateCommand.extend_with(
|
64
69
|
HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new,
|
65
70
|
HammerCLIForemanPuppet::CommandExtensions::HostPuppetProxy.new
|
@@ -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::
|
44
|
+
HammerCLIForemanPuppet::PuppetReferences.puppetclasses(self)
|
46
45
|
end
|
47
46
|
end
|
48
47
|
end
|
@@ -56,11 +55,16 @@ module HammerCLIForemanPuppet
|
|
56
55
|
HammerCLIForemanPuppet::Hostgroup::PuppetSCParamsCommand
|
57
56
|
|
58
57
|
HammerCLIForeman::Hostgroup::CreateCommand.include(HammerCLIForemanPuppet::EnvironmentNameMapping)
|
58
|
+
# Delete deprecated options explicitly until they are deleted from API
|
59
|
+
HammerCLIForemanPuppet::CommandExtensions::HostPuppetProxy.delete_deprecated_options(HammerCLIForeman::Hostgroup::CreateCommand)
|
59
60
|
HammerCLIForeman::Hostgroup::CreateCommand.extend_with(
|
60
61
|
HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new,
|
61
62
|
HammerCLIForemanPuppet::CommandExtensions::HostgroupPuppetProxy.new
|
62
63
|
)
|
64
|
+
|
63
65
|
HammerCLIForeman::Hostgroup::UpdateCommand.include(HammerCLIForemanPuppet::EnvironmentNameMapping)
|
66
|
+
# Delete deprecated options explicitly until they are deleted from API
|
67
|
+
HammerCLIForemanPuppet::CommandExtensions::HostPuppetProxy.delete_deprecated_options(HammerCLIForeman::Hostgroup::UpdateCommand)
|
64
68
|
HammerCLIForeman::Hostgroup::UpdateCommand.extend_with(
|
65
69
|
HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new,
|
66
70
|
HammerCLIForemanPuppet::CommandExtensions::HostgroupPuppetProxy.new
|
@@ -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::
|
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::
|
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,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
|