Skip to content

Instantly share code, notes, and snippets.

View raphink's full-sized avatar
🐝
eBPF everything!

Raphaël Pinson raphink

🐝
eBPF everything!
View GitHub Profile
augeas {
'Add line if missing':
context => '/files/myfile',
changes => 'set 01 "subversion-1.6"',
onlyif => 'match *[. =~ regex("^subversion-")] size == 0';
'Update line if present':
context => '/files/myfile',
changes => 'set *[. =~ regex("^subversion-")] "subversion-1.6"',
require => Augeas['Add line if missing'];
#!/usr/bin/augtool -Asf
# Loaded with -A, add association now
set /augeas/load/Pg_Hba/lens Pg_Hba.lns
set /augeas/load/Pg_Hba/incl /etc/postgresql/9.1/main/pg_hba.conf
load
# Make sure file exists
defnode file /files/etc/postgresql/9.1/main/pg_hba.conf
$ rspec --color spec/unit/puppet/apache_setenv_spec.rb
....FF.
Failures:
1) Puppet::Type::Apache_setenv::ProviderAugeas with simple file when update existing should update existing
Failure/Error: ))
expected: []
got: [wrong number of arguments (2 for 0), change from test.com to test2.com failed: wrong number of arguments (2 for 0)] (using ==)
Diff:
# Define a method using augopen
#
# @param [Symbol] meth the name of the method to create
# @yield [aug] block that uses the Augeas handle
# @yieldparam [Augeas] aug open Augeas handle
# @api public
def define_augmethod(meth, &block)
define_method(meth) do
instance_exec augopen, &block
end
@raphink
raphink / augeas.rb
Last active December 19, 2015 22:39
lens { 'Shells.lns' }
resource_path { |r| "$target/*[.='#{r[:name]}']" }
# exists? is automatic
# destroy is automatic
def create
augopen! { |aug| aug.set('$target/01', resource[:name]) }
end
1.8.7-p371 :001 > target = '/files/etc/toto'
=> "/files/etc/toto"
1.8.7-p371 :002 > spath = '/files/etc/toto/truc/IfModule[3]/directive[6]'
=> "/files/etc/toto/truc/IfModule[3]/directive[6]"
1.8.7-p371 :003 > spath.slice(target.length+1..-1).sub(/(.*)\/directive(?:\[\d+\])?/, '\1')
=> "truc/IfModule[3]"
positionable do
def insync?(is)
# define sync
end
end
@raphink
raphink / gist:5853347
Created June 24, 2013 20:30
Augeas lens debug note
<lutter> hmm .. ok; I just put a 'let _ = (print_regexp (lens_ctype values) ); print_endline ""' in there
<lutter> and get
<lutter> /([^\n;]|[^\n ];|;[^\n ])*( ; ([^\n;]|[^\n ];|;[^\n ])*)*/
module Mechanicalduck =
let values =
(* semicolons are allowed if they are not preceded or followed by a space *)
let allowed_semicolon = /[^\n ];/ | /;[^\n ]/
(* anything but a semicolon or a newline *)
in let no_semicolon = /[^\n;]/
(* values can be either no_semicolon or allowed_semicolon *)
in let val_re = (no_semicolon | allowed_semicolon)*
(* a value is a seq entry that stores a val_re *)
drush site-install standard --account-pass='MDRHFD' -l default --yes
You are about to DROP all tables in your 'drupal' database. Do you want to continue? (y/n): y
No tables to drop. [ok]
Starting Drupal installation. This takes a few seconds ... [ok]
WD php: Exception: To start over, you must empty your existing database.To install to a different database, edit the appropriate [error]
settings.php file in the sites folder.To upgrade an existing installation, proceed to the update script.View your existing site.
in install_begin_request() (line 301 of /var/www/pref63_risques-majeurs/htdocs/drupal/includes/install.core.inc).
Cannot modify header information - headers already sent by (output started at /usr/local/share/drush/includes/output.inc:37) [warning]
bootstrap.inc:1212
Exception: <ul><li>To start over, you must empty y