0

I am trying to make some changes on my Ubuntu 16.04 server using puppet exec to run commands to make those changes. When I run puppet, the command is executed successfully but puppet exec doesn't make the necessary changes. Below is what I have:

exec { 'snap_max_soft_limit':
  path    => '/usr/bin:/usr/sbin:/bin',
  command => 'gluster snapshot config snap-max-soft-limit 50',
}

It doesn't throw any errors so I am not sure what I am doing wrong and how to fix it so the exec makes the changes I want. I am running puppet v4

5
  • All strings that do not contain variables or escape characters like \n or \t should be enclosed in single quotes. style guide. Probably not a solution but it is good practice. Feb 2, 2018 at 15:42
  • @ Hunter.S.Thompson, thanks for your feedback. I have changed it to single quotes but unfortunately, that didn't fix it. Feb 2, 2018 at 16:03
  • what's the difference between "the command is executed successfully" (did the snapshot run?) and puppet not making the changes?
    – thrig
    Feb 2, 2018 at 16:28
  • @thrig, the command 'gluster snapshot config snap-max-soft-limit 50' doesn't run the snapshot, it only sets the number snapshot allowed limit. The command is executed when puppet is run but doesn't change the snap max soft limit from 90 to 50 even though the command is executed successfully per puppet. When I run that command directly on the command line on the server, that works and makes the changes. Feb 2, 2018 at 18:33
  • Assuming when the command is run, you have to confirm before the command makes the needed changes. Is there a way to handle that with puppet? So say, after running 'gluster snapshot config snap-max-soft-limit 50', its prompts you, with 'Are you sure you want to proceed?' and you have to answer Y before the changes are made Feb 2, 2018 at 18:37

1 Answer 1

2

To make it work, this is how the syntax is supposed to be(figured it out):

exec { 'snap_max_soft_limit':
  path    => '/usr/bin:/usr/sbin:/bin',
  command => 'yes | gluster snapshot config snap-max-soft-limit 50',
}

When the command is run it accepts the y command to confirm before proceeding to make the changes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .