Class: InstanceAgent::Plugins::CodeDeployPlugin::ChangeContextCommand
- Inherits:
-
Object
- Object
- InstanceAgent::Plugins::CodeDeployPlugin::ChangeContextCommand
- Defined in:
- lib/instance_agent/plugins/codedeploy/install_instruction.rb
Instance Method Summary collapse
- #execute(cleanup_file) ⇒ Object
-
#initialize(object, context) ⇒ ChangeContextCommand
constructor
A new instance of ChangeContextCommand.
- #to_h ⇒ Object
Constructor Details
#initialize(object, context) ⇒ ChangeContextCommand
Returns a new instance of ChangeContextCommand.
348 349 350 351 |
# File 'lib/instance_agent/plugins/codedeploy/install_instruction.rb', line 348 def initialize(object, context) @object = object @context = context end |
Instance Method Details
#execute(cleanup_file) ⇒ Object
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/instance_agent/plugins/codedeploy/install_instruction.rb', line 353 def execute(cleanup_file) if !@context.role.nil? raise "Attempt to set role on object, not supported" end args = "-t #{@context.type}" if (!@context.user.nil?) args = "-s #{@context.user} " + args end if (!@context.range.nil?) args = args + " -r #{@context.range.get_range}" end object = File.realpath(@object) if !system("semanage fcontext -a #{args} #{object}") raise "Unable to set context: semanage fcontext -a #{args} #{object}, exit code: #{$?}" end if !system("restorecon -v #{object}") raise "Unable to apply context: restorcecon -v #{object}, exit code: #{$?}" end cleanup_file.puts("semanage\0#{object}") end |
#to_h ⇒ Object
375 376 377 |
# File 'lib/instance_agent/plugins/codedeploy/install_instruction.rb', line 375 def to_h {:type => :semanage, :context => {:user => @context.user, :role => @context.role, :type => @context.type, :range => @context.range.get_range}, :file => @object} end |