hammer_cli_foreman_ansible 0.1.2 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 711d672a9da9e9f53bbf6b0d80160b768227ac25
4
- data.tar.gz: 99c0f69340edf77b5652a2e9713e7fadc2616b3b
2
+ SHA256:
3
+ metadata.gz: 112a9a2f17f8e7c0149d5ec348472d2d89e9151117055ae4e9d07941544190b0
4
+ data.tar.gz: cc10c500cebe02c1d1ac83b562df854a2821f210842142d1043e4f98e5aaa1fe
5
5
  SHA512:
6
- metadata.gz: 393c2f267071a0c52292c1e97364516ef959f961bbece4f3f6fe6299025de5c241082c16b3bed423e6c9ec8dca0e9fefc07577bae38fde6b417cd87c2fc7c982
7
- data.tar.gz: b70e4e201aaf651e0aafedadb85a2b2191f50aad5ae3e13089a7fb06216ceb8f926519a5ef9099833e05739279e623154b64bdcd29148070a2c58f6eaa88387e
6
+ metadata.gz: c1b3efec9a7988157cf24b9ab3b669c9d0c416ac2348a2d497fda3476a9fe091a55b906f185f54c2b319968a65ec7686cac3f6b1063fd749fc81ea4dc1e876e9
7
+ data.tar.gz: 3f2760ff90bb62ab888ad7647ca1ae04fd7b661cd1eb6288d954440f6de36f5b0f861497087e4c346985fdd206505ddf31b477ac3a61425ada3c74960e4b018a
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+ |
12
+ |----------------------------|--------|--------|
13
+ | foreman_ansible | 2.2.0+ | 2.3.2+ |
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,7 +7,6 @@ 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'
@@ -19,15 +18,15 @@ module HammerCLIForemanAnsible
19
18
  'hammer_cli_foreman_ansible/ansible'
20
19
  )
21
20
  HammerCLIForeman::Host.lazy_subcommand(
22
- HostAnsibleRolesCommand.command_name,
23
- HostAnsibleRolesCommand.desc,
24
- 'HammerCLIForemanAnsible::HostAnsibleRolesCommand',
21
+ Host::AnsibleRolesCommand.command_name,
22
+ Host::AnsibleRolesCommand.desc,
23
+ 'HammerCLIForemanAnsible::Host::AnsibleRolesCommand',
25
24
  'hammer_cli_foreman_ansible/host'
26
25
  )
27
26
  HammerCLIForeman::Hostgroup.lazy_subcommand(
28
- HostgroupAnsibleRolesCommand.command_name,
29
- HostgroupAnsibleRolesCommand.desc,
30
- 'HammerCLIForemanAnsible::HostgroupAnsibleRolesCommand',
27
+ Hostgroup::AnsibleRolesCommand.command_name,
28
+ Hostgroup::AnsibleRolesCommand.desc,
29
+ 'HammerCLIForemanAnsible::Hostgroup::AnsibleRolesCommand',
31
30
  'hammer_cli_foreman_ansible/hostgroup'
32
31
  )
33
32
  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,13 +1,19 @@
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
16
+ class InfoCommand < HammerCLIForeman::InfoCommand
11
17
  output AnsibleRolesCommand::InfoCommand.output_definition
12
18
  build_options
13
19
  end
@@ -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
 
@@ -47,20 +59,7 @@ module HammerCLIForemanAnsible
47
59
  build_options
48
60
  end
49
61
 
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
62
+ class ImportCommand < HammerCLIForeman::Command
64
63
  action :import
65
64
  command_name 'import'
66
65
 
@@ -73,10 +72,21 @@ module HammerCLIForemanAnsible
73
72
  end
74
73
  end
75
74
 
75
+ def execute
76
+ response = {}
77
+ response['changed'] = send_request
78
+ response['message'] = _('The following ansible variables were changed')
79
+ if response['changed'].empty?
80
+ response['message'] = _('No changes in ansible variables detected.')
81
+ end
82
+ print_data(response)
83
+ HammerCLI::EX_OK
84
+ end
85
+
76
86
  build_options
77
87
  end
78
88
 
79
- class ObsoleteCommand < ChangedCommand
89
+ class ObsoleteCommand < HammerCLIForeman::Command
80
90
  action :obsolete
81
91
  command_name 'obsolete'
82
92
 
@@ -89,6 +99,17 @@ module HammerCLIForemanAnsible
89
99
  end
90
100
  end
91
101
 
102
+ def execute
103
+ response = {}
104
+ response['changed'] = send_request
105
+ response['message'] = _('The following ansible variables were changed')
106
+ if response['changed'].empty?
107
+ response['message'] = _('No changes in ansible variables detected.')
108
+ end
109
+ print_data(response)
110
+ HammerCLI::EX_OK
111
+ end
112
+
92
113
  build_options
93
114
  end
94
115
 
@@ -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.2.0'
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.2.0
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: 2019-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hammer_cli_foreman
@@ -80,7 +80,6 @@ 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
84
83
  - lib/hammer_cli_foreman_ansible/host.rb
85
84
  - lib/hammer_cli_foreman_ansible/hostgroup.rb
86
85
  - lib/hammer_cli_foreman_ansible/i18n.rb
@@ -106,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
105
  version: '0'
107
106
  requirements: []
108
107
  rubyforge_project:
109
- rubygems_version: 2.6.8
108
+ rubygems_version: 2.7.9
110
109
  signing_key:
111
110
  specification_version: 4
112
111
  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