Re: [Puppet Users] init config once

2021-03-15 Thread Steve McKuhr
Thanks for that, it *is* useful, although not in this particular 
scenario. It's sitting now in my Puppet toolbox.

On Fri, 2021-01-29 at 11:47 -0800, Ben Ford wrote:
> I do have a kind of terrible module that does exactly this I make no 
> guarantees whatsoever about how well it works. I ended up not using it for 
> much longer after building it.
> 
> https://forge.puppet.com/modules/binford2k/manageonce
> 
> On Fri, Jan 29, 2021 at 12:14 AM Martin Alfke  wrote:
> > A custom fact is the best way to report the status of the file on the node 
> > to the master and have the file managed by Puppet based on the fact value.
> > 
> > Bolt needs ssh access to the systems (unless you are using Puppet 
> > Enterprise which does not need ssh but uses a message queue on the master 
> > and the pxp-agent on the nodes.).
> > 
> > Besides this: Bolt must be executed manually
> > 
> > > On 29. Jan 2021, at 06:03, Benjamin Ridley  wrote:
> > > 
> > > You might be better off using something like Puppet Bolt to deploy the 
> > > file as a one off task at provisioning, rather than trying to manage it 
> > > declaratively through Puppet. 
> > > 
> > > On Fri, 29 Jan 2021, 3:50 pm Steve McKuhr,  wrote:
> > > > In an effort to avoid errors triggered by validate_cmd, I ended up 
> > > > using  
> > > > a conditional based on a File.exists custom fact. I'm still open to 
> > > > suggestions, this is all new territory to me.
> > > > 
> > > > 
> > > > On Thu, 2021-01-28 at 17:13 -0800, Steve McKuhr wrote:
> > > > > I've just realized that my problem statement was slightly misleading. 
> > > > > A 
> > > > > 'users' file gets installed as part of the software package, and the  
> > > > > goal is replacing its contents during the first Puppet run. The next 
> > > > > Puppet runs should ignore any changes.
> > > > > 
> > > > > 
> > > > > On Thu, 2021-01-28 at 20:07 +0100, Martin Alfke wrote:
> > > > > > and please use ensure => file !
> > > > > > this is more clear.
> > > > > > you can set the file ensure attribute to one of the following: 
> > > > > > file, directory, link, absent
> > > > > > 
> > > > > > 
> > > > > > > On 28. Jan 2021, at 18:58, Ben Ford  wrote:
> > > > > > > 
> > > > > > > Yep, just use the replace attribute on the file resource. 
> > > > > > > https://puppet.com/docs/puppet/latest/types/file.html#file-attribute-replace
> > > > > > > 
> > > > > > > On Thu, Jan 28, 2021 at 9:57 AM Steve McKuhr 
> > > > > > >  wrote:
> > > > > > > I'd like to initialize a user config file once, at software 
> > > > > > > install time, then allow application admins to manage the file 
> > > > > > > contents via web interface (add/remove users, etc.) - I have come 
> > > > > > > up with the following:
> > > > > > > 
> > > > > > > file { 'users':
> > > > > > >   ensure => present,
> > > > > > >   content => template('my-template'),
> > > > > > >   validate_cmd => '/bin/test ! -f users.control',
> > > > > > > }
> > > > > > > file { 'users.control':
> > > > > > >   ensure => present,
> > > > > > >   content => "puppet managed",
> > > > > > >   require => File['users'],
> > > > > > > }
> > > > > > > 
> > > > > > > The above code works ok, however I was wondering if there is a 
> > > > > > > more elegant solution.
> > > > > > > 
> > > > > > > Thanks,
> > > > > > > Steve
> > > > > > > 
> > > > > > > 
> > > > > > > -- 
> > > > > > > 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/fb1ae2b4-f220-4d18-864b-aafbadb44b14n%40googlegroups.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_L5oTmsHiwvmVEisKap7gkUt1P4Gmvh1-%3DBQqNtHHiWAcA%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/7a518ea8c6214ea01e1ce3d6e76273ddfd576493.camel%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 

Re: [Puppet Users] init config once

