Convert configuration channels to Ansible in RedHat Satellite 6.x

Latest response

Greetings,

I have an older Satellite 5.x and I am testing the transition to 6.x.

I would like to convert, reprogram my old Configuration channels from 5.x to Ansible files.

What would you recommend to be used and done?

Some guideliness.

Kind regards.

Zeljko

Responses

This is just to give this thread a bump. This perl code is a way to capture everything (I think) that you have configured. You will need to populate the $hostname (satellite), $user (satellite user), and $pass (password) for your environment.

#!/usr/bin/perl
use strict;
use Frontier::Client;
use Data::Dumper;

my $hostname = `hostname`;
chomp($hostname);
my $HOST = "$hostname";
my $user = '';
my @paths = ();
my $pass = "";

my $client = new Frontier::Client(url => "http://$HOST/rpc/api");
my $session = $client->call('auth.login',$user, $pass);

my $systems = $client->call('system.listUserSystems', $session);
foreach my $system (@$systems) {
    print $system->{'name'}."\n";
    my $channels = $client->call('system.config.listChannels', $session, $system->{'id'});
    foreach my $channel (@$channels) {
        print "\t$channel->{'label'}\n";
        my $files = $client->call('configchannel.listFiles', $session, $channel->{'label'});
        @paths = ();
        foreach my $file (@$files) {
            push (@paths, $file->{'path'});
        }
        my $fileinfo = $client->call('configchannel.lookupFileInfo', $session, $channel->{'label'}, \@paths);
        print Dumper($fileinfo);
    }
}
$client->call('auth.logout', $session);

This script will dump out a data structure that will iterate for the latest version of all files in all configuration channels (sorted by ranking) on a given machine

machine name
        config-channel-label
$VAR1 = [
          {
            'permissions' => '600',
            'contents' => 'root
thisuser
thatuser
',
            'channel' => 'ACN_Global_Config',
            'contents_enc64' => bless( do{\(my $o = '0')}, 'Frontier::RPC2::Boolean' ),
            'group' => 'root',
            'macro-start-delimiter' => '{|',
            'owner' => 'root',
            'binary' => bless( do{\(my $o = '0')}, 'Frontier::RPC2::Boolean' ),
            'path' => '/etc/cron.allow',
            'permissions_mode' => '600',
            'modified' => bless( do{\(my $o = '20130411T20:24:59')}, 'Frontier::RPC2::DateTime::ISO8601' ),
            'revision' => '2',
            'sha256' => '4377c1c0ee1fe02861f80ac1580870ae',
            'macro-end-delimiter' => '|}',
            'type' => 'file',
            'creation' => bless( do{\(my $o = '20130411T20:24:59')}, 'Frontier::RPC2::DateTime::ISO8601' )
          },

So I would like to think that all the information that you would need to write the correct ansible playbook ought to be at your fingertips. Use only the first occurrence of any given path name as the hierarchy is sorted to preference of channels. Maybe someone else with more ansible training can continue the conversation.

Hi Terry,

Thanks for your fast response. I wanted to try out the script but I am getting the error:500 Can't connect to :443 (Bad hostname '') My satellite Server is 5.6 version. I am using https but the certificate is internal and so it shows in the browser as insecure. When I do a curl with insecure I connect locally on the server but it points me to the context rhn/apidoc/index.jsp when I try the /rpc/api I get the docs in the browser. Port 80 and http is turned off on the server.

Are there maybe some parameters for the Frontier::Client; library to deal with this. I am myself more a python person , maybe there is a python alternative to this script.

Thanks in advance.

Zeljko

It certainly can be written in python but don't know that I have a version that particular algorithm available in python. Bad hostname would indicate that if you are running it on a box other than the satellite and you are running it as I wrote it, it just backticks the value of the current hostname into the variable. Try putting the value of the satellite's hostname on the right hand side of the $HOST = equation.

HI Terry,

Thanks for your help. Now with the $HOST the scripts works. But I get so much data that the file grows over 500 MB and it is unusable anymore. Is there a possibility to maybe split the work in smaller chunks, for example channel based or something similar?

Thanks in advance.

Zeljko