Class: Itamae::Plugin::Resource::SelinuxContext
- Inherits:
-
Resource::Base
- Object
- Resource::Base
- Itamae::Plugin::Resource::SelinuxContext
show all
- Includes:
- SelinuxContextVersion
- Defined in:
- lib/itamae/plugin/resource/selinux_context.rb
Constant Summary
Itamae::Plugin::Resource::SelinuxContextVersion::VERSION
Instance Method Summary
collapse
Instance Method Details
#action_run(options) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/itamae/plugin/resource/selinux_context.rb', line 32
def action_run(options)
unless current.exist
run_command("sudo chcon #{attributes.context} #{attributes.file}")
updated!
end
end
|
#set_current_attributes ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/itamae/plugin/resource/selinux_context.rb', line 15
def set_current_attributes
super
command_result = run_command("ls -Z #{attributes.file} | grep '#{attributes.context}'", error: false)
if attributes.debug
Itamae.logger.info "command: ls -Z #{attributes.file} | grep '#{attributes.context}"
Itamae.logger.info "exit code: #{command_result.exit_status}"
Itamae.logger.info "stdout: #{command_result.stdout}"
Itamae.logger.info "stderr: #{command_result.stderr}"
end
current.exist = command_result.exit_status == 0
if current.exist
Itamae.logger.info "Already set context of #{attributes.file}" if attributes.debug
else
Itamae.logger.info "Set context to #{attributes.file}"
end
end
|