How to manage half file.

23 views
Skip to first unread message

Albert Shih

unread,
Jan 13, 2016, 3:28:13 PM1/13/16
to puppet...@googlegroups.com
Hi everybody.

I want to manage through puppet a config file for a php web application.

But I just want manage all of it's content except one line, because this
line is manage by the application himself.

I can't change the application behavior.

I don't think I can manage through augeas because this file is not in any
« standard » format.

I prefer not to manage it through file_line because this config file is
large.

What kind of solution do I have ?

Regards.

JAS
--
Albert SHIH
DIO bâtiment 15
Observatoire de Paris
5 Place Jules Janssen
92195 Meudon Cedex
France
Téléphone : +33 1 45 07 76 26/+33 6 86 69 95 71
xmpp: j...@obspm.fr
Heure local/Local time:
mer 13 jan 2016 21:17:48 CET

Hunter Haugen

unread,
Jan 13, 2016, 4:22:42 PM1/13/16
to puppet-users
Does the application have an "include" syntax that would allow you do have one file that is one line that the application manages, and the file that puppet manages includes it where appropriate?

Or a stupid workaround would be to have a fact that is that one line, and a puppet template that adds the line. So puppet would manage the whole file but the line would not be affected by a puppet run.



-Hunter


--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/20160113202546.GB83097%40pcjas.obspm.fr.
For more options, visit https://groups.google.com/d/optout.

Albert Shih

unread,
Jan 14, 2016, 11:50:00 AM1/14/16
to puppet...@googlegroups.com
Le 13/01/2016 à 13:21:51-0800, Hunter Haugen a écrit
> Does the application have an "include" syntax that would allow you do have one
> file that is one line that the application manages, and the file that puppet
> manages includes it where appropriate?

Well....I would like it....but no...

>
> Or a stupid workaround would be to have a fact that is that one line, and a
> puppet template that adds the line. So puppet would manage the whole file but
> the line would not be affected by a puppet run.

Humm....sorry I don't understand your workaround....

Thanks.

JAS
--
Albert SHIH
DIO bâtiment 15
Observatoire de Paris
5 Place Jules Janssen
92195 Meudon Cedex
France
Téléphone : +33 1 45 07 76 26/+33 6 86 69 95 71
xmpp: j...@obspm.fr
Heure local/Local time:
jeu 14 jan 2016 17:46:08 CET

Trevor Vaughan

unread,
Jan 15, 2016, 6:07:26 AM1/15/16
to puppet...@googlegroups.com
Albert's suggestion is probably your best bet at the least amount of work.

First, create a custom fact that pulls that line out of your file.https://docs.puppetlabs.com/facter/3.1/custom_facts.html.

Next, your template would have a placeholder for that item.

my_template.erb

...usual_template...
<%= @my_custom_fact %>
---remaining_template...

This isn't a great solution but it's probably the easiest way to solve your problem quickly. I would not do this if that line is huge (some encoded binary blob or something).

Trevor

--
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...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699

-- This account not approved for unencrypted proprietary information --

Trevor Vaughan

unread,
Jan 15, 2016, 6:07:48 AM1/15/16
to puppet...@googlegroups.com
Sorry...Hunter's!

Too early in the morning.

Craig Dunn

unread,
Jan 15, 2016, 6:38:50 AM1/15/16
to puppet...@googlegroups.com

Albert,

Is it possible that your application can manage the line it needs to manage in a separate file to php.ini?  If so you can use a combination of concat's source and content attributes to manage this.

If for example, your application can manage a file containing just the one line in /etc/config/file.part  you can concatenate this with Puppet data using something like;

concat { '/etc/config/file':
  ensure => present,
}

concat::fragment { 'config_puppet':
  content => template('mymodule/config.erb'),
  target  => '/etc/config/file',
}

concat::fragment { 'app_config':
  source  => '/etc/config/file.part',
  target  => '/etc/config/file',
}

This depends on your ability to define which file the application places it’s config in, but it’s another way of doing it that doesn’t involve writing facts.

Regards
Craig


-- 
Enviatics     |      Automation and Configuration Management
Puppet Labs Service Delivery Partner & Certified Consultant



Reply all
Reply to author
Forward
0 new messages