Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby function in control repo works in Puppet but not found in onceover #315

Open
damonmaria opened this issue Sep 28, 2021 · 4 comments
Open

Comments

@damonmaria
Copy link

I have a function lib/puppet/functions/fix_image_tag.rb in my control repo. It works fine in Puppet / production but onceover fails with:

  errors:
    Evaluation Error: Unknown function: 'fix_image_tag'.

Is this expected to work? Or do I need to move it into a module brought in through Puppetfile?

@dylanratcliffe
Copy link
Collaborator

That's not expected to work. Puppet only looks for functions (and other ruby stuff) in the lib directory of a module, not at the root of the controlrepo. So you could put it in a module and then have that pulled in though the Puppetfile, or you could could just create a module straight in the controlrepo under the site-modules like in this example module which is located inside a controlrepo: https://github.com/puppetlabs/control-repo/tree/production/site-modules/adhoc

@dylanratcliffe
Copy link
Collaborator

Note that the reason site-modules works as a location for modules, is because we told it to look there in the environment.conf e.g. https://github.com/puppetlabs/control-repo/blob/production/environment.conf#L1

@damonmaria
Copy link
Author

I can confirm it does work when used in Puppet at that location.

I got the idea from this Puppet documentation which says an upcase function can be placed at /etc/puppetlabs/code/environments/production/lib/puppet/functions/upcase.rb. I have been assuming a control repo maps to an environment. I admit I'm no expert here :)

@dylanratcliffe
Copy link
Collaborator

Huh you're right, I had no idea that was possible and I've never seen it used but it does say:

either a module or an environment

Which would mean root of the controlrepo should be fine... So workaround is definitely to put it in a module but I'll re-open this as it does sound like a onceover thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants