forked from theforeman/hammer-cli-foreman-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
host.rb
83 lines (60 loc) · 2.48 KB
/
host.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# frozen_string_literal: true
module HammerCLIForemanAnsible
class Host < HammerCLIForeman::Command
resource :hosts
class AnsibleRolesCommand < HammerCLIForeman::Command
command_name 'ansible-roles'
desc _('Manage Ansible roles on a host')
class ListCommand < HammerCLIForeman::ListCommand
action :ansible_roles
output(HammerCLIForemanAnsible::AnsibleRolesCommand::ListCommand.output_definition) do
field :inherited, _('Inherited'), Fields::Boolean
field :directly_assigned, _('Directly assigned'), Fields::Boolean
end
build_options
end
class PlayCommand < HammerCLIForeman::Command
command_name 'play'
action :play_roles
success_message _('Ansible roles are being played. Job ID: %{id}')
failure_message _('Could not play roles on a host')
build_options
end
class AssignRolesCommand < HammerCLIForeman::Command
command_name 'assign'
action :assign_ansible_roles
success_message _('Ansible roles were assigned to the host')
failure_message _('Could not assign roles to the host')
build_options
end
class AddAnsibleRoleCommand < HammerCLIForeman::AddAssociatedCommand
prepend HammerCLIForemanAnsible::AssociatedAnsibleRole
command_name 'add'
associated_resource :ansible_roles
desc _('Associate an Ansible role')
option '--force', :flag, _('Associate the Ansible role even if it already is associated indirectly')
success_message _('Ansible role has been associated.')
failure_message _('Could not associate the Ansible role')
validate_options do
any(:option_name, :option_id).required
any(:option_ansible_role_name, :option_ansible_role_id).required
end
build_options
end
class RemoveAnsibleRoleCommand < HammerCLIForeman::RemoveAssociatedCommand
prepend HammerCLIForemanAnsible::AssociatedAnsibleRole
command_name 'remove'
associated_resource :ansible_roles
desc _('Disassociate an Ansible role')
success_message _('Ansible role has been disassociated.')
failure_message _('Could not disassociate the Ansible role')
validate_options do
any(:option_name, :option_id).required
any(:option_ansible_role_name, :option_ansible_role_id).required
end
build_options
end
autoload_subcommands
end
end
end