foreman_remote_execution 1.6.3 → 1.6.4
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/app/assets/javascripts/foreman_remote_execution/template_input.js +0 -10
- data/app/assets/javascripts/foreman_remote_execution/template_invocation.js +1 -12
- data/app/assets/stylesheets/foreman_remote_execution/template_invocation.css.scss +1 -0
- data/app/controllers/api/v2/job_invocations_controller.rb +5 -1
- data/app/helpers/job_invocation_output_helper.rb +5 -4
- data/app/helpers/job_invocations_helper.rb +0 -29
- data/app/helpers/remote_execution_helper.rb +1 -24
- data/app/lib/foreman_remote_execution/renderer/scope/input.rb +28 -8
- data/app/models/concerns/foreman_remote_execution/template_extensions.rb +0 -12
- data/app/models/concerns/foreman_remote_execution/template_input_extensions.rb +9 -0
- data/app/models/concerns/foreman_remote_execution/template_overrides.rb +11 -0
- data/app/models/input_template_renderer.rb +16 -17
- data/app/models/job_invocation.rb +14 -4
- data/app/models/job_invocation_composer.rb +2 -6
- data/app/models/job_template.rb +23 -52
- data/app/models/template_invocation_input_value.rb +12 -1
- data/app/views/api/v2/smart_proxies/pubkey.json.rabl +1 -0
- data/app/views/job_invocations/_form.html.erb +1 -7
- data/app/views/job_templates/_custom_tabs.html.erb +0 -7
- data/app/views/template_invocations/_output_line_set.html.erb +2 -2
- data/app/views/templates/ssh/module_action.erb +67 -0
- data/app/views/templates/ssh/package_action.erb +39 -7
- data/app/views/templates/ssh/power_action.erb +2 -1
- data/app/views/templates/ssh/puppet_run_once.erb +1 -0
- data/app/views/templates/ssh/run_command.erb +1 -0
- data/app/views/templates/ssh/service_action.erb +9 -1
- data/config/routes.rb +0 -1
- data/lib/foreman_remote_execution/engine.rb +4 -0
- data/lib/foreman_remote_execution/version.rb +1 -1
- data/locale/de/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/de/foreman_remote_execution.po +3 -72
- data/locale/en/foreman_remote_execution.po +3 -72
- data/locale/en_GB/foreman_remote_execution.po +3 -72
- data/locale/es/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/es/foreman_remote_execution.po +3 -72
- data/locale/foreman_remote_execution.pot +124 -225
- data/locale/fr/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/fr/foreman_remote_execution.po +3 -72
- data/locale/ja/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/ja/foreman_remote_execution.po +3 -72
- data/locale/ko/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/ko/foreman_remote_execution.po +3 -72
- data/locale/pt_BR/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/pt_BR/foreman_remote_execution.po +3 -72
- data/locale/ru/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/ru/foreman_remote_execution.po +3 -72
- data/locale/zh_CN/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/zh_CN/foreman_remote_execution.po +3 -72
- data/locale/zh_TW/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/zh_TW/foreman_remote_execution.po +3 -72
- data/test/factories/foreman_remote_execution_factories.rb +6 -5
- data/test/functional/api/v2/job_invocations_controller_test.rb +10 -0
- data/test/unit/input_template_renderer_test.rb +52 -21
- data/test/unit/job_invocation_composer_test.rb +2 -2
- data/test/unit/job_invocation_test.rb +36 -0
- metadata +6 -19
- data/app/controllers/api/v2/template_inputs_controller.rb +0 -92
- data/app/controllers/concerns/foreman/controller/parameters/template_input.rb +0 -17
- data/app/models/template_input.rb +0 -179
- data/app/views/api/v2/template_inputs/base.json.rabl +0 -3
- data/app/views/api/v2/template_inputs/create.json.rabl +0 -3
- data/app/views/api/v2/template_inputs/index.json.rabl +0 -3
- data/app/views/api/v2/template_inputs/main.json.rabl +0 -10
- data/app/views/api/v2/template_inputs/show.json.rabl +0 -3
- data/app/views/template_inputs/_form.html.erb +0 -25
- data/app/views/template_inputs/_invocation_form.html.erb +0 -7
- data/db/migrate/20150616080015_create_template_input.rb +0 -19
- data/db/migrate/20150827152730_add_options_to_template_input.rb +0 -5
- data/db/migrate/20160127134031_add_advanced_to_template_input.rb +0 -11
- data/test/functional/api/v2/template_inputs_controller_test.rb +0 -56
- data/test/unit/template_input_test.rb +0 -40
    
        data/app/models/job_template.rb
    CHANGED
    
    | @@ -6,7 +6,7 @@ class JobTemplate < ::Template | |
| 6 6 | 
             
              class NonUniqueInputsError < Foreman::Exception
         | 
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 | 
            -
              attr_exportable :job_category, :description_format, | 
| 9 | 
            +
              attr_exportable :job_category, :description_format,
         | 
| 10 10 | 
             
                              :foreign_input_sets, :provider_type,
         | 
| 11 11 | 
             
                              { :kind => ->(template) { template.class.name.underscore } }.merge(taxonomy_exportable)
         | 
| 12 12 |  | 
| @@ -43,15 +43,6 @@ class JobTemplate < ::Template | |
| 43 43 | 
             
              validates :provider_type, :presence => true
         | 
| 44 44 | 
             
              validates :name, :uniqueness => true
         | 
| 45 45 | 
             
              validate :provider_type_whitelist
         | 
| 46 | 
            -
              validate :inputs_unchanged_when_locked, :if => ->(template) { (template.locked? || template.locked_changed?) && template.persisted? && !Foreman.in_rake? }
         | 
| 47 | 
            -
             | 
| 48 | 
            -
              validate do
         | 
| 49 | 
            -
                begin
         | 
| 50 | 
            -
                  validate_unique_inputs!
         | 
