help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Complex Editfiles Examples


From: Russell Adams
Subject: Re: Complex Editfiles Examples
Date: Wed, 3 Dec 2003 10:26:57 -0600
User-agent: Mutt/1.4i

Egad man!! I'm impressed. ;]

I setup a similar construct last night to edit Gentoo's
/etc/make.conf, but its not nearly as complex.

I'll post something when I've got the limits thing figured out.

Russell

On Wed, Dec 03, 2003 at 12:43:00PM +1100, Jamie Wilkinson wrote:
> This one time, at band camp, Russell Adams wrote:
> >I haven't seen many complex editfiles examples in the sample configs,
> >and only one relevant FAQ entry.
> >
> >Anyone want to share their particularly complex editfiles experiences?
> >
> >Input would be appreciated. ;]
> 
> I have a really evil cf.mysql which tries to convergently edit
> /etc/my.cnf, which just happens to be in that .ini file format:
> 
> [group]
> key=value
> 
> but additionally it has the exciting 'set' command, i.e.:
> 
> set-variable = var=value
> 
> which makes things more interesting.
> 
> I think this is the ugliest of all my editfiles sections, only because I
> am not trying to do anything extremely complex (and safely convergent)
> on my Apache configurations...
> 
> Attached.
> 
> -- 
> jaq@spacepants.org                           http://spacepants.org/jaq.gpg
> 

> # configuration input for mysql
> 
> groups:
> 
>     mysql_server = ( juggernaut mast ballast yacht barnacle barge )
> 
>     mysql_shared_server = ( juggernaut )
> 
> control:
> 
>     AddInstallable = ( mysql_restart )
> 
>     mysql_bind_address = ( 127.0.0.1 )
> 
>     !mysql_shared_server::
> 
>         mysql_max_user_connections = ( 256 )
> 
>     mysql_shared_server::
> 
>         mysql_max_user_connections = ( 30 )
> 
> editfiles:
> 
>     mysql_server::
> 
>         { /etc/my.cnf
>             Backup 'off'
>             
>             # this is a bit dodgey, but as my.cnf is an ini-style conffile
>             # and editfiles can't nest groups, we'll have to make do
>             BeginGroupIfNoLineMatching '^port.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'port'
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '^socket.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'socket'
>             EndGroup
>             ResetSearch 1
>             # dunno about this one, just copying from the sample my-huge.cnf
>             BeginGroupIfNoLineMatching '^skip-locking.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'skip-locking'
>             EndGroup
>             ResetSearch 1
>             # my.cnf is fucked, these variables are of the form
>             # set-variable = key_buffer=384M
>             # so check for the actual variable and then qualify it with
>             # the set-variable later
>             BeginGroupIfNoLineMatching '.*key_buffer.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'key_buffer'
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '.*max_allowed_packet.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'max_allowed_packet'
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '.*table_cache.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'table_cache'
>             EndGroup
>             ResetSearch 1
>             # match the = otherwise myisasm_sort_buffer_size matches
>             BeginGroupIfNoLineMatching '.*sort_buffer=.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'sort_buffer='
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '.*record_buffer.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'record_buffer'
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '.*thread_cache.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'thread_cache'
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '.*thread_concurrency.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'thread_concurrency'
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '.*myisam_sort_buffer_size.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'myisam_sort_buffer_size'
>             EndGroup
>             ResetSearch 1
>             # back to normal variables
>             BeginGroupIfNoLineMatching '^log-bin.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'log-bin'
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '^server-id.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'server-id'
>             EndGroup
>             ResetSearch 1
>             # now for the innodb stuff
>             BeginGroupIfNoLineMatching '^innodb_data_home_dir.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'innodb_data_home_dir'
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '^innodb_data_file_path.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'innodb_data_file_path'
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '^innodb_log_group_home_dir.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'innodb_log_group_home_dir'
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '^innodb_log_arch_dir.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'innodb_log_arch_dir'
>             EndGroup
>             ResetSearch 1
>             # now for some set-variables again
>             BeginGroupIfNoLineMatching '.*innodb_buffer_pool_size.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'innodb_buffer_pool_size'
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '.*innodb_additional_mem_pool_size.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'innodb_additional_mem_pool_size'
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '.*innodb_log_file_size.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'innodb_log_file_size'
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '.*innodb_log_buffer_size.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'innodb_log_buffer_size'
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '^innodb_flush_log_at_trx_commit.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'innodb_flush_log_at_trx_commit'
>             EndGroup
>             ResetSearch 1
>             BeginGroupIfNoLineMatching '.*innodb_lock_wait_timeout.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'innodb_lock_wait_timeout'
>             EndGroup
>             ResetSearch 1
>             # set the default table type to innodb
>             BeginGroupIfNoLineMatching '.*default-table-type.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'default-table-type'
>             EndGroup
>             ResetSearch 1
>             # security options, users can't see databases they don't own
>             BeginGroupIfNoLineMatching '^safe-show-database.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'safe-show-database'
>             EndGroup
>             ResetSearch 1
>             # need INSERT privs on mysql.user in order to GRANT
>             BeginGroupIfNoLineMatching '.*safe-user-create.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'safe-user-create'
>             EndGroup
>             ResetSearch 1
>           # listen only on the interfaces we tell it to
>           BeginGroupIfNoLineMatching '^bind-address =.*'
>               LocateLineMatching '^\[mysqld\]'
>               InsertLine 'bind-address ='
>           EndGroup
>           ResetSearch 1
>             # now we've made sure the options exist, set the values
>             LocateLineMatching '^port.*'
>             ReplaceLineWith 'port = 3306'
>             ResetSearch 1
>             LocateLineMatching '^socket.*'
>             ReplaceLineWith 'socket = /var/lib/mysql/mysql.sock'
>             ResetSearch 1
>             LocateLineMatching '.*key_buffer.*'
>             ReplaceLineWith 'set-variable = key_buffer=256M'
>             ResetSearch 1
>             LocateLineMatching '.*max_allowed_packet.*'
>             ReplaceLineWith 'set-variable = max_allowed_packet=1M'
>             ResetSearch 1
>             LocateLineMatching '.*table_cache.*'
>             ReplaceLineWith 'set-variable = table_cache=256'
>             ResetSearch 1
>             LocateLineMatching '.*sort_buffer=.*'
>             ReplaceLineWith 'set-variable = sort_buffer=1M'
>             ResetSearch 1
>             LocateLineMatching '.*record_buffer.*'
>             ReplaceLineWith 'set-variable = record_buffer=1M'
>             ResetSearch 1
>             LocateLineMatching '.*thread_cache.*'
>             ReplaceLineWith 'set-variable = thread_cache=8'
>             ResetSearch 1
>             LocateLineMatching '.*thread_concurrency.*'
>             ReplaceLineWith 'set-variable = thread_concurrency=8'
>             ResetSearch 1
>             LocateLineMatching '.*myisam_sort_buffer_size.*'
>             ReplaceLineWith 'set-variable = myisam_sort_buffer_size=64M'
>             ResetSearch 1
>             LocateLineMatching '^server-id.*'
>             ReplaceLineWith 'server-id = 1'
>             ResetSearch 1
>             LocateLineMatching '^innodb_data_home_dir.*'
>             ReplaceLineWith 'innodb_data_home_dir = /var/lib/mysql/'
>             ResetSearch 1
>             LocateLineMatching '^innodb_data_file_path.*'
>             ReplaceLineWith 'innodb_data_file_path = 
> ibdata1:2000M;ibdata:10M:autoextend'
>             ResetSearch 1
>             LocateLineMatching '^innodb_log_group_home_dir.*'
>             ReplaceLineWith 'innodb_log_group_home_dir = /var/lib/mysql/'
>             ResetSearch 1
>             LocateLineMatching '^innodb_log_arch_dir.*'
>             ReplaceLineWith 'innodb_log_arch_dir = /var/lib/mysql/'
>             ResetSearch 1
>             LocateLineMatching '.*innodb_buffer_pool_size.*'
>             ReplaceLineWith 'set-variable = innodb_buffer_pool_size=256M'
>             ResetSearch 1
>             LocateLineMatching '.*innodb_additional_mem_pool_size.*'
>             ReplaceLineWith 'set-variable = 
> innodb_additional_mem_pool_size=20M'
>             ResetSearch 1
>             LocateLineMatching '.*innodb_log_file_size.*'
>             ReplaceLineWith 'set-variable = innodb_log_file_size=64M'
>             ResetSearch 1
>             LocateLineMatching '.*innodb_log_buffer_size.*'
>             ReplaceLineWith 'set-variable = innodb_log_buffer_size=8M'
>             ResetSearch 1
>             LocateLineMatching '^innodb_flush_log_at_trx_commit.*'
>             ReplaceLineWith 'innodb_flush_log_at_trx_commit = 1'
>             ResetSearch 1
>             LocateLineMatching '.*innodb_lock_wait_timeout.*'
>             ReplaceLineWith 'set-variable = innodb_lock_wait_timeout=50'
>             ResetSearch 1
>             LocateLineMatching '^default-table-type.*'
>             ReplaceLineWith 'default-table-type = innodb'
>             ResetSearch 1
>             LocateLineMatching '^safe-show-database.*'
>             ReplaceLineWith 'safe-show-database'
>             ResetSearch 1
>             LocateLineMatching '.*safe-user-create.*'
>             ReplaceLineWith 'safe-user-create'
>             ResetSearch 1
>           LocateLineMatching '^bind-address =.*'
>           ReplaceLineWith 'bind-address = ${mysql_bind_address}'
>           ResetSearch 1
> 
>             # set the maximum number of connections per user
>             BeginGroupIfNoLineMatching '^set-variable = 
> max_user_connections=.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'set-variable = max_user_connections='
>             EndGroup
>             ResetSearch 1
>             LocateLineMatching '^set-variable = max_user_connections=.*'
>             BeginGroupIfNoMatch '^set-variable = 
> max_user_connections=${mysql_max_user_connections}'
>                 ReplaceLineWith 'set-variable = 
> max_user_connections=${mysql_max_user_connections}'
>             EndGroup
> 
>           ResetSearch 1
>             # set the maximum number of connections to the server in total
>             BeginGroupIfNoLineMatching '^set-variable = max_connections=.*'
>                 LocateLineMatching '^\[mysqld\]'
>                 InsertLine 'set-variable = max_connections='
>             EndGroup
>             ResetSearch 1
>             LocateLineMatching '^set-variable = max_connections=.*'
>             BeginGroupIfNoMatch '^set-variable = max_connections=512'
>                 ReplaceLineWith 'set-variable = max_connections=512'
>             EndGroup
> 
>             DefineClasses 'mysql_restart'
>         }
> 
> directories:
> 
>     mysql_server::
> 
>         /var/lib/mysqlbackup
>             mode=0750
>             o=root
>             g=root
> 
> copy:
> 
>     mysql_server::
> 
>         $(copysrc)/usr/local/sbin/db-export-mysql
>             dest=/usr/local/sbin/db-export-mysql
>             mode=0755
>             type=checksum
>             timestamp=keep
>             stealth=on
>             backup=false
> 
>         $(copysrc)/etc/cron.d/db-export-mysql
>             dest=/etc/cron.d/db-export-mysql
>             mode=0600
>             type=checksum
>             timestamp=keep
>             stealth=on
>             backup=false
> 
> processes:
> 
>     mysql_server.redhat::
> 
>         "mysqld"
>             restart "/sbin/service mysqld restart"
>             elsedefine=mysql_chkconfig
> 
> shellcommands:
> 
>     mysql_restart::
> 
>         # redhat 8.0's mysql init script is broken -- it doesn't wait
>         # for the database to shutdown before starting it again for a 
> "restart"
>         "/sbin/service mysqld stop; /bin/sleep 10; /sbin/service mysqld start"
>             useshell=true
> 
>     mysql_chkconfig.redhat::
> 
>         "/sbin/chkconfig mysqld on" useshell=false

> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-cfengine





reply via email to

[Prev in Thread] Current Thread [Next in Thread]