Execute resource on chef 13 client


#1

Hi I try to use execute resource on chef 13 to change ownership on file on RHEL machine

  • execute[change_ownership_contact_load.service] action run

    ================================================================================
    Error executing action run on resource 'execute[change_ownership_contact_load.service]'

    Mixlib::ShellOut::ShellCommandFailed

    Expected process to exit with [0], but received ''
    ---- Begin output of sudo chown ec2-user /etc/systemd/system/contact_load.service ----
    STDOUT:
    STDERR:
    ---- End output of sudo chown ec2-user /etc/systemd/system/contact_load.service ----
    Ran sudo chown ec2-user /etc/systemd/system/contact_load.service returned

    Resource Declaration:

    In /opt/chef/cache/cookbooks/snaplogic_decommission/recipes/contact_load.rb

    86: execute 'change_ownership_contact_load.service' do
    87: command "sudo chown ec2-user /etc/systemd/system/contact_load.service"
    88: end
    89:

    Compiled Resource:

    Declared in /opt/chef/cache/cookbooks/snaplogic_decommission/recipes/contact_load.rb:86:in `from_file'

    execute("change_ownership_contact_load.service") do
    action [:run]
    default_guard_interpreter :execute
    command "sudo chown ec2-user /etc/systemd/system/contact_load.service"
    backup 5
    returns 0
    user nil
    declared_type :execute
    cookbook_name "snaplogic_decommission"
    recipe_name "contact_load"
    domain nil
    end

    System Info:

    chef_version=13.0.118
    platform=redhat
    platform_version=7.6
    ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
    program_name=chef-client worker: ppid=6756;start=15:07:35;
    executable=/opt/chef/bin/chef-client

please help me out on this issue