Ask Your Question
0

awk error in puppet

asked 2015-02-27 11:33:32 -0500

Chutki gravatar image

Hi,

I am executing below manifests

define semmns_val($value) {

  exec { 'semmns':
    cwd     => '/etc',
    path    => '/etc',
    command => "awk '/kernel.sem/ { if(($3 + 0) < $value) sub($3, $value) } 1' /etc/sysctl.conf >> /etc/sysctl.conf.mod",
    }


    }

I got below error

Error: Could not find command 'awk'
Error: /Stage[main]/Infappsysctl::Kersem/Infappsysctl::Kersem::Semmns_val[kernel_semmns]/Exec[semmns]/returns: change from notrun to 0 failed: Could not find command 'awk'

should I use nawk or something similar like that.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-02-27 11:57:24 -0500

doc75 gravatar image

You need to specify the full path to awk (on my system: /usr/bin/awk) in the command:

exec { 'semmns':
    cwd     => '/etc',
    path    => '/etc',
    command => "/usr/bin/awk '/kernel.sem/ { if(($3 + 0) < $value) sub($3, $value) } 1' /etc/sysctl.conf >> /etc/sysctl.conf.mod",
    }

Another option is to add the directory containing awk in the path:

exec { 'semmns':
    cwd     => '/etc',
    path    => ['/etc', '/usr/bin'],
    command => "awk '/kernel.sem/ { if(($3 + 0) < $value) sub($3, $value) } 1' /etc/sysctl.conf >> /etc/sysctl.conf.mod",
    }

Otherwise check on the side of augeas, but it can be tricky sometime (but very powerful).

Hope this helps.

edit flag offensive delete link more

Comments

Thanks it worked

Chutki gravatar imageChutki ( 2015-02-28 11:32:52 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-02-27 11:33:32 -0500

Seen: 356 times

Last updated: Feb 27 '15