2021-01-31 Thread Justin Stoller
Just to pile on. If you want the content updated whenever the package is
updated and you are managing the package with puppet you can "subscribe" to
the package resource to have the file resource only applied when the
package changes.

On Fri, Jan 29, 2021 at 11:47 AM Ben Ford  wrote:

> I do have a kind of terrible module that does exactly this I make no
> guarantees whatsoever about how well it works. I ended up not using it for
> much longer after building it.
>
> https://forge.puppet.com/modules/binford2k/manageonce
>
> On Fri, Jan 29, 2021 at 12:14 AM Martin Alfke  wrote:
>
>> A custom fact is the best way to report the status of the file on the
>> node to the master and have the file managed by Puppet based on the fact
>> value.
>>
>> Bolt needs ssh access to the systems (unless you are using Puppet
>> Enterprise which does not need ssh but uses a message queue on the master
>> and the pxp-agent on the nodes.).
>>
>> Besides this: Bolt must be executed manually
>>
>> On 29. Jan 2021, at 06:03, Benjamin Ridley  wrote:
>>
>> You might be better off using something like Puppet Bolt to deploy the
>> file as a one off task at provisioning, rather than trying to manage it
>> declaratively through Puppet.
>>
>> On Fri, 29 Jan 2021, 3:50 pm Steve McKuhr, 
>> wrote:
>>
>>> In an effort to avoid errors triggered by validate_cmd, I ended up
>>> using
>>> a conditional based on a File.exists custom fact. I'm still open to
>>> suggestions, this is all new territory to me.
>>>
>>>
>>> On Thu, 2021-01-28 at 17:13 -0800, Steve McKuhr wrote:
>>> > I've just realized that my problem statement was slightly misleading.
>>> A
>>> > 'users' file gets installed as part of the software package, and the
>>> > goal is replacing its contents during the first Puppet run. The next
>>> > Puppet runs should ignore any changes.
>>> >
>>> >
>>> > On Thu, 2021-01-28 at 20:07 +0100, Martin Alfke wrote:
>>> > > and please use ensure => file !
>>> > > this is more clear.
>>> > > you can set the file ensure attribute to one of the following: file,
>>> directory, link, absent
>>> > >
>>> > >
>>> > > > On 28. Jan 2021, at 18:58, Ben Ford  wrote:
>>> > > >
>>> > > > Yep, just use the replace attribute on the file resource.
>>> https://puppet.com/docs/puppet/latest/types/file.html#file-attribute-replace
>>> > > >
>>> > > > On Thu, Jan 28, 2021 at 9:57 AM Steve McKuhr <
>>> steve.mck...@gmail.com> wrote:
>>> > > > I'd like to initialize a user config file once, at software
>>> install time, then allow application admins to manage the file contents via
>>> web interface (add/remove users, etc.) - I have come up with the following:
>>> > > >
>>> > > > file { 'users':
>>> > > >   ensure => present,
>>> > > >   content => template('my-template'),
>>> > > >   validate_cmd => '/bin/test ! -f users.control',
>>> > > > }
>>> > > > file { 'users.control':
>>> > > >   ensure => present,
>>> > > >   content => "puppet managed",
>>> > > >   require => File['users'],
>>> > > > }
>>> > > >
>>> > > > The above code works ok, however I was wondering if there is a
>>> more elegant solution.
>>> > > >
>>> > > > Thanks,
>>> > > > Steve
>>> > > >
>>> > > >
>>> > > > --
>>> > > > 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/fb1ae2b4-f220-4d18-864b-aafbadb44b14n%40googlegroups.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_L5oTmsHiwvmVEisKap7gkUt1P4Gmvh1-%3DBQqNtHHiWAcA%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/7a518ea8c6214ea01e1ce3d6e76273ddfd576493.camel%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/CABaapw%2B3od6HtGXb8bGMncUXZWuiZW46frSfL62S%3DgjyqcJimg%40mail.gmail.com
>> 

Re: [Puppet Users] init config once

2021-01-29 Thread Ben Ford
I do have a kind of terrible module that does exactly this I make no
guarantees whatsoever about how well it works. I ended up not using it for
much longer after building it.

