Re: [Puppet Users] Getting the location of the manifest file

2021-08-27 Thread Go Iwai
Hello Ben,

On Wednesday, August 18, 2021 at 2:25:19 AM UTC+9 Ben Ford wrote:

> Hiera provides an environment hierarchy. Is that what you're looking for? 
> https://puppet.com/docs/puppet/latest/hiera_config_yaml_5.html
>

No, it is not. I know that the environmental hierarchy provided by hiera 
realise what I want to do but I don't want to do with that.

Let me restate the question. How can we get the absolute path of the 
manifest file in itself?

% pwd
/xxx/yyy
% puppet apply ../zzz/manifest.pp

In this example above, I would get the /xxx/zzz/manifest.pp in the manifest 
somehow.

Kind regards,
Go
 

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/1699572d-2c0f-46da-87dd-be36db28cf6dn%40googlegroups.com.


Re: [Puppet Users] Getting the location of the manifest file

2021-08-17 Thread Ben Ford
Hiera provides an environment hierarchy. Is that what you're looking for?
https://puppet.com/docs/puppet/latest/hiera_config_yaml_5.html

On Mon, Aug 16, 2021 at 7:33 PM Go Iwai  wrote:

> Hello Martin,
>
> Let's say we have three directories:
>
> preproduction/  preproduction/  private/
>
> There are different manifest files saved in the same name, like
> service-deploy.pp.
>
> In the manifest service-deploy.pp, I want to get the absolute path to
> itself, then determine the variable of env like:
>
> $dir = dirname($file)  # $file is absolute path to service-deploy.pp
> like: '/path/to/manifests/preproduction/service-deploy.pp'
> $env = split($dir, '/')[-1]
>
> Then, hiera dynamically maps the correspond yaml file under the $env like:
>
> mapped_paths: [services, svc, "environments/%{env}/%{svc}.yaml"]
>
> This is what I want to realise. I know puppet has already provided a
> switch in response to $environment, e.g.,
> /etc/puppetlabs/code/environments/production. In this way, I have to
> maintain some branches in parallel. That is what I don't want to do.
>
> Kind regards,
> Go
>
> On Mon, Aug 16, 2021 at 7:53 PM Martin Alfke  wrote:
> >
> > Hi Go,
> >
> > what do you want to achieve?
> > When using puppet apply, a manifest can be anywhere on the filesystem.
> >
> > Best,
> > Martin
> >
> >
> > > On 16. Aug 2021, at 03:18, Go Iwai  wrote:
> > >
> > > Hello,
> > >
> > > I want to know the location where puppet-apply locally applied the
> > > manifest file.
> > >
> > > $ pwd
> > > /path/to/manifests
> > > $ puppet apply file.pp
> > >
> > > In this case above, can I anyhow get the location of
> > > /path/to/manifests/file.pp within file.pp?
> > >
> > > Kind regards,
> > > Go
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> > > To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users+unsubscr...@googlegroups.com.
> > > To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/CAAyfkv-2dC--QR_1tz1ux%2BrgYaVsqjseB4oTEZ-EnkZPNXnn1w%40mail.gmail.com
> .
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/2E04526A-7F74-4F84-99E4-4C1D675FC67C%40gmail.com
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/CAAyfkv_qCcfWG5tcqkD%2BTAaSRPhr%3DsfCYYUP3q1MXToULxXyJw%40mail.gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CACkW_L7XSALCjA67chyTjD%2Bpsx0-72kOOf%3D5HTC1kBjdGd3H%2BA%40mail.gmail.com.


Re: [Puppet Users] Getting the location of the manifest file

2021-08-16 Thread Go Iwai
Hello Martin,

Let's say we have three directories:

preproduction/  preproduction/  private/

There are different manifest files saved in the same name, like
service-deploy.pp.

In the manifest service-deploy.pp, I want to get the absolute path to
itself, then determine the variable of env like:

$dir = dirname($file)  # $file is absolute path to service-deploy.pp
like: '/path/to/manifests/preproduction/service-deploy.pp'
$env = split($dir, '/')[-1]

Then, hiera dynamically maps the correspond yaml file under the $env like:

mapped_paths: [services, svc, "environments/%{env}/%{svc}.yaml"]

This is what I want to realise. I know puppet has already provided a
switch in response to $environment, e.g.,
/etc/puppetlabs/code/environments/production. In this way, I have to
maintain some branches in parallel. That is what I don't want to do.

Kind regards,
Go

On Mon, Aug 16, 2021 at 7:53 PM Martin Alfke  wrote:
>
> Hi Go,
>
> what do you want to achieve?
> When using puppet apply, a manifest can be anywhere on the filesystem.
>
> Best,
> Martin
>
>
> > On 16. Aug 2021, at 03:18, Go Iwai  wrote:
> >
> > Hello,
> >
> > I want to know the location where puppet-apply locally applied the
> > manifest file.
> >
> > $ pwd
> > /path/to/manifests
> > $ puppet apply file.pp
> >
> > In this case above, can I anyhow get the location of
> > /path/to/manifests/file.pp within file.pp?
> >
> > Kind regards,
> > Go
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Puppet Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to puppet-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/puppet-users/CAAyfkv-2dC--QR_1tz1ux%2BrgYaVsqjseB4oTEZ-EnkZPNXnn1w%40mail.gmail.com.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/2E04526A-7F74-4F84-99E4-4C1D675FC67C%40gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAAyfkv_qCcfWG5tcqkD%2BTAaSRPhr%3DsfCYYUP3q1MXToULxXyJw%40mail.gmail.com.


Re: [Puppet Users] Getting the location of the manifest file

2021-08-16 Thread Ben Ford
Hi Go!

I'm not sure what you're trying to accomplish, but you'd probably be better
off locating your code in a module on your modulepath and then Puppet takes
care of all the relative paths for you.
https://puppet.com/docs/puppet/latest/modules_fundamentals.html

On Mon, Aug 16, 2021 at 3:53 AM Martin Alfke  wrote:

> Hi Go,
>
> what do you want to achieve?
> When using puppet apply, a manifest can be anywhere on the filesystem.
>
> Best,
> Martin
>
>
> > On 16. Aug 2021, at 03:18, Go Iwai  wrote:
> >
> > Hello,
> >
> > I want to know the location where puppet-apply locally applied the
> > manifest file.
> >
> > $ pwd
> > /path/to/manifests
> > $ puppet apply file.pp
> >
> > In this case above, can I anyhow get the location of
> > /path/to/manifests/file.pp within file.pp?
> >
> > Kind regards,
> > Go
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/CAAyfkv-2dC--QR_1tz1ux%2BrgYaVsqjseB4oTEZ-EnkZPNXnn1w%40mail.gmail.com
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/2E04526A-7F74-4F84-99E4-4C1D675FC67C%40gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CACkW_L4J5pCQeshZO1Nf3sRwdnKoGxy%2BgPUC6Cx66rXdArQUcQ%40mail.gmail.com.


Re: [Puppet Users] Getting the location of the manifest file

2021-08-16 Thread Martin Alfke
Hi Go,

what do you want to achieve?
When using puppet apply, a manifest can be anywhere on the filesystem.

Best,
Martin


> On 16. Aug 2021, at 03:18, Go Iwai  wrote:
> 
> Hello,
> 
> I want to know the location where puppet-apply locally applied the
> manifest file.
> 
> $ pwd
> /path/to/manifests
> $ puppet apply file.pp
> 
> In this case above, can I anyhow get the location of
> /path/to/manifests/file.pp within file.pp?
> 
> Kind regards,
> Go
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/CAAyfkv-2dC--QR_1tz1ux%2BrgYaVsqjseB4oTEZ-EnkZPNXnn1w%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/2E04526A-7F74-4F84-99E4-4C1D675FC67C%40gmail.com.