| 51 | 
            -
                rescue Foreman::Exception => e
         | 
| 52 | 
            -
                  errors.add :base, e.message
         | 
| 53 | 
            -
                end
         | 
| 54 | 
            -
              end
         | 
| 55 46 | 
             
              validates_associated :foreign_input_sets
         | 
| 56 47 |  | 
| 57 48 | 
             
              has_one :effective_user, :class_name => 'JobTemplateEffectiveUser', :foreign_key => 'job_template_id', :dependent => :destroy
         | 
| @@ -90,6 +81,21 @@ class JobTemplate < ::Template | |
| 90 81 | 
             
                    template
         | 
| 91 82 | 
             
                  end
         | 
| 92 83 | 
             
                end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                def acceptable_template_input_types
         | 
| 86 | 
            +
                  [ :user, :fact, :variable, :puppet_parameter ]
         | 
| 87 | 
            +
                end
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                def default_render_scope_class
         | 
| 90 | 
            +
                  ForemanRemoteExecution::Renderer::Scope::Input
         | 
| 91 | 
            +
                end
         | 
| 92 | 
            +
              end
         | 
| 93 | 
            +
             | 
| 94 | 
            +
              def validate_unique_inputs!
         | 
| 95 | 
            +
                duplicated_inputs = template_inputs_with_foreign.group_by(&:name).values.select { |values| values.size > 1 }.map(&:first)
         | 
| 96 | 
            +
                unless duplicated_inputs.empty?
         | 
| 97 | 
            +
                  raise NonUniqueInputsError.new(N_('Duplicated inputs detected: %{duplicated_inputs}'), :duplicated_inputs => duplicated_inputs.map(&:name))
         | 
| 98 | 
            +
                end
         | 
| 93 99 | 
             
              end
         | 
| 94 100 |  | 
| 95 101 | 
             
              def metadata
         | 
| @@ -111,14 +117,6 @@ class JobTemplate < ::Template | |
| 111 117 | 
             
                []
         | 
| 112 118 | 
             
              end
         | 
| 113 119 |  | 
| 114 | 
            -
              def dup
         | 
| 115 | 
            -
                dup = super
         | 
| 116 | 
            -
                self.template_inputs.each do |input|
         | 
| 117 | 
            -
                  dup.template_inputs.build input.attributes.except('template_id', 'id', 'created_at', 'updated_at')
         | 
| 118 | 
            -
                end
         | 
| 119 | 
            -
                dup
         | 
| 120 | 
            -
              end
         | 
| 121 | 
            -
             | 
| 122 120 | 
             
              def assign_taxonomies
         | 
| 123 121 | 
             
                if default
         | 
| 124 122 | 
             
                  organizations << Organization.all if SETTINGS[:organizations_enabled]
         | 
| @@ -147,31 +145,6 @@ class JobTemplate < ::Template | |
| 147 145 | 
             
                end
         | 
| 148 146 | 
             
              end
         | 
| 149 147 |  | 
| 150 | 
            -
              def validate_unique_inputs!
         | 
| 151 | 
            -
                duplicated_inputs = template_inputs_with_foreign.group_by(&:name).values.select { |values| values.size > 1 }.map(&:first)
         | 
| 152 | 
            -
                unless duplicated_inputs.empty?
         | 
| 153 | 
            -
                  raise NonUniqueInputsError.new(N_('Duplicated inputs detected: %{duplicated_inputs}'), :duplicated_inputs => duplicated_inputs.map(&:name))
         | 
| 154 | 
            -
                end
         | 
| 155 | 
            -
              end
         | 
| 156 | 
            -
             | 
| 157 | 
            -
              def sync_inputs(inputs)
         | 
| 158 | 
            -
                inputs ||= []
         | 
| 159 | 
            -
                # Build a hash where keys are input names
         | 
| 160 | 
            -
                inputs = inputs.inject({}) { |h, input| h.update(input['name'] => input) }
         | 
| 161 | 
            -
             | 
| 162 | 
            -
                # Sync existing inputs
         | 
| 163 | 
            -
                template_inputs.each do |existing_input|
         | 
| 164 | 
            -
                  if inputs.include?(existing_input.name)
         | 
| 165 | 
            -
                    existing_input.assign_attributes(inputs.delete(existing_input.name))
         | 
| 166 | 
            -
                  else
         | 
| 167 | 
            -
                    existing_input.mark_for_destruction
         | 
| 168 | 
            -
                  end
         | 
| 169 | 
            -
                end
         | 
| 170 | 
            -
             | 
| 171 | 
            -
                # Create new inputs
         | 
| 172 | 
            -
                inputs.each_value { |new_input| template_inputs.build(new_input) }
         | 
| 173 | 
            -
              end
         | 
| 174 | 
            -
             | 
| 175 148 | 
             
              def sync_foreign_input_sets(input_sets)
         | 
| 176 149 | 
             
                input_sets ||= []
         | 
| 177 150 |  | 
| @@ -201,7 +174,7 @@ class JobTemplate < ::Template | |
| 201 174 | 
             
              end
         | 
| 202 175 |  | 
| 203 176 | 
             
              def import_custom_data(options)
         | 
| 204 | 
            -
                 | 
| 177 | 
            +
                super
         | 
| 205 178 | 
             
                sync_foreign_input_sets(@importing_metadata['foreign_input_sets'])
         | 
| 206 179 | 
             
                sync_feature(@importing_metadata['feature'])
         | 