https://forge.puppet.com/modules/binford2k/manageonce

On Fri, Jan 29, 2021 at 12:14 AM Martin Alfke  wrote:

> A custom fact is the best way to report the status of the file on the node
> to the master and have the file managed by Puppet based on the fact value.
>
> Bolt needs ssh access to the systems (unless you are using Puppet
> Enterprise which does not need ssh but uses a message queue on the master
> and the pxp-agent on the nodes.).
>
> Besides this: Bolt must be executed manually
>
> On 29. Jan 2021, at 06:03, Benjamin Ridley  wrote:
>
> You might be better off using something like Puppet Bolt to deploy the
> file as a one off task at provisioning, rather than trying to manage it
> declaratively through Puppet.
>
> On Fri, 29 Jan 2021, 3:50 pm Steve McKuhr,  wrote:
>
>> In an effort to avoid errors triggered by validate_cmd, I ended up using
>> a conditional based on a File.exists custom fact. I'm still open to
>> suggestions, this is all new territory to me.
>>
>>
>> On Thu, 2021-01-28 at 17:13 -0800, Steve McKuhr wrote:
>> > I've just realized that my problem statement was slightly misleading. A
>> > 'users' file gets installed as part of the software package, and the
>> > goal is replacing its contents during the first Puppet run. The next
>> > Puppet runs should ignore any changes.
>> >
>> >
>> > On Thu, 2021-01-28 at 20:07 +0100, Martin Alfke wrote:
>> > > and please use ensure => file !
>> > > this is more clear.
>> > > you can set the file ensure attribute to one of the following: file,
>> directory, link, absent
>> > >
>> > >
>> > > > On 28. Jan 2021, at 18:58, Ben Ford  wrote:
>> > > >
>> > > > Yep, just use the replace attribute on the file resource.
>> https://puppet.com/docs/puppet/latest/types/file.html#file-attribute-replace
>> > > >
>> > > > On Thu, Jan 28, 2021 at 9:57 AM Steve McKuhr <
>> steve.mck...@gmail.com> wrote:
>> > > > I'd like to initialize a user config file once, at software install
>> time, then allow application admins to manage the file contents via web
>> interface (add/remove users, etc.) - I have come up with the following:
>> > > >
>> > > > file { 'users':
>> > > >   ensure => present,
>> > > >   content => template('my-template'),
>> > > >   validate_cmd => '/bin/test ! -f users.control',
>> > > > }
>> > > > file { 'users.control':
>> > > >   ensure => present,
>> > > >   content => "puppet managed",
>> > > >   require => File['users'],
>> > > > }
>> > > >
>> > > > The above code works ok, however I was wondering if there is a more
>> elegant solution.
>> > > >
>> > > > Thanks,
>> > > > Steve
>> > > >
>> > > >
>> > > > --
>> > > > 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/fb1ae2b4-f220-4d18-864b-aafbadb44b14n%40googlegroups.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_L5oTmsHiwvmVEisKap7gkUt1P4Gmvh1-%3DBQqNtHHiWAcA%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/7a518ea8c6214ea01e1ce3d6e76273ddfd576493.camel%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/CABaapw%2B3od6HtGXb8bGMncUXZWuiZW46frSfL62S%3DgjyqcJimg%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/45081E02-E818-4013-8547-F0E6B5856118%40gmail.com
> 

Re: [Puppet Users] init config once

2021-01-29 Thread Martin Alfke
A custom fact is the best way to report the status of the file on the node to 
the master and have the file managed by Puppet based on the fact value.

Bolt needs ssh access to the systems (unless you are using Puppet Enterprise 
which does not need ssh but uses a message queue on the master and the 
pxp-agent on the nodes.).

Besides this: Bolt must be executed manually

