I would Puppet to modify some parameters in “php.ini” file.

In may example, thsi parameter is “post_max_size“.

  • Here the current value :
[root@puppetserver ~]# grep post_max_size /etc/php.ini
post_max_size = 8M

I would like to have “32M” instead of “8M”.

What Augeas can do for me ?

Augeas treats configuration files as a values tree :

[root@puppetserver ~]# /opt/puppetlabs/puppet/bin/augtool print /files/etc/php.ini | grep post_max_size
/files/etc/php.ini/PHP/post_max_size = "8M"

Ask augeas to replace the value :

[root@puppetserver ~]# /opt/puppetlabs/puppet/bin/augtool
augtool> set /files/etc/php.ini/PHP/post_max_size 32M
augtool> save
Saved 1 file(s)
augtool> quit

Check :

[root@puppetserver ~]# grep post_max_size /etc/php.ini
post_max_size = 32M

Great, it works !

Puppet & Augeas

Now, I would like Puppet to do the same…

Create a short Puppet manifest :

[root@puppetserver ~]# mkdir /examples && cd /examples
[root@puppetserver examples]# cat augeas_example.pp
class augeas_example {
  augeas { "post_max_size 32MB" :
    context => '/files/etc/php.ini',
    changes => [ 'set PHP/post_max_size 32M' ],
  }
}

include ::augeas_example

Check Puppet syntax :

[root@puppetserver examples]# puppet parser validate augeas_example.pp

Dry run :

[root@puppetserver examples]# puppet apply --noop augeas_example.pp
Notice: Compiled catalog for puppetserver.argonay.wou in environment production in 0.21 seconds
Notice: /Stage[main]/Augeas_example/Augeas[post_max_size 32MB]/returns: current_value need_to_run, should be 0 (noop)
Notice: Class[Augeas_example]: Would have triggered 'refresh' from 1 events
Notice: Stage[main]: Would have triggered 'refresh' from 1 events
Notice: Applied catalog in 0.79 seconds

Apply this manifest :

[root@puppetserver examples]# puppet apply augeas_example.pp
Notice: Compiled catalog for puppetserver.argonay.wou in environment production in 0.17 seconds
Notice: /Stage[main]/Augeas_example/Augeas[post_max_size 32MB]/returns: executed successfully
Notice: Applied catalog in 1.00 seconds

And Puppet did the job :

[root@puppetserver examples]# grep post_max_size /etc/php.ini
post_max_size = 32M

 

PDF24    Send article as PDF   

Leave a Reply

Your email address will not be published. Required fields are marked *


*