Need help on how to incorporate the below code in exec

asked 2016-02-15 21:26:23 -0600

updated 2016-02-17 09:37:08 -0600

Below is the code that I am trying to use.

MEM=`dmidecode -t 17 | grep "Size.*MB" | awk '{s+=$2} END {print s}'`
POOL_SIZE=`echo "$MEM * 0.6" | bc | awk '{printf("%d\n",$1 + 0.5)}'`
perl -p -i -e "s/Memory_Size/${POOL_SIZE}M/" /mariadb/bin/etc/my.cnf

I tried the below exec but it fails

 exec {  "MEM=`dmidecode -t 17 | grep \"Size.*MB\" | awk '{s+=$2} END {print s}'`;POOL_SIZE=`echo \"\$MEM * 0.6" | bc | awk '{printf(\"%d\n\",$1 + 0.5)}'`;perl -p -i -e \"s/2048/\$POOL_SIZE/\" my.cnf":
      path   => "/usr/bin:/usr/sbin:/bin:/sbin", cwd  => '/mariadb/bin/etc',
      onlyif => "test `grep 2048 my.cnf | wc -l` -ge 1" }
edit retag flag offensive close merge delete

Comments

please paste the error message.

Chutki gravatar imageChutki ( 2016-02-16 00:16:33 -0600 )edit
1

I think in this case you can try to use facts, for example "puppet facts | grep memory" and templates to fill up your file

c4f4t0r gravatar imagec4f4t0r ( 2016-02-18 03:46:38 -0600 )edit