> On 29. Jan 2021, at 06:03, Benjamin Ridley  wrote:
> 
> You might be better off using something like Puppet Bolt to deploy the file 
> as a one off task at provisioning, rather than trying to manage it 
> declaratively through Puppet. 
> 
> On Fri, 29 Jan 2021, 3:50 pm Steve McKuhr,  > wrote:
> In an effort to avoid errors triggered by validate_cmd, I ended up using  
> a conditional based on a File.exists custom fact. I'm still open to 
> suggestions, this is all new territory to me.
> 
> 
> On Thu, 2021-01-28 at 17:13 -0800, Steve McKuhr wrote:
> > I've just realized that my problem statement was slightly misleading. A 
> > 'users' file gets installed as part of the software package, and the  
> > goal is replacing its contents during the first Puppet run. The next 
> > Puppet runs should ignore any changes.
> > 
> > 
> > On Thu, 2021-01-28 at 20:07 +0100, Martin Alfke wrote:
> > > and please use ensure => file !
> > > this is more clear.
> > > you can set the file ensure attribute to one of the following: file, 
> > > directory, link, absent
> > > 
> > > 
> > > > On 28. Jan 2021, at 18:58, Ben Ford  > > > > wrote:
> > > > 
> > > > Yep, just use the replace attribute on the file resource. 
> > > > https://puppet.com/docs/puppet/latest/types/file.html#file-attribute-replace
> > > >  
> > > > 
> > > > 
> > > > On Thu, Jan 28, 2021 at 9:57 AM Steve McKuhr  > > > > wrote:
> > > > I'd like to initialize a user config file once, at software install 
> > > > time, then allow application admins to manage the file contents via web 
> > > > interface (add/remove users, etc.) - I have come up with the following:
> > > > 
> > > > file { 'users':
> > > >   ensure => present,
> > > >   content => template('my-template'),
> > > >   validate_cmd => '/bin/test ! -f users.control',
> > > > }
> > > > file { 'users.control':
> > > >   ensure => present,
> > > >   content => "puppet managed",
> > > >   require => File['users'],
> > > > }
> > > > 
> > > > The above code works ok, however I was wondering if there is a more 
> > > > elegant solution.
> > > > 
> > > > Thanks,
> > > > Steve
> > > > 
> > > > 
> > > > -- 
> > > > 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/fb1ae2b4-f220-4d18-864b-aafbadb44b14n%40googlegroups.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_L5oTmsHiwvmVEisKap7gkUt1P4Gmvh1-%3DBQqNtHHiWAcA%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/7a518ea8c6214ea01e1ce3d6e76273ddfd576493.camel%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/CABaapw%2B3od6HtGXb8bGMncUXZWuiZW46frSfL62S%3DgjyqcJimg%40mail.gmail.com
>  
> 

Re: [Puppet Users] init config once

2021-01-28 Thread Benjamin Ridley
You might be better off using something like Puppet Bolt to deploy the file
as a one off task at provisioning, rather than trying to manage it
declaratively through Puppet.

On Fri, 29 Jan 2021, 3:50 pm Steve McKuhr,  wrote:

> In an effort to avoid errors triggered by validate_cmd, I ended up using
> a conditional based on a File.exists custom fact. I'm still open to
> suggestions, this is all new territory to me.
>
>
> On Thu, 2021-01-28 at 17:13 -0800, Steve McKuhr wrote:
> > I've just realized that my problem statement was slightly misleading. A
> > 'users' file gets installed as part of the software package, and the
> > goal is replacing its contents during the first Puppet run. The next
> > Puppet runs should ignore any changes.
> >
> >
> > On Thu, 2021-01-28 at 20:07 +0100, Martin Alfke wrote:
> > > and please use ensure => file !
> > > this is more clear.
> > > you can set the file ensure attribute to one of the following: file,
> directory, link, absent
> > >
> > >
> > > > On 28. Jan 2021, at 18:58, Ben Ford  wrote:
> > > >
> > > > Yep, just use the replace attribute on the file resource.
> https://puppet.com/docs/puppet/latest/types/file.html#file-attribute-replace
> > > >
> > > > On Thu, Jan 28, 2021 at 9:57 AM Steve McKuhr 
> wrote:
> > > > I'd like to initialize a user config file once, at software install
> time, then allow application admins to manage the file contents via web
> interface (add/remove users, etc.) - I have come up with the following:
> > > >
> > > > file { 'users':
> > > >   ensure => present,
> > > >   content => template('my-template'),
> > > >   validate_cmd => '/bin/test ! -f users.control',
> > > > }
> > > > file { 'users.control':
> > > >   ensure => present,
> > > >   content => "puppet managed",
> > > >   require => File['users'],
> > > > }
> > > >
> > > > The above code works ok, however I was wondering if there is a more
> elegant solution.
> > > >
> > > > Thanks,
> > > > Steve
> > > >
> > > >
> > > > --
> > > > 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/fb1ae2b4-f220-4d18-864b-aafbadb44b14n%40googlegroups.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_L5oTmsHiwvmVEisKap7gkUt1P4Gmvh1-%3DBQqNtHHiWAcA%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/7a518ea8c6214ea01e1ce3d6e76273ddfd576493.camel%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/CABaapw%2B3od6HtGXb8bGMncUXZWuiZW46frSfL62S%3DgjyqcJimg%40mail.gmail.com.