| 207 180 |  | 
| @@ -218,18 +191,16 @@ class JobTemplate < ::Template | |
| 218 191 | 
             
                self.template = self.template.gsub(/<%\#.+?.-?%>\n?/m, '').strip
         | 
| 219 192 | 
             
              end
         | 
| 220 193 |  | 
| 194 | 
            +
              def default_input_values(ignore_keys)
         | 
| 195 | 
            +
                result = self.template_inputs_with_foreign.select { |ti| !ti.required? && ti.user_template_input? }.map { |ti| ti.name.to_s }
         | 
| 196 | 
            +
                result -= ignore_keys.map(&:to_s)
         | 
| 197 | 
            +
                Hash[result.map { |k| [ k, nil ] }]
         | 
| 198 | 
            +
              end
         | 
| 199 | 
            +
             | 
| 221 200 | 
             
              private
         | 
| 222 201 |  | 
| 223 202 | 
             
              # we can't use standard validator, .provider_names output can change but the validator does not reflect it
         | 
| 224 203 | 
             
              def provider_type_whitelist
         | 
| 225 204 | 
             
                errors.add :provider_type, :uniq unless RemoteExecutionProvider.provider_names.include?(self.provider_type)
         | 
| 226 205 | 
             
              end
         | 
| 227 | 
            -
             | 
| 228 | 
            -
              def inputs_unchanged_when_locked
         | 
| 229 | 
            -
                inputs_changed = template_inputs.any? { |input| input.changed? || input.new_record? }
         | 
| 230 | 
            -
                foreign_input_sets_changed = foreign_input_sets.any? { |input_set| input_set.changed? || input_set.new_record? }
         | 
| 231 | 
            -
                if inputs_changed || foreign_input_sets_changed
         | 
| 232 | 
            -
                  errors.add(:base, _('This template is locked. Please clone it to a new template to customize.'))
         | 
| 233 | 
            -
                end
         | 
| 234 | 
            -
              end
         | 
| 235 206 | 
             
            end
         | 
| @@ -5,6 +5,17 @@ class TemplateInvocationInputValue < ApplicationRecord | |
| 5 5 |  | 
| 6 6 | 
             
              validates :value, :presence => true, :if => proc { |v| v.template_input.required? || v.value.nil? }
         | 
| 7 7 |  | 
| 8 | 
            -
              validates :value, :inclusion => { :in => proc { |v| v.template_input | 
| 8 | 
            +
              validates :value, :inclusion => { :in => proc { |v| options_for_template_input v.template_input } },
         | 
| 9 9 | 
             
                                :if => proc { |v| v.template_input.input_type == 'user' && v.template_input.options_array.present? }
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              class << self
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                private
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                def options_for_template_input(template_input)
         | 
| 16 | 
            +
                  options = template_input.options_array
         | 
| 17 | 
            +
                  options += [''] unless template_input.required?
         | 
| 18 | 
            +
                  options
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 10 21 | 
             
            end
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            attribute :pubkey => :remote_execution_pubkey
         | 
| @@ -1,9 +1,3 @@ | |
| 1 | 
            -
            <script type="text/javascript">
         | 
| 2 | 
            -
              $(function () {
         | 
| 3 | 
            -
                template_change($('select.job_template_selector'));
         | 
| 4 | 
            -
              });
         | 
| 5 | 
            -
            </script>
         | 
| 6 | 
            -
             | 
| 7 1 | 
             
            <%= form_for @composer.job_invocation, :html => {'data-refresh-url' => refresh_job_invocations_path, :id => 'job_invocation_form'} do |f| %>
         | 
| 8 2 |  | 
| 9 3 | 
             
              <% unless @composer.rerun_possible? %>
         | 
| @@ -67,7 +61,7 @@ | |
| 67 61 | 
             
                                <%= job_template_fields.fields_for :input_values do |input_values_fields| %>
         | 
| 68 62 | 
             
                                  <% inputs = job_template.template_inputs_with_foreign.select { |input| input.input_type == 'user' } %>
         | 
| 69 63 | 
             
                                  <% inputs.select { |i| i.basic? }.each do |input| %>
         | 
| 70 | 
            -
                                    <%= render :partial => 'template_inputs/invocation_form', :locals => { :input_values_fields => input_values_fields, :composer => @composer, :job_template => job_template, :input => input } %>
         | 
| 64 | 
            +
                                    <%= render :partial => 'template_inputs/invocation_form', :locals => { :input_values_fields => input_values_fields, :composer => @composer, :job_template => job_template, :input => input, :onchange => "regenerate_description(this);" } %>
         | 
| 71 65 | 
             
                                  <% end %>
         | 
| 72 66 |  | 
| 73 67 | 
             
                                  <%= advanced_switch_f _('Display advanced fields'), _('Hide advanced fields') %>
         | 
| @@ -18,13 +18,6 @@ | |
| 18 18 | 
             
              <%= number_f f, :execution_timeout_interval, :disabled => @template.locked?, :label => _('Timeout to kill') %>
         | 
| 19 19 |  | 
| 20 20 | 
             
              <div class="children_fields">
         | 
| 21 | 
            -
                <%= new_child_fields_template(f, :template_inputs, { :partial => "template_inputs/form" }) %>
         | 
| 22 | 
            -
                <%= f.fields_for :template_inputs do |ff| %>
         | 
| 23 | 
            -
                  <div class="template_input_form fields">
         | 
| 24 | 
            -
                    <%= render 'template_inputs/form', :f => ff %>
         | 
| 25 | 
            -
                  </div>
         | 
| 26 | 
            -
                <% end %>
         | 
| 27 | 
            -
                <%= add_child_link '+ ' + _("Add Input"), :template_inputs, { :title => _('add a input for this template')} unless @template.locked? %>
         | 
| 28 21 | 
             
                <%= new_child_fields_template(f, :foreign_input_sets, { :partial => "template_inputs/foreign_input_set_form" }) %>
         | 
| 29 22 | 
             
                <%= f.fields_for :foreign_input_sets do |ff| %>
         | 
| 30 23 | 
             
                  <div class="template_input_form fields">
         | 
| @@ -1,7 +1,7 @@ | |
| 1 | 
            -
            <% output_line_set['output']. | 
| 1 | 
            +
            <% output_line_set['output'].gsub("\r\n", "\n").split("\n", -1).each do |line| %>
         | 
| 2 2 | 
             
              <%= content_tag :div, :class => 'line ' + output_line_set['output_type'], :data => { :timestamp => output_line_set['timestamp'] } do %>
         | 
| 3 3 |  | 
| 4 4 | 
             
                <%= content_tag(:span, (@line_counter += 1).to_s.rjust(4).gsub(' ', ' ').html_safe + ':', :class => 'counter', :title => (output_line_set['timestamp'] && Time.at(output_line_set['timestamp']))) %>
         | 
| 5 | 
            -
                <%= content_tag(:div, (line.empty? ?  | 
| 5 | 
            +
                <%= content_tag(:div, colorize_line(line.gsub(JobInvocationOutputHelper::COLOR_PATTERN, '').empty? ? "#{line}\n" : line).html_safe, :class => 'content') %>
         | 
| 6 6 | 
             
              <% end %>
         | 
| 7 7 | 
             
            <% end %>
         | 
| @@ -0,0 +1,67 @@ | |
| 1 | 
            +
            <%#
         | 
| 2 | 
            +
            kind: job_template
         | 
| 3 | 
            +
            name: Module Action - SSH Default
         | 
| 4 | 
            +
            model: JobTemplate
         | 
| 5 | 
            +
            job_category: Modules
         | 
| 6 | 
            +
            description_format: "Module %{action} %{module_spec}"
         | 
| 7 | 
            +
            provider_type: SSH
         | 
| 8 | 
            +
            template_inputs:
         | 
| 9 | 
            +
            - name: pre_script
         | 
| 10 | 
            +
              description: A script to run prior to the module action
         | 
| 11 | 
            +
              input_type: user
         | 
| 12 | 
            +
              required: false
         | 
| 13 | 
            +
              advanced: true
         | 
| 14 | 
            +
            - name: action
         | 
| 15 | 
            +
              description: 'The module action enable, install etc.'
         | 
| 16 | 
            +
              input_type: user
         | 
| 17 | 
            +
              required: true
         | 
| 18 | 
            +
              options: "\nlist\ninfo\nenable\ndisable\ninstall\nupdate\nremove\nprovides\nlock\nunlock\nprofile\nstreams"
         | 
| 19 | 
            +
            - name: module_spec
         | 
| 20 | 
            +
              description: The module specification. module:stream/profile
         | 
| 21 | 
            +
              input_type: user
         | 
| 22 | 
            +
              required: false
         | 
| 23 | 
            +
            - name: options
         | 
| 24 | 
            +
              description: Other optional flags for the action
         | 
| 25 | 
            +
              input_type: user
         | 
| 26 | 
            +
              required: false
         | 
| 27 | 
            +
            - name: post_script
         | 
| 28 | 
            +
              description: A script to run after the module action
         | 
| 29 | 
            +
              input_type: user
         | 
| 30 | 
            +
              required: false
         | 
| 31 | 
            +
              advanced: true
         | 
| 32 | 
            +
            %>
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            <%
         | 
| 35 | 
            +
              supported_families = ['Redhat']
         | 
| 36 | 
            +
              render_error(N_('Unsupported or no operating system found for this host.')) unless @host.operatingsystem && supported_families.include?(@host.operatingsystem.family)
         | 
| 37 | 
            +
            -%>
         | 
| 38 | 
            +
            #!/bin/bash
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            # Helper function that exits with a particular message and code.
         | 
| 41 | 
            +
            #
         | 
| 42 | 
            +
            # Usage:
         | 
| 43 | 
            +
            #   exit_with_message "Could not do a thing" 2
         | 
| 44 | 
            +
            #
         | 
| 45 | 
            +
            function exit_with_message {
         | 
| 46 | 
            +
              echo "${1}, exiting..."
         | 
| 47 | 
            +
              exit $2
         | 
| 48 | 
            +
            }
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            <% unless input("pre_script").blank? -%>
         | 
| 51 | 
            +
              # Pre Script
         | 
| 52 | 
            +
              <%= input("pre_script") %>
         | 
| 53 | 
            +
              RETVAL=$?
         | 
| 54 | 
            +
              [ $RETVAL -eq 0 ] || exit_with_message "Pre script failed" $RETVAL
         | 
| 55 | 
            +
            <% end -%>
         | 
| 56 | 
            +
             | 
| 57 | 
            +
            # Action
         | 
| 58 | 
            +
            dnf -y module <%= input("action") %> <%= input("module_spec") %> <%= input("options") %>
         | 
| 59 | 
            +
            RETVAL=$?
         | 
| 60 | 
            +
            [ $RETVAL -eq 0 ] || exit_with_message " module action failed" $RETVAL
         | 
| 61 | 
            +
             | 
| 62 | 
            +
            <% unless input("post_script").blank? -%>
         | 
| 63 | 
            +
              # Post Script
         | 
| 64 | 
            +
              <%= input("post_script") %>
         | 
| 65 | 
            +
              RETVAL=$?
         | 
| 66 | 
            +
              [ $RETVAL -eq 0 ] || exit_with_message "Post script failed" $RETVAL
         | 
| 67 | 
            +
            <% end -%>
         | 
| @@ -1,6 +1,7 @@ | |
| 1 1 | 
             
            <%#
         | 
| 2 2 | 
             
            kind: job_template
         | 
| 3 3 | 
             
            name: Package Action - SSH Default
         | 
| 4 | 
            +
            model: JobTemplate
         | 
| 4 5 | 
             
            job_category: Packages
         | 
| 5 6 | 
             
            description_format: "%{action} package(s) %{package}"
         | 
| 6 7 | 
             
            provider_type: SSH
         | 
| @@ -27,16 +28,26 @@ template_inputs: | |
| 27 28 | 
             
            %>
         | 
| 28 29 |  | 
| 29 30 | 
             
            <%
         | 
| 30 | 
            -
              supported_families = ['Redhat', 'Debian']
         | 
| 31 | 
            +
              supported_families = ['Redhat', 'Debian', 'Suse']
         | 
| 31 32 | 
             
              render_error(N_('Unsupported or no operating system found for this host.')) unless @host.operatingsystem && supported_families.include?(@host.operatingsystem.family)
         | 
| 32 | 
            -
             | 
| 33 | 
            +
              action = input("action")
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              if @host.operatingsystem.family == 'Redhat'
         | 
| 36 | 
            +
                package_manager = 'yum'
         | 
| 37 | 
            +
              elsif @host.operatingsystem.family == 'Debian'
         | 
| 38 | 
            +
                package_manager = 'apt'
         | 
| 39 | 
            +
              elsif @host.operatingsystem.family == 'Suse'
         | 
| 40 | 
            +
                package_manager = 'zypper'
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
            -%>
         | 
| 43 | 
            +
            #!/bin/bash
         | 
| 33 44 |  | 
| 34 45 | 
             
            # Helper function that exits with a particular message and code.
         | 
| 35 46 | 
             
            #
         | 
| 36 47 | 
             
            # Usage:
         | 
| 37 48 | 
             
            #   exit_with_message "Could not do a thing" 2
         | 
| 38 49 | 
             
            #
         | 
| 39 | 
            -
             | 
| 50 | 
            +
            exit_with_message () {
         | 
| 40 51 | 
             
              echo "${1}, exiting..."
         | 
| 41 52 | 
             
              exit $2
         | 
| 42 53 | 
             
            }
         | 
| @@ -49,10 +60,31 @@ function exit_with_message() { | |
| 49 60 | 
             
            <% end -%>
         | 
| 50 61 |  | 
| 51 62 | 
             
            # Action
         | 
| 52 | 
            -
            <% if  | 
| 53 | 
            -
              yum -y <%=  | 
| 54 | 
            -
            <% elsif  | 
| 55 | 
            -
               | 
| 63 | 
            +
            <% if package_manager == 'yum' -%>
         | 
| 64 | 
            +
              yum -y <%= action %> <%= input("package") %>
         | 
| 65 | 
            +
            <% elsif package_manager == 'apt' -%>
         | 
| 66 | 
            +
              <%-
         | 
| 67 | 
            +
                action = 'install' if action == 'group install'
         | 
| 68 | 
            +
                action = 'remove' if action == 'group remove'
         | 
| 69 | 
            +
                if action == 'group update' || action == 'update'
         | 
| 70 | 
            +
                  if input('package').blank?
         | 
| 71 | 
            +
                    action = 'upgrade'
         | 
| 72 | 
            +
                  else
         | 
| 73 | 
            +
                    action = '--only-upgrade install'
         | 
| 74 | 
            +
                  end
         | 
| 75 | 
            +
                end
         | 
| 76 | 
            +
              -%>
         | 
| 77 | 
            +
              apt-get -y update
         | 
| 78 | 
            +
              apt-get -y <%= action %> <%= input("package") %>
         | 
| 79 | 
            +
            <% elsif package_manager == 'zypper' -%>
         | 
| 80 | 
            +
              <%-
         | 
| 81 | 
            +
                if action == "group install"
         | 
| 82 | 
            +
                  action = "install -t pattern"
         | 
| 83 | 
            +
                elsif action == "group remove"
         | 
| 84 | 
            +
                  action = "remove -t pattern"
         | 
| 85 | 
            +
                end
         | 
| 86 | 
            +
              -%>
         | 
| 87 | 
            +
              zypper -n <%= action %> <%= input("package") %>
         | 
| 56 88 | 
             
            <% end -%>
         | 
| 57 89 | 
             
            RETVAL=$?
         | 
| 58 90 | 
             
            [ $RETVAL -eq 0 ] || exit_with_message "Package action failed" $RETVAL
         | 
| @@ -1,6 +1,7 @@ | |
| 1 1 | 
             
            <%#
         | 
| 2 2 | 
             
            kind: job_template
         | 
| 3 3 | 
             
            name: Power Action - SSH Default
         | 
| 4 | 
            +
            model: JobTemplate
         | 
| 4 5 | 
             
            job_category: Power
         | 
| 5 6 | 
             
            description_format: '%{action} host'
         | 
| 6 7 | 
             
            provider_type: SSH
         | 
| @@ -15,7 +16,7 @@ template_inputs: | |
| 15 16 | 
             
            echo <%= input('action') %> host && sleep 3
         | 
| 16 17 | 
             
            <%= case input('action')
         | 
| 17 18 | 
             
                  when 'restart'
         | 
| 18 | 
            -
                    ' | 
| 19 | 
            +
                    'shutdown -r +1'
         | 
| 19 20 | 
             
                  else
         | 
| 20 21 | 
             
                    'shutdown -h now'
         | 
| 21 22 | 
             
                  end %>
         | 
| @@ -1,6 +1,7 @@ | |
| 1 1 | 
             
            <%#
         | 
| 2 2 | 
             
            kind: job_template
         | 
| 3 3 | 
             
            name: Service Action - SSH Default
         | 
| 4 | 
            +
            model: JobTemplate
         | 
| 4 5 | 
             
            job_category: Services
         | 
| 5 6 | 
             
            description_format: '%{action} service %{service}'
         | 
| 6 7 | 
             
            provider_type: SSH
         | 
| @@ -8,7 +9,7 @@ template_inputs: | |
| 8 9 | 
             
            - name: action
         | 
| 9 10 | 
             
              description: Action to perform on the service
         | 
| 10 11 | 
             
              input_type: user
         | 
| 11 | 
            -
              options: "restart\nstart\nstop\nstatus"
         | 
| 12 | 
            +
              options: "restart\nstart\nstop\nstatus\nreload\nenable\ndisable"
         | 
| 12 13 | 
             
              required: true
         | 
| 13 14 | 
             
            - name: service
         | 
| 14 15 | 
             
              description: Name of the service
         | 
| @@ -18,5 +19,12 @@ template_inputs: | |
| 18 19 | 
             
            <% if @host.operatingsystem.family == "Redhat" && @host.operatingsystem.major.to_i > 6 %>
         | 
| 19 20 | 
             
            systemctl <%= input("action") %> <%= input("service") %>
         | 
| 20 21 | 
             
            <% else %>
         | 
| 22 | 
            +
              <% case input("action")
         | 
| 23 | 
            +
              when 'enable' %>
         | 
| 24 | 
            +
            chkconfig --add <%= input("service") %>
         | 
| 25 | 
            +
              <% when 'disable' %>
         | 
| 26 | 
            +
            chkconfig --del <%= input("service") %>
         | 
| 27 | 
            +
              <% else %>
         | 
| 21 28 | 
             
            service <%= input("service") %> <%= input("action") %>
         | 
| 29 | 
            +
              <% end %>
         | 
| 22 30 | 
             
            <% end -%>
         | 
    
        data/config/routes.rb
    CHANGED
    
    | @@ -75,7 +75,6 @@ Rails.application.routes.draw do | |
| 75 75 | 
             
                  end
         | 
| 76 76 |  | 
| 77 77 | 
             
                  resources :templates, :only => :none do
         | 
| 78 | 
            -
                    resources :template_inputs, :only => [:index, :show, :create, :destroy, :update]
         | 
| 79 78 | 
             
                    resources :foreign_input_sets, :only => [:index, :show, :create, :destroy, :update]
         | 
| 80 79 | 
             
                  end
         | 
| 81 80 |  | 
| @@ -119,6 +119,8 @@ module ForemanRemoteExecution | |
| 119 119 | 
             
                    parameter_filter Nic::Interface do |ctx|
         | 
| 120 120 | 
             
                      ctx.permit :execution
         | 
| 121 121 | 
             
                    end
         | 
| 122 | 
            +
             | 
| 123 | 
            +
                    extend_rabl_template 'api/v2/smart_proxies/main', 'api/v2/smart_proxies/pubkey'
         | 
| 122 124 | 
             
                  end
         | 
| 123 125 | 
             
                end
         | 
| 124 126 |  | 
| @@ -150,6 +152,7 @@ module ForemanRemoteExecution | |
| 150 152 | 
             
                  #   ProvisioningTemplate.reflect_on_association :template_inputs # => nil
         | 
| 151 153 | 
             
                  require_dependency 'job_template'
         | 
| 152 154 | 
             
                  (Template.descendants + [Template]).each { |klass| klass.send(:include, ForemanRemoteExecution::TemplateExtensions) }
         | 
| 155 | 
            +
                  Template.send(:prepend, ForemanRemoteExecution::TemplateOverrides)
         | 
| 153 156 |  | 
| 154 157 | 
             
                  (Taxonomy.descendants + [Taxonomy]).each { |klass| klass.send(:include, ForemanRemoteExecution::TaxonomyExtensions) }
         | 
| 155 158 |  | 
| @@ -165,6 +168,7 @@ module ForemanRemoteExecution | |
| 165 168 | 
             
                  Bookmark.send(:include, ForemanRemoteExecution::BookmarkExtensions)
         | 
| 166 169 | 
             
                  HostsHelper.send(:prepend, ForemanRemoteExecution::HostsHelperExtensions)
         | 
| 167 170 | 
             
                  ProvisioningTemplatesHelper.send(:prepend, ForemanRemoteExecution::JobTemplatesExtensions)
         | 
| 171 | 
            +
                  TemplateInput.send(:include, ForemanRemoteExecution::TemplateInputExtensions)
         | 
| 168 172 |  | 
| 169 173 | 
             
                  SmartProxy.send(:prepend, ForemanRemoteExecution::SmartProxyExtensions)
         | 
| 170 174 | 
             
                  Subnet.send(:include, ForemanRemoteExecution::SubnetExtensions)
         | 
| Binary file | 
| @@ -41,9 +41,6 @@ msgstr "Kommagetrennte Liste von Eingabenamen, die in die Fremdvorlage einzubezi | |
| 41 41 | 
             
            msgid "A job '%{subject}' has finished successfully"
         | 
| 42 42 | 
             
            msgstr ""
         | 
| 43 43 |  | 
| 44 | 
            -
            msgid "A list of options the user can select from. If not provided, the user will be given a free-form field"
         | 
| 45 | 
            -
            msgstr "Eine Liste von Optionen, aus der der Benutzer auswählen kann. Wenn keine Liste bereitgestellt ist, wird dem Benutzer ein Freitext-Feld zur Verfügung gestellt"
         | 
| 46 | 
            -
             | 
| 47 44 | 
             
            msgid "A plugin bringing remote execution to the Foreman, completing the config management functionality with remote management functionality."
         | 
| 48 45 | 
             
            msgstr "Ein Plugin, das Foreman entfernte Ausführung bietet und die Konfig-Verwaltungsfunktion mit einer entfernten Verwaltungsfunktion ergänzt."
         | 
| 49 46 |  | 
| @@ -62,9 +59,6 @@ msgstr "Aktionen" | |
| 62 59 | 
             
            msgid "Add Foreign Input Set"
         | 
| 63 60 | 
             
            msgstr "Fremdeingabe-Satz hinzufügen"
         | 
| 64 61 |  | 
| 65 | 
            -
            msgid "Add Input"
         | 
| 66 | 
            -
            msgstr "Eingabe hinzufügen"
         | 
| 67 | 
            -
             | 
| 68 62 | 
             
            msgid "Amount of workers in the pool to handle the execution of the remote execution jobs. Restart of the dynflowd/foreman-tasks service is required."
         | 
| 69 63 | 
             
            msgstr ""
         | 
| 70 64 |  | 
| @@ -128,6 +122,9 @@ msgstr "" | |
| 128 122 | 
             
            msgid "Could not render the preview because no host matches the search query."
         | 
| 129 123 | 
             
            msgstr ""
         | 
| 130 124 |  | 
| 125 | 
            +
            msgid "Could not rerun job %{id} because its template could not be found"
         | 
| 126 | 
            +
            msgstr ""
         | 
| 127 | 
            +
             | 
| 131 128 | 
             
            msgid "Could not use any proxy. Consider configuring %{global_proxy}, %{fallback_proxy} or %{no_proxy} in settings"
         | 
| 132 129 | 
             
            msgstr ""
         | 
| 133 130 |  | 
| @@ -146,9 +143,6 @@ msgstr "Job-Vorlage erstellen" | |
| 146 143 | 
             
            msgid "Create a recurring job"
         | 
| 147 144 | 
             
            msgstr "Wiederholten Job erstellen"
         | 
| 148 145 |  | 
| 149 | 
            -
            msgid "Create a template input"
         | 
| 150 | 
            -
            msgstr "Vorlageneingabe erstellen"
         | 
| 151 | 
            -
             | 
| 152 146 | 
             
            msgid "Default SSH key passphrase"
         | 
| 153 147 | 
             
            msgstr ""
         | 
| 154 148 |  | 
| @@ -173,9 +167,6 @@ msgstr "Fremdeingabe-Satz löschen" | |
| 173 167 | 
             
            msgid "Delete a job template"
         | 
| 174 168 | 
             
            msgstr "Job-Vorlage löschen"
         | 
| 175 169 |  | 
| 176 | 
            -
            msgid "Delete a template input"
         | 
| 177 | 
            -
            msgstr "Vorlageneingabe löschen"
         | 
| 178 | 
            -
             | 
| 179 170 | 
             
            msgid "Description"
         | 
| 180 171 | 
             
            msgstr "Beschreibung"
         | 
| 181 172 |  | 
| @@ -239,12 +230,6 @@ msgstr "Exit-Status: %s" | |
| 239 230 | 
             
            msgid "Export a job template to ERB"
         | 
| 240 231 | 
             
            msgstr "Job-Vorlage nach ERB exportieren"
         | 
| 241 232 |  | 
| 242 | 
            -
            msgid "Fact name, used when input type is fact"
         | 
| 243 | 
            -
            msgstr "Faktenname wird benutzt, wenn Eingabetyp Fakt ist"
         | 
| 244 | 
            -
             | 
| 245 | 
            -
            msgid "Fact value"
         | 
| 246 | 
            -
            msgstr "Faktenwert"
         | 
| 247 | 
            -
             | 
| 248 233 | 
             
            msgid "Failed"
         | 
| 249 234 | 
             
            msgstr "Fehlgeschlagen"
         | 
| 250 235 |  | 
| @@ -311,24 +296,9 @@ msgstr "Gibt an, dass die Aktion abgebrochen werden soll, wenn sie nicht vor die | |
| 311 296 | 
             
            msgid "Input"
         | 
| 312 297 | 
             
            msgstr "Eingabe"
         | 
| 313 298 |  | 
| 314 | 
            -
            msgid "Input description"
         | 
| 315 | 
            -
            msgstr "Eingabebeschreibung"
         | 
| 316 | 
            -
             | 
| 317 | 
            -
            msgid "Input is advanced"
         | 
| 318 | 
            -
            msgstr "Eingabe ist erweitert"
         | 
| 319 | 
            -
             | 
| 320 | 
            -
            msgid "Input is required"
         | 
| 321 | 
            -
            msgstr "Eingabe ist erforderlich"
         | 
| 322 | 
            -
             | 
| 323 | 
            -
            msgid "Input name"
         | 
| 324 | 
            -
            msgstr "Eingabename"
         | 
| 325 | 
            -
             | 
| 326 299 | 
             
            msgid "Input set description"
         | 
| 327 300 | 
             
            msgstr "Beschreibung des Eingabe-Satzes"
         | 
| 328 301 |  | 
| 329 | 
            -
            msgid "Input type"
         | 
| 330 | 
            -
            msgstr "Eingabetyp"
         | 
| 331 | 
            -
             | 
| 332 302 | 
             
            msgid "Inputs to use"
         | 
| 333 303 | 
             
            msgstr "Zu verwendende Eingaben"
         | 
| 334 304 |  | 
| @@ -428,9 +398,6 @@ msgstr "Job-Vorlagen pro Organisation auflisten" | |
| 428 398 | 
             
            msgid "List remote execution features"
         | 
| 429 399 | 
             
            msgstr "Entfernte Ausführungsfunktionen auflisten"
         | 
| 430 400 |  | 
| 431 | 
            -
            msgid "List template inputs"
         | 
| 432 | 
            -
            msgstr "Vorlageneingabe auflisten"
         | 
| 433 | 
            -
             | 
| 434 401 | 
             
            msgid "List template invocations belonging to job invocation"
         | 
| 435 402 | 
             
            msgstr ""
         | 
| 436 403 |  | 
| @@ -514,15 +481,6 @@ msgstr "Anbieter und Vorlagen" | |
| 514 481 | 
             
            msgid "Proxies"
         | 
| 515 482 | 
             
            msgstr "Proxys"
         | 
| 516 483 |  | 
| 517 | 
            -
            msgid "Puppet class name, used when input type is puppet_parameter"
         | 
| 518 | 
            -
            msgstr "Name der Puppet-Klasse wird benutzt, wenn Eingabetyp Puppet-Parameter ist"
         | 
| 519 | 
            -
             | 
| 520 | 
            -
            msgid "Puppet parameter"
         | 
| 521 | 
            -
            msgstr "Puppet-Parameter"
         | 
| 522 | 
            -
             | 
| 523 | 
            -
            msgid "Puppet parameter name, used when input type is puppet_parameter"
         | 
| 524 | 
            -
            msgstr "Puppet-Parameter-Name wird benutzt, wenn Eingabetyp Puppet-Parameter ist"
         | 
| 525 | 
            -
             | 
| 526 484 | 
             
            msgid "Recurring logic"
         | 
| 527 485 | 
             
            msgstr "Wiederholungslogik"
         | 
| 528 486 |  | 
| @@ -640,9 +598,6 @@ msgstr "ERB-Datei zum Hochladen auswählen, um Job-Vorlage zu importieren. Die V | |
| 640 598 | 
             
            msgid "Select as many remote execution proxies as applicable for this subnet.  When multiple proxies with the same provider are added, actions will be load balanced among them."
         | 
| 641 599 | 
             
            msgstr "Wählen Sie so viele Proxys für entfernte Ausführung aus, wie es für dieses Subnetz zutreffend ist. Wenn mehrere Proxys mit demselben Provider hinzugefügt werden, dann wird die Auslastung unter diesen ausgeglichen."
         | 
| 642 600 |  | 
| 643 | 
            -
            msgid "Selectable values for user inputs"
         | 
| 644 | 
            -
            msgstr "Auswählbare Werte für Benutzereingaben"
         | 
| 645 | 
            -
             | 
| 646 601 | 
             
            msgid "Set to distribute over"
         | 
| 647 602 | 
             
            msgstr ""
         | 
| 648 603 |  | 
| @@ -661,9 +616,6 @@ msgstr "Details der Job-Vorlage anzeigen" | |
| 661 616 | 
             
            msgid "Show remote execution feature"
         | 
| 662 617 | 
             
            msgstr "Entfernte Ausführungsfunktionen anzeigen"
         | 
| 663 618 |  | 
| 664 | 
            -
            msgid "Show template input details"
         | 
| 665 | 
            -
            msgstr "Details der Vorlageneingabe anzeigen"
         | 
| 666 | 
            -
             | 
| 667 619 | 
             
            msgid "Snippet"
         | 
| 668 620 | 
             
            msgstr "Snippet"
         | 
| 669 621 |  | 
| @@ -712,9 +664,6 @@ msgstr "Vorlage ERB" | |
| 712 664 | 
             
            msgid "Template Invocation for %s"
         | 
| 713 665 | 
             
            msgstr ""
         | 
| 714 666 |  | 
| 715 | 
            -
            msgid "Template input"
         | 
| 716 | 
            -
            msgstr "Vorlageneingabe"
         | 
| 717 | 
            -
             | 
| 718 667 | 
             
            msgid "Template name"
         | 
| 719 668 | 
             
            msgstr "Vorlagenname"
         | 
| 720 669 |  | 
| @@ -849,9 +798,6 @@ msgstr "Fremdeingabe-Satz aktualisieren" | |
| 849 798 | 
             
            msgid "Update a job template"
         | 
| 850 799 | 
             
            msgstr "Job-Vorlage aktualisieren"
         | 
| 851 800 |  | 
| 852 | 
            -
            msgid "Update a template input"
         | 
| 853 | 
            -
            msgstr "Vorlageneingabe aktualisieren"
         | 
| 854 | 
            -
             | 
| 855 801 | 
             
            msgid "Use default description template"
         | 
| 856 802 | 
             
            msgstr "Standardbeschreibungsvorlage verwenden"
         | 
| 857 803 |  | 
| @@ -873,15 +819,6 @@ msgstr "Benutzereingabe" | |
| 873 819 | 
             
            msgid "Value"
         | 
| 874 820 | 
             
            msgstr "Wert"
         | 
| 875 821 |  | 
| 876 | 
            -
            msgid "Value for required input '%s' was not specified"
         | 
| 877 | 
            -
            msgstr "Wert für erforderliche Eingabe '%s' wurde nicht angegeben"
         | 
| 878 | 
            -
             | 
| 879 | 
            -
            msgid "Variable"
         | 
| 880 | 
            -
            msgstr "Variable"
         | 
| 881 | 
            -
             | 
| 882 | 
            -
            msgid "Variable name, used when input type is variable"
         | 
| 883 | 
            -
            msgstr "Variablenname wird benutzt, wenn Eingabetyp Variable ist"
         | 
| 884 | 
            -
             | 
| 885 822 | 
             
            msgid "What command should be used to switch to the effective user. One of %s"
         | 
| 886 823 | 
             
            msgstr "Welcher Befehl für den Wechsel zum effektiven Benutzer verwendet werden soll. Einer von %s"
         | 
| 887 824 |  | 
| @@ -920,9 +857,6 @@ msgstr "" | |
| 920 857 | 
             
            msgid "You are not allowed to see the currently assigned template. Saving the form now would unassign the template."
         | 
| 921 858 | 
             
            msgstr "Sie haben nicht die Genehmigung, die aktuell zugewiesenen Vorlagen einzusehen. Wenn Sie das Formular jetzt speichern, wird die Zuweisung der Vorlage aufgehoben."
         | 
| 922 859 |  | 
| 923 | 
            -
            msgid "add a input for this template"
         | 
| 924 | 
            -
            msgstr "Eingabe für diese Vorlage hinzufügen"
         | 
| 925 | 
            -
             | 
| 926 860 | 
             
            msgid "add an input set for this template to reference a different template inputs"
         | 
| 927 861 | 
             
            msgstr "Eingabe-Satz für diese Vorlage hinzufügen, um auf andere Vorlage-Eingaben zu verweisen"
         | 
| 928 862 |  | 
| @@ -965,9 +899,6 @@ msgstr "in der Warteschlange" | |
| 965 899 | 
             
            msgid "queued to start executing in %{time}"
         | 
| 966 900 | 
             
            msgstr ""
         | 
| 967 901 |  | 
| 968 | 
            -
            msgid "remove template input"
         | 
| 969 | 
            -
            msgstr "Vorlageneingabe entfernen"
         | 
| 970 | 
            -
             | 
| 971 902 | 
             
            msgid "remove template input set"
         | 
| 972 903 | 
             
            msgstr "Vorlageneingabe-Satz entfernen"
         | 
| 973 904 |  |