hammer_cli_foreman_ansible 0.1.2 → 0.3.3

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
- SHA1:
3
- metadata.gz: 711d672a9da9e9f53bbf6b0d80160b768227ac25
4
- data.tar.gz: 99c0f69340edf77b5652a2e9713e7fadc2616b3b
2
+ SHA256:
3
+ metadata.gz: a63fcefc58731191aed327d9be1c107b16345f2428f825e339f41ee7cb8a4a5d
4
+ data.tar.gz: 6c9ce07e90583511bbe55a51273393b2b0e82a46ec7595ddf00bc106b52f3dd8
5
5
  SHA512:
6
- metadata.gz: 393c2f267071a0c52292c1e97364516ef959f961bbece4f3f6fe6299025de5c241082c16b3bed423e6c9ec8dca0e9fefc07577bae38fde6b417cd87c2fc7c982
7
- data.tar.gz: b70e4e201aaf651e0aafedadb85a2b2191f50aad5ae3e13089a7fb06216ceb8f926519a5ef9099833e05739279e623154b64bdcd29148070a2c58f6eaa88387e
6
+ metadata.gz: 7d37d4b6c5490fb66e0d62802f360286d9f0940ac0d26cb099fb065783305365fee3ec7e328d0e973b7366d04d746e0a6f488255ad4d7f1e3f9a1c5afdb2e9cb
7
+ data.tar.gz: 32c611d308d8d459d6940f5688f41581cccb59823044793366fe07361d04bcb459d24958f85a3fe2da63985b32246e8673c252fc295820a8156ead4031814aad
data/README.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # Hammer CLI Foreman Ansible
2
2
 
3
- [Foreman Ansible](https://github.com/theforeman/foreman_ansible) plugin for Hammer CLI
3
+ This Hammer CLI plugin contains set of commands for [foreman_ansible](
4
+ https://github.com/theforeman/foreman_ansible
5
+ ), a plugin to Foreman for Ansible.
6
+
7
+ ## Versions
8
+
9
+ This is the list of which version of Foreman Ansible is needed to which version of this plugin.
10
+
11
+ | hammer_cli_foreman_ansible | 0.1.0+ | 0.2.0+ | 0.3.0+ |
12
+ |----------------------------|--------|--------|--------|
13
+ | foreman_ansible | 2.2.0+ | 2.3.2+ | 2.3.3+ |
4
14
 
5
15
  ## Installation
6
16
 
@@ -15,3 +25,8 @@
15
25
 
16
26
  # to confirm things work, this should return useful output
17
27
  hammer ansible --help
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).
@@ -7,11 +7,12 @@ module HammerCLIForemanAnsible
7
7
  require 'hammer_cli_foreman_ansible/version'
8
8
  require 'hammer_cli_foreman_ansible/i18n'
9
9
  require 'hammer_cli_foreman_ansible/ansible'
10
- require 'hammer_cli_foreman_ansible/base'
11
10
  require 'hammer_cli_foreman_ansible/ansible_roles'
12
11
  require 'hammer_cli_foreman_ansible/host'
13
12
  require 'hammer_cli_foreman_ansible/hostgroup'
14
13
 
14
+ require 'hammer_cli_foreman_ansible/command_extensions'
15
+
15
16
  HammerCLI::MainCommand.lazy_subcommand(
16
17
  'ansible',
17
18
  'Manage foreman ansible',
@@ -19,15 +20,15 @@ module HammerCLIForemanAnsible
19
20
  'hammer_cli_foreman_ansible/ansible'
20
21
  )
21
22
  HammerCLIForeman::Host.lazy_subcommand(
22
- HostAnsibleRolesCommand.command_name,
23
- HostAnsibleRolesCommand.desc,
24
- 'HammerCLIForemanAnsible::HostAnsibleRolesCommand',
23
+ Host::AnsibleRolesCommand.command_name,
24
+ Host::AnsibleRolesCommand.desc,
25
+ 'HammerCLIForemanAnsible::Host::AnsibleRolesCommand',
25
26
  'hammer_cli_foreman_ansible/host'
26
27
  )
27
28
  HammerCLIForeman::Hostgroup.lazy_subcommand(
28
- HostgroupAnsibleRolesCommand.command_name,
29
- HostgroupAnsibleRolesCommand.desc,
30
- 'HammerCLIForemanAnsible::HostgroupAnsibleRolesCommand',
29
+ Hostgroup::AnsibleRolesCommand.command_name,
30
+ Hostgroup::AnsibleRolesCommand.desc,
31
+ 'HammerCLIForemanAnsible::Hostgroup::AnsibleRolesCommand',
31
32
  'hammer_cli_foreman_ansible/hostgroup'
32
33
  )
33
34
  end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module HammerCLIForemanAnsible
2
4
  class AnsibleCommand < HammerCLI::AbstractCommand
3
-
4
5
  lazy_subcommand(
5
6
  'roles',
6
7
  _('Manage ansible roles'),
@@ -1,14 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module HammerCLIForemanAnsible
2
4
  class AnsibleRolesCommand < HammerCLIForeman::Command
3
5
  resource :ansible_roles
4
6
 
5
- class InfoCommand < HammerCLIForeman::InfoCommand
6
- output BaseAnsibleRolesCommand.output_definition
7
+ class ListCommand < HammerCLIForeman::ListCommand
8
+ output do
9
+ field :id, _('Id')
10
+ field :name, _('Name')
11
+ field :created_at, _('Imported at'), Fields::Date
12
+ end
7
13
  build_options
8
14
  end
9
15
 
10
- class ListCommand < HammerCLIForeman::ListCommand
11
- output AnsibleRolesCommand::InfoCommand.output_definition
16
+ class InfoCommand < HammerCLIForeman::InfoCommand
17
+ output AnsibleRolesCommand::ListCommand.output_definition
12
18
  build_options
13
19
  end
14
20
 
@@ -19,7 +25,19 @@ module HammerCLIForemanAnsible
19
25
  build_options
20
26
  end
21
27
 
22
- class ChangedCommand < HammerCLIForeman::Command
28
+ class ImportCommand < HammerCLIForeman::Command
29
+ action :import
30
+ command_name 'import'
31
+
32
+ failure_message _('Could not import roles')
33
+
34
+ output do
35
+ field :message, _('Result'), Fields::LongText
36
+ collection :changed, _('Imported'), hide_blank: true do
37
+ field :name, nil
38
+ end
39
+ end
40
+
23
41
  def execute
24
42
  response = {}
25
43
  response['changed'] = send_request
@@ -30,33 +48,45 @@ module HammerCLIForemanAnsible
30
48
  print_data(response)
31
49
  HammerCLI::EX_OK
32
50
  end
51
+
52
+ build_options
33
53
  end
34
54
 
35
- class ImportCommand < ChangedCommand
36
- action :import
37
- command_name 'import'
55
+ class ObsoleteCommand < HammerCLIForeman::Command
56
+ action :obsolete
57
+ command_name 'obsolete'
38
58
 
39
- failure_message _('Could not import roles')
59
+ failure_message _('Could not obsolete roles')
40
60
 
41
61
  output do
42
62
  field :message, _('Result'), Fields::LongText
43
- collection :changed, _('Imported'), hide_blank: true do
63
+ collection :changed, _('Obsoleted'), hide_blank: true do
44
64
  field :name, nil
45
65
  end
46
66
  end
47
67
 
68
+ def execute
69
+ response = {}
70
+ response['changed'] = send_request
71
+ response['message'] = _('The following ansible roles were changed')
72
+ if response['changed'].empty?
73
+ response['message'] = _('No changes in ansible roles detected.')
74
+ end
75
+ print_data(response)
76
+ HammerCLI::EX_OK
77
+ end
78
+
48
79
  build_options
49
80
  end
50
81
 
51
- class ObsoleteCommand < ChangedCommand
52
- action :obsolete
53
- command_name 'obsolete'
82
+ class FetchCommand < HammerCLIForeman::Command
83
+ action :fetch
84
+ command_name 'fetch'
54
85
 
55
- failure_message _('Could not obsolete roles')
86
+ failure_message _('Could not fetch roles')
56
87
 
57
88
  output do
58
- field :message, _('Result'), Fields::LongText
59
- collection :changed, _('Obsoleted'), hide_blank: true do
89
+ collection :ansible_roles, _('Ansible roles available to be imported') do
60
90
  field :name, nil
61
91
  end
62
92
  end
@@ -64,6 +94,28 @@ module HammerCLIForemanAnsible
64
94
  build_options
65
95
  end
66
96
 
97
+ class PlayHostsCommand < HammerCLIForeman::Command
98
+ resource :hosts
99
+ action :multiple_play_roles
100
+ command_name 'play-hosts'
101
+
102
+ success_message _("Ansible roles are being played. Job ID: %{id}")
103
+ failure_message _('Could not play roles on hosts')
104
+
105
+ build_options
106
+ end
107
+
108
+ class PlayHostgroupsCommand < HammerCLIForeman::Command
109
+ resource :hostgroups
110
+ action :multiple_play_roles
111
+ command_name 'play-hostgroups'
112
+
113
+ success_message _("Ansible roles are being played. Job ID: %{id}")
114
+ failure_message _('Could not play roles on hostgroups')
115
+
116
+ build_options
117
+ end
118
+
67
119
  autoload_subcommands
68
120
  end
69
121
  end
@@ -1,9 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module HammerCLIForemanAnsible
2
4
  class AnsibleVariablesCommand < HammerCLIForeman::Command
3
5
  resource :ansible_variables
4
6
 
5
7
  class ListCommand < HammerCLIForeman::ListCommand
6
- output BaseAnsibleVariablesCommand.output_definition
8
+ output do
9
+ field :id, _('Id')
10
+
11
+ field :variable, _('Variable')
12
+ field :default_value, _('Default Value')
13
+ field :variable_type, _('Type')
14
+
15
+ field :ansible_role, _('Role')
16
+ field :ansible_role_id, _('Role Id'), Fields::Id
17
+ end
18
+
7
19
  build_options
8
20
  end
9
21
 
@@ -17,6 +29,7 @@ module HammerCLIForemanAnsible
17
29
  field :validator_rule, _("Rule")
18
30
  end
19
31
  label _("Override values") do
32
+ field :override, _("Override"), Fields::Boolean
20
33
  field :merge_overrides, _("Merge overrides"), Fields::Boolean
21
34
  field :merge_default, _("Merge default value"), Fields::Boolean
22
35
  field :avoid_duplicates, _("Avoid duplicates"), Fields::Boolean
@@ -33,6 +46,13 @@ module HammerCLIForemanAnsible
33
46
  build_options
34
47
  end
35
48
 
49
+ class CreateCommand < HammerCLIForeman::CreateCommand
50
+ success_message _("Ansible variable [%{variable}] was created.")
51
+ failure_message _("Could not create the ansible variable")
52
+
53
+ build_options
54
+ end
55
+
36
56
  class DeleteCommand < HammerCLIForeman::DeleteCommand
37
57
  success_message _('Ansible variable [%{variable}] was deleted.')
38
58
  failure_message _('Could not delete the variable')
@@ -47,20 +67,7 @@ module HammerCLIForemanAnsible
47
67
  build_options
48
68
  end
49
69
 
50
- class ChangedCommand < HammerCLIForeman::Command
51
- def execute
52
- response = {}
53
- response['changed'] = send_request
54
- response['message'] = _('The following ansible variables were changed')
55
- if response['changed'].empty?
56
- response['message'] = _('No changes in ansible variables detected.')
57
- end
58
- print_data(response)
59
- HammerCLI::EX_OK
60
- end
61
- end
62
-
63
- class ImportCommand < ChangedCommand
70
+ class ImportCommand < HammerCLIForeman::Command
64
71
  action :import
65
72
  command_name 'import'
66
73
 
@@ -73,10 +80,21 @@ module HammerCLIForemanAnsible
73
80
  end
74
81
  end
75
82
 
83
+ def execute
84
+ response = {}
85
+ response['changed'] = send_request
86
+ response['message'] = _('The following ansible variables were changed')
87
+ if response['changed'].empty?
88
+ response['message'] = _('No changes in ansible variables detected.')
89
+ end
90
+ print_data(response)
91
+ HammerCLI::EX_OK
92
+ end
93
+
76
94
  build_options
77
95
  end
78
96
 
79
- class ObsoleteCommand < ChangedCommand
97
+ class ObsoleteCommand < HammerCLIForeman::Command
80
98
  action :obsolete
81
99
  command_name 'obsolete'
82
100
 
@@ -89,6 +107,17 @@ module HammerCLIForemanAnsible
89
107
  end
90
108
  end
91
109
 
110
+ def execute
111
+ response = {}
112
+ response['changed'] = send_request
113
+ response['message'] = _('The following ansible variables were changed')
114
+ if response['changed'].empty?
115
+ response['message'] = _('No changes in ansible variables detected.')
116
+ end
117
+ print_data(response)
118
+ HammerCLI::EX_OK
119
+ end
120
+
92
121
  build_options
93
122
  end
94
123
 
@@ -0,0 +1 @@
1
+ require 'hammer_cli_foreman_ansible/command_extensions/resolver'
@@ -0,0 +1,15 @@
1
+ module HammerCLIForemanAnsible
2
+ module ResolverExtension
3
+ def create_ansible_roles_search_options(options, mode = nil)
4
+ if defined? HammerCLIKatello::IdResolver
5
+ create_search_options_without_katello_api(options, api.resource(:ansible_roles), mode)
6
+ else
7
+ create_search_options(options, api.resource(:ansible_roles), mode)
8
+ end
9
+ end
10
+ end
11
+
12
+ ::HammerCLIForeman::IdResolver.instance_eval do
13
+ include ResolverExtension
14
+ end
15
+ end
@@ -1,6 +1,41 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module HammerCLIForemanAnsible
2
- class HostAnsibleRolesCommand < BaseAnsibleRolesCommand
4
+ class Host < HammerCLIForeman::Command
3
5
  resource :hosts
4
- build_options
6
+
7
+ class AnsibleRolesCommand < HammerCLIForeman::Command
8
+ command_name 'ansible-roles'
9
+ desc _('Manage Ansible roles on a host')
10
+
11
+ class ListCommand < HammerCLIForeman::ListCommand
12
+ action :ansible_roles
13
+
14
+ output HammerCLIForemanAnsible::AnsibleRolesCommand::ListCommand.output_definition
15
+
16
+ build_options
17
+ end
18
+
19
+ class PlayCommand < HammerCLIForeman::Command
20
+ command_name 'play'
21
+ action :play_roles
22
+
23
+ success_message _('Ansible roles are being played. Job ID: %{id}')
24
+ failure_message _('Could not play roles on a host')
25
+
26
+ build_options
27
+ end
28
+
29
+ class AssignRolesCommand < HammerCLIForeman::Command
30
+ command_name 'assign'
31
+ action :assign_ansible_roles
32
+
33
+ success_message _('Ansible roles were assigned to the host')
34
+ failure_message _('Could not assign roles to the host')
35
+
36
+ build_options
37
+ end
38
+ autoload_subcommands
39
+ end
5
40
  end
6
41
  end
@@ -1,6 +1,42 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module HammerCLIForemanAnsible
2
- class HostgroupAnsibleRolesCommand < BaseAnsibleRolesCommand
4
+ class Hostgroup < HammerCLIForeman::Command
3
5
  resource :hostgroups
4
- build_options
6
+
7
+ class AnsibleRolesCommand < HammerCLIForeman::Command
8
+ command_name 'ansible-roles'
9
+ desc _('Manage Ansible roles on a hostgroup')
10
+
11
+ class ListCommand < HammerCLIForeman::ListCommand
12
+ action :ansible_roles
13
+
14
+ output HammerCLIForemanAnsible::AnsibleRolesCommand::ListCommand.output_definition
15
+
16
+ build_options
17
+ end
18
+
19
+ class PlayCommand < HammerCLIForeman::Command
20
+ command_name 'play'
21
+ action :play_roles
22
+
23
+ success_message _('Ansible roles are being played. Job ID: %{id}')
24
+ failure_message _('Could not play roles on a hostgroup')
25
+
26
+ build_options
27
+ end
28
+
29
+ class AssignRolesCommand < HammerCLIForeman::Command
30
+ command_name 'assign'
31
+ action :assign_ansible_roles
32
+
33
+ success_message _('Ansible roles were assigned to the hostgroup')
34
+ failure_message _('Could not assign roles to the hostgroup')
35
+
36
+ build_options
37
+ end
38
+
39
+ autoload_subcommands
40
+ end
5
41
  end
6
42
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'hammer_cli/i18n'
2
4
 
3
5
  module HammerCLIForemanAnsible
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module HammerCLIForemanAnsible
2
4
  def self.version
3
- @version ||= Gem::Version.new '0.1.2'
5
+ @version ||= Gem::Version.new '0.3.3'
4
6
  end
5
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_foreman_ansible
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleh Fedorenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-25 00:00:00.000000000 Z
11
+ date: 2021-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hammer_cli_foreman
@@ -80,7 +80,8 @@ files:
80
80
  - lib/hammer_cli_foreman_ansible/ansible.rb
81
81
  - lib/hammer_cli_foreman_ansible/ansible_roles.rb
82
82
  - lib/hammer_cli_foreman_ansible/ansible_variables.rb
83
- - lib/hammer_cli_foreman_ansible/base.rb
83
+ - lib/hammer_cli_foreman_ansible/command_extensions.rb
84
+ - lib/hammer_cli_foreman_ansible/command_extensions/resolver.rb
84
85
  - lib/hammer_cli_foreman_ansible/host.rb
85
86
  - lib/hammer_cli_foreman_ansible/hostgroup.rb
86
87
  - lib/hammer_cli_foreman_ansible/i18n.rb
@@ -105,8 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
106
  - !ruby/object:Gem::Version
106
107
  version: '0'
107
108
  requirements: []
108
- rubyforge_project:
109
- rubygems_version: 2.6.8
109
+ rubygems_version: 3.1.2
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: Foreman Ansible plugin for Hammer CLI
@@ -1,40 +0,0 @@
1
- module HammerCLIForemanAnsible
2
- class BaseAnsibleRolesCommand < HammerCLIForeman::Command
3
- command_name 'ansible-roles'
4
- desc _('List all Ansible roles')
5
-
6
- action :ansible_roles
7
-
8
- output do
9
- field :id, _('Id')
10
- field :name, _('Name')
11
- field :created_at, _('Imported at'), Fields::Date
12
- end
13
-
14
- def adapter
15
- :table
16
- end
17
- end
18
-
19
- class BaseAnsibleVariablesCommand < HammerCLIForeman::Command
20
- command_name 'ansible-variables'
21
- desc _('List all Ansible variables')
22
-
23
- action :ansible_variables
24
-
25
- output do
26
- field :id, _('Id')
27
-
28
- field :variable, _('Variable')
29
- field :default_value, _('Default Value')
30
- field :variable_type, _('Type')
31
-
32
- field :ansible_role, _('Role')
33
- field :ansible_role_id, _('Role Id'), Fields::Id
34
- end
35
-
36
- def adapter
37
- :table
38
- end
39
- end
40
- end