Re: [Puppet Users] init config once

2021-01-28 Thread Steve McKuhr
In an effort to avoid errors triggered by validate_cmd, I ended up using  
a conditional based on a File.exists custom fact. I'm still open to 
suggestions, this is all new territory to me.


On Thu, 2021-01-28 at 17:13 -0800, Steve McKuhr wrote:
> I've just realized that my problem statement was slightly misleading. A 
> 'users' file gets installed as part of the software package, and the  
> goal is replacing its contents during the first Puppet run. The next 
> Puppet runs should ignore any changes.
> 
> 
> On Thu, 2021-01-28 at 20:07 +0100, Martin Alfke wrote:
> > and please use ensure => file !
> > this is more clear.
> > you can set the file ensure attribute to one of the following: file, 
> > directory, link, absent
> > 
> > 
> > > On 28. Jan 2021, at 18:58, Ben Ford  wrote:
> > > 
> > > Yep, just use the replace attribute on the file resource. 
> > > https://puppet.com/docs/puppet/latest/types/file.html#file-attribute-replace
> > > 
> > > On Thu, Jan 28, 2021 at 9:57 AM Steve McKuhr  
> > > wrote:
> > > I'd like to initialize a user config file once, at software install time, 
> > > then allow application admins to manage the file contents via web 
> > > interface (add/remove users, etc.) - I have come up with the following:
> > > 
> > > file { 'users':
> > >   ensure => present,
> > >   content => template('my-template'),
> > >   validate_cmd => '/bin/test ! -f users.control',
> > > }
> > > file { 'users.control':
> > >   ensure => present,
> > >   content => "puppet managed",
> > >   require => File['users'],
> > > }
> > > 
> > > The above code works ok, however I was wondering if there is a more 
> > > elegant solution.
> > > 
> > > Thanks,
> > > Steve
> > > 
> > > 
> > > -- 
> > > 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/fb1ae2b4-f220-4d18-864b-aafbadb44b14n%40googlegroups.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_L5oTmsHiwvmVEisKap7gkUt1P4Gmvh1-%3DBQqNtHHiWAcA%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/7a518ea8c6214ea01e1ce3d6e76273ddfd576493.camel%40gmail.com.


Re: [Puppet Users] init config once

2021-01-28 Thread Steve McKuhr
I've just realized that my problem statement was slightly misleading. A 
'users' file gets installed as part of the software package, and the  
goal is replacing its contents during the first Puppet run. The next 
Puppet runs should ignore any changes.


