0

I am trying to use Hammer in Foreman 1.20.1 on Centos 7.6 to refresh proxy features (or just about any other command other than --version) in a Puppet exec. The command I am using works fine at the shell. It fails in Puppet exec with:

Error: undefined local variable or method `dotfile' for Notice: /Stage[main]/Profiles::Test/Exec[test]/returns: Did you mean? @@dotfile Notice: /Stage[main]/Profiles::Test/Exec[test]/returns: Error: No such sub-command 'proxy'.

The code I am using is:

class profiles::test{
  exec {'test':
    command => '/usr/bin/hammer proxy refresh-features --name $(hostname)',
  }
}
include profiles::test

I'm not concerned about idempotency as it will have a refreshonly, I just want to get the command to work.

I have tried adding other options such as path, user, environment etc to no avail. Any help appreciated.

piet.t
  • 11,718
  • 21
  • 43
  • 52
xit
  • 135
  • 1
  • 12

1 Answers1

2

from clues I found at https://github.com/awesome-print/awesome_print/issues/316 and https://grokbase.com/t/gg/puppet-users/141mrjg2bw/problems-with-onlyif-in-exec, it turns out that the HOME environment has to be set. So the working code is:

  exec {'test':
    command     => '/usr/bin/hammer proxy refresh-features --name $(hostname)',
    environment => ["HOME=/root"],
    refreshonly => true,
  }

f'ing ruby!

xit
  • 135
  • 1
  • 12
  • 1
    You may also need to set a path in order for the Linux hostname command to be found? – Alex Harvey Feb 06 '19 at 10:13
  • it seems to work without it however if I have a problem I will certainly add a path. I have put a path ahead of hammer at this stage. – xit Feb 07 '19 at 09:02