diff options
Diffstat (limited to 'zarb-ml/mageia-dev/2012-July/017450.html')
-rw-r--r-- | zarb-ml/mageia-dev/2012-July/017450.html | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/zarb-ml/mageia-dev/2012-July/017450.html b/zarb-ml/mageia-dev/2012-July/017450.html new file mode 100644 index 000000000..7f15b9727 --- /dev/null +++ b/zarb-ml/mageia-dev/2012-July/017450.html @@ -0,0 +1,160 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<HTML> + <HEAD> + <TITLE> [Mageia-dev] puppet and the urpmi config + </TITLE> + <LINK REL="Index" HREF="index.html" > + <LINK REL="made" HREF="mailto:mageia-dev%40mageia.org?Subject=Re%3A%20%5BMageia-dev%5D%20puppet%20and%20the%20urpmi%20config&In-Reply-To=%3C20120718122906.GW3708%40virgo.home.nanardon.zarb.org%3E"> + <META NAME="robots" CONTENT="index,nofollow"> + <META http-equiv="Content-Type" content="text/html; charset=us-ascii"> + <LINK REL="Previous" HREF="017466.html"> + <LINK REL="Next" HREF="017457.html"> + </HEAD> + <BODY BGCOLOR="#ffffff"> + <H1>[Mageia-dev] puppet and the urpmi config</H1> + <B>Olivier Thauvin</B> + <A HREF="mailto:mageia-dev%40mageia.org?Subject=Re%3A%20%5BMageia-dev%5D%20puppet%20and%20the%20urpmi%20config&In-Reply-To=%3C20120718122906.GW3708%40virgo.home.nanardon.zarb.org%3E" + TITLE="[Mageia-dev] puppet and the urpmi config">nanardon at nanardon.zarb.org + </A><BR> + <I>Wed Jul 18 14:29:06 CEST 2012</I> + <P><UL> + <LI>Previous message: <A HREF="017466.html">[Mageia-dev] LSI Logic Megaraid SAS not supported with install dvd +</A></li> + <LI>Next message: <A HREF="017457.html">[Mageia-dev] puppet and the urpmi config +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#17450">[ date ]</a> + <a href="thread.html#17450">[ thread ]</a> + <a href="subject.html#17450">[ subject ]</a> + <a href="author.html#17450">[ author ]</a> + </LI> + </UL> + <HR> +<!--beginarticle--> +<PRE>Hello, + +As sys admin I use puppet to push config to servers. + +It is very simple, puppet detect a file is not the same than the +reference, copy the file, restart the daemon or trigger a command if +need. + +Here come urpmi, can you push by force the urpmi.cfg and make it work +using some --force and --do-it-even-it-is-really-not-clean but each time +an urpmi command is called the config file written again. + +Then the file is changed, making puppet updating the urpmi.cfg again and +again. + +To avoid this problem I wrote the attached script: it take as argument +the path to an urpmi.cfg and synchronize the config found with the real +urpmi.cfg. +- removed media are removed properly +- the media.cfg used as template is unchanged +- urpmi.update is called to update the index +- urpmi base is locked to avoid race condition + +In cases this can be usefull. + +Ideas and patches welcome. + +-- + +Olivier Thauvin +CNRS - LATMOS +♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖ +-------------- next part -------------- +#!/usr/bin/perl + +use strict; +use warnings; +use urpm; +use urpm::cfg; +use urpm::media; +use urpm::args; +use urpm::download; +use Getopt::Long; +use Pod::Usage; + +GetOptions( + help => sub { pod2usage() }, +);# or pod2sage(1); + +my ($config) = @ARGV; + +my $template = urpm::cfg::load_config($config); + +{ +my $urpm = urpm->new_parse_cmdline or exit(1); + +my $_urpmi_lock = urpm::lock::urpmi_db( + $urpm, + 'exclusive', + wait => 1, +); + +urpm::media::read_config($urpm); + +my %media_to_update = (); + +foreach my $medium (@{ $urpm->{media} || [] }) { + my ($tlpmedia) = (grep { $_->{name} eq $medium->{name} } + @{ $template->{media} || [] }); + if (! $tlpmedia) { + my @selected = urpm::media::select_media_by_name($urpm, [ $medium->{name} ], + !$urpm->{options}{fuzzy}); + urpm::media::remove_media($urpm, \@selected); + } else { + %{ $medium } = (); + %{ $medium } = %{ $tlpmedia }; + } +} +foreach my $medium (@{ $template->{media} || [] }) { + if (!grep { $_->{name} eq $medium->{name} } + (@{ $urpm->{media} || [] })) { + push(@{ $urpm->{media} }, $medium); + } +} + +$urpm->{modified} = 1; +urpm::media::write_config($urpm); + +} +system('/usr/sbin/urpmi.update', '-a', '-q'); +-------------- next part -------------- +A non-text attachment was scrubbed... +Name: not available +Type: application/pgp-signature +Size: 197 bytes +Desc: not available +URL: </pipermail/mageia-dev/attachments/20120718/16773ec7/attachment.asc> +</PRE> + + + + + + + + + +<!--endarticle--> + <HR> + <P><UL> + <!--threads--> + <LI>Previous message: <A HREF="017466.html">[Mageia-dev] LSI Logic Megaraid SAS not supported with install dvd +</A></li> + <LI>Next message: <A HREF="017457.html">[Mageia-dev] puppet and the urpmi config +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#17450">[ date ]</a> + <a href="thread.html#17450">[ thread ]</a> + <a href="subject.html#17450">[ subject ]</a> + <a href="author.html#17450">[ author ]</a> + </LI> + </UL> + +<hr> +<a href="https://www.mageia.org/mailman/listinfo/mageia-dev">More information about the Mageia-dev +mailing list</a><br> +</body></html> |