On Thu, 2021-01-28 at 20:07 +0100, Martin Alfke wrote:
> and please use ensure => file !
> this is more clear.
> you can set the file ensure attribute to one of the following: file, 
> directory, link, absent
> 
> 
> > On 28. Jan 2021, at 18:58, Ben Ford  wrote:
> > 
> > Yep, just use the replace attribute on the file resource. 
> > https://puppet.com/docs/puppet/latest/types/file.html#file-attribute-replace
> > 
> > On Thu, Jan 28, 2021 at 9:57 AM Steve McKuhr  wrote:
> > I'd like to initialize a user config file once, at software install time, 
> > then allow application admins to manage the file contents via web interface 
> > (add/remove users, etc.) - I have come up with the following:
> > 
> > file { 'users':
> >   ensure => present,
> >   content => template('my-template'),
> >   validate_cmd => '/bin/test ! -f users.control',
> > }
> > file { 'users.control':
> >   ensure => present,
> >   content => "puppet managed",
> >   require => File['users'],
> > }
> > 
> > The above code works ok, however I was wondering if there is a more elegant 
> > solution.
> > 
> > Thanks,
> > Steve
> > 
> > 
> > -- 
> > 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/fb1ae2b4-f220-4d18-864b-aafbadb44b14n%40googlegroups.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_L5oTmsHiwvmVEisKap7gkUt1P4Gmvh1-%3DBQqNtHHiWAcA%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/4cb67533a96456e7761973336db2eb2f96dc3e1e.camel%40gmail.com.


Re: [Puppet Users] init config once

2021-01-28 Thread Martin Alfke
and please use ensure => file !
this is more clear.
you can set the file ensure attribute to one of the following: file, directory, 
link, absent


> On 28. Jan 2021, at 18:58, Ben Ford  wrote:
> 
> Yep, just use the replace attribute on the file resource. 
> https://puppet.com/docs/puppet/latest/types/file.html#file-attribute-replace
> 
> On Thu, Jan 28, 2021 at 9:57 AM Steve McKuhr  wrote:
> I'd like to initialize a user config file once, at software install time, 
> then allow application admins to manage the file contents via web interface 
> (add/remove users, etc.) - I have come up with the following:
> 
> file { 'users':
>   ensure => present,
>   content => template('my-template'),
>   validate_cmd => '/bin/test ! -f users.control',
> }
> file { 'users.control':
>   ensure => present,
>   content => "puppet managed",
>   require => File['users'],
> }
> 
> The above code works ok, however I was wondering if there is a more elegant 
> solution.
> 
> Thanks,
> Steve
> 
> 
> -- 
> 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/fb1ae2b4-f220-4d18-864b-aafbadb44b14n%40googlegroups.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_L5oTmsHiwvmVEisKap7gkUt1P4Gmvh1-%3DBQqNtHHiWAcA%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/ABD6964A-0353-4CA9-B528-B2C0D241BE37%40gmail.com.


Re: [Puppet Users] init config once

2021-01-28 Thread Ben Ford
Yep, just use the replace attribute on the file resource.
https://puppet.com/docs/puppet/latest/types/file.html#file-attribute-replace

On Thu, Jan 28, 2021 at 9:57 AM Steve McKuhr  wrote:

> I'd like to initialize a user config file once, at software install time,
> then allow application admins to manage the file contents via web interface
> (add/remove users, etc.) - I have come up with the following:
>
> file { 'users':
>   ensure => present,
>   content => template('my-template'),
>   validate_cmd => '/bin/test ! -f users.control',
> }
> file { 'users.control':
>   ensure => present,
>   content => "puppet managed",
>   require => File['users'],
> }
>
> The above code works ok, however I was wondering if there is a more
> elegant solution.
>
> Thanks,
> Steve
>
> --
> 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/fb1ae2b4-f220-4d18-864b-aafbadb44b14n%40googlegroups.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_L5oTmsHiwvmVEisKap7gkUt1P4Gmvh1-%3DBQqNtHHiWAcA%40mail.gmail.com.


[Puppet Users] init config once

2021-01-28 Thread Steve McKuhr
I'd like to initialize a user config file once, at software install time, 
then allow application admins to manage the file contents via web interface 
(add/remove users, etc.) - I have come up with the following:

file { 'users':
  ensure => present,
  content => template('my-template'),
  validate_cmd => '/bin/test ! -f users.control',
}
file { 'users.control':
  ensure => present,
  content => "puppet managed",
  require => File['users'],
}

The above code works ok, however I was wondering if there is a more elegant 
solution.

Thanks,
Steve

-- 
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/fb1ae2b4-f220-4d18-864b-aafbadb44b14n%40googlegroups.com.