Environment name transformation before it hits puppet

41 views
Skip to first unread message

Maksym Melnychok

unread,
May 4, 2015, 10:23:50 AM5/4/15
to puppe...@googlegroups.com
Hello,

I'm looking for a place in puppet code where i can modify environment name
after it's been read from command line args or puppet.conf but before it hits
any puppet's internal machinery.

Use case: our directory environments are coming from git branches named
in a certain pattern, and that pattern includes '/' which for obvious reason
won't work properly. So current solution is to use puppet with a wrapper script
that reads environment arg and replaces '/' with '__'. Since we're running a
fork anyway I'd like to hide this logic into puppet codebase but struggling to
find a good spot for it.

Any suggestions?

- maksym

James Turnbull

unread,
May 4, 2015, 10:43:25 AM5/4/15
to puppe...@googlegroups.com
Maksym Melnychok wrote:
> Hello,
>
> I'm looking for a place in puppet code where i can modify environment name
> after it's been read from command line args or puppet.conf but before it
> hits
> any puppet's internal machinery.

Perhaps r10k might help?

https://github.com/puppetlabs/r10k/blob/master/doc/dynamic-environments.mkd

Regards

James Turnbull

--
* The Art of Monitoring (http://artofmonitoring.com)
* The Docker Book (http://dockerbook.com)
* The LogStash Book (http://logstashbook.com)
* Pro Puppet (http://tinyurl.com/ppuppet2 )
* Pro Linux System Administration (http://tinyurl.com/linuxadmin)
* Hardening Linux (http://tinyurl.com/hardeninglinux)

Maksym Melnychok

unread,
May 4, 2015, 11:58:10 AM5/4/15
to puppe...@googlegroups.com
from what i can gather r10k suffers from the same problem:

https://github.com/puppetlabs/r10k/blob/master/doc/dynamic-environments/git-environments.mkd#invalid_branches

what i need is to be able to tell puppet (either in command line or config) that
environment value is "some/git/branch" while puppet will see it internally
as "some__git__branch"

regards,
maksym

James Turnbull

unread,
May 4, 2015, 12:43:46 PM5/4/15
to puppe...@googlegroups.com
Maksym Melnychok wrote:
> from what i can gather r10k suffers from the same problem:
>
> https://github.com/puppetlabs/r10k/blob/master/doc/dynamic-environments/git-environments.mkd#invalid_branches
>
> what i need is to be able to tell puppet (either in command line or
> config) that
> environment value is "some/git/branch" while puppet will see it internally
> as "some__git__branch"
>

My reading of those docs is that r10k will rename the branch internally.

Erik Dalén

unread,
May 6, 2015, 4:43:57 AM5/6/15
to puppe...@googlegroups.com
On Mon, 4 May 2015 at 18:43 James Turnbull <ja...@lovedthanlost.net> wrote:
Maksym Melnychok wrote:
> from what i can gather r10k suffers from the same problem:
>
> https://github.com/puppetlabs/r10k/blob/master/doc/dynamic-environments/git-environments.mkd#invalid_branches
>
> what i need is to be able to tell puppet (either in command line or
> config) that
> environment value is "some/git/branch" while puppet will see it internally
> as "some__git__branch"
>

My reading of those docs is that r10k will rename the branch internally.


Right, but I think the issue here is that you have to specify the renamed branch name as --environment option. You can't specify the original name with slashes etc.
 
Regards

James Turnbull

--
* The Art of Monitoring (http://artofmonitoring.com)
* The Docker Book (http://dockerbook.com)
* The LogStash Book (http://logstashbook.com)
* Pro Puppet (http://tinyurl.com/ppuppet2 )
* Pro Linux System Administration (http://tinyurl.com/linuxadmin)
* Hardening Linux (http://tinyurl.com/hardeninglinux)

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/5547A1BC.8030003%40lovedthanlost.net.
For more options, visit https://groups.google.com/d/optout.

Maksym Melnychok

unread,
May 7, 2015, 5:31:29 AM5/7/15
to puppe...@googlegroups.com
Erik is right, that's exactly my problem - i want to be able to run `puppet --environment invalid/env/name` and have puppet see it as `invalid__env__name`

James Turnbull

unread,
May 7, 2015, 11:24:21 AM5/7/15
to puppe...@googlegroups.com
Maksym Melnychok wrote:
> Erik is right, that's exactly my problem - i want to be able to run
> `puppet --environment invalid/env/name` and have puppet see it as
> `invalid__env__name`
>

Then beyond a wrapper I don't have a good solution for you. Sorry. :(
Reply all
Reply to author
Forward
0 new messages