ostype => {
optional => 1,
type => 'string',
- enum => ['debian', 'ubuntu', 'centos', 'fedora', 'opensuse', 'archlinux', 'alpine'],
- description => "OS type. Corresponds to lxc setup scripts in /usr/share/lxc/config/<ostype>.common.conf.",
+ enum => ['debian', 'ubuntu', 'centos', 'fedora', 'opensuse', 'archlinux', 'alpine', 'unmanaged'],
+ description => "OS type. This is used to setup configuration inside the container, and corresponds to lxc setup scripts in /usr/share/lxc/config/<ostype>.common.conf. Value 'unmanaged' can be used to skip and OS specific setup.",
},
console => {
optional => 1,
my $custom_idmap = grep { $_->[0] eq 'lxc.id_map' } @{$conf->{lxc}};
my $ostype = $conf->{ostype} || die "missing 'ostype' - internal error";
- if ($ostype =~ /^(?:debian | ubuntu | centos | fedora | opensuse | archlinux | alpine)$/x) {
+ if ($ostype =~ /^(?:debian | ubuntu | centos | fedora | opensuse | archlinux | alpine | unmanaged)$/x) {
my $inc ="/usr/share/lxc/config/$ostype.common.conf";
$inc ="/usr/share/lxc/config/common.conf" if !-f $inc;
$raw .= "lxc.include = $inc\n";
$used_volids->{$mp->{volume}} = 1;
} elsif ($opt eq 'unprivileged') {
die "unable to modify read-only option: '$opt'\n";
+ } elsif ($opt eq 'ostype') {
+ next if $hotplug_error->($opt);
+ $conf->{$opt} = $value;
} else {
die "implement me: $opt";
}
my $self = bless { conf => $conf, rootdir => $rootdir};
- if (!defined($type)) {
+ if ($conf->{ostype} && $conf->{ostype} eq 'unmanaged') {
+ return $self;
+ } elsif (!defined($type)) {
# try to autodetect type
$type = &$autodetect_type($rootdir);
+ my $expected_type = $conf->{ostype} || $type;
+
+ die "got unexpected ostype ($type != $expected_type)\n"
+ if $type ne $expected_type;
}
-
+
my $plugin_class = $plugins->{$type} ||
"no such OS type '$type'\n";
sub protected_call {
my ($self, $sub) = @_;
+ die "internal error" if !$self->{plugin};
+
# avoid recursion:
return $sub->() if $self->{in_chroot};
sub template_fixup {
my ($self) = @_;
+ return if !$self->{plugin}; # unmanaged
+
my $code = sub {
$self->{plugin}->template_fixup($self->{conf});
};
sub setup_network {
my ($self) = @_;
+ return if !$self->{plugin}; # unmanaged
+
my $code = sub {
$self->{plugin}->setup_network($self->{conf});
};
sub set_hostname {
my ($self) = @_;
+ return if !$self->{plugin}; # unmanaged
+
my $code = sub {
$self->{plugin}->set_hostname($self->{conf});
};
sub set_dns {
my ($self) = @_;
+ return if !$self->{plugin}; # unmanaged
+
my $code = sub {
$self->{plugin}->set_dns($self->{conf});
};
sub setup_init {
my ($self) = @_;
+ return if !$self->{plugin}; # unmanaged
+
my $code = sub {
$self->{plugin}->setup_init($self->{conf});
};
sub set_user_password {
my ($self, $user, $pw) = @_;
-
+
+ return if !$self->{plugin}; # unmanaged
+
my $code = sub {
$self->{plugin}->set_user_password($self->{conf}, $user, $pw);
};
sub rewrite_ssh_host_keys {
my ($self) = @_;
+ return if !$self->{plugin}; # unmanaged
+
my $conf = $self->{conf};
my $plugin = $self->{plugin};
my $rootdir = $self->{rootdir};
sub pre_start_hook {
my ($self) = @_;
+ return if !$self->{plugin}; # unmanaged
+
my $code = sub {
# Create /fastboot to skip run fsck
$self->{plugin}->ct_file_set_contents('/fastboot', '');
sub post_create_hook {
my ($self, $root_password) = @_;
+ return if !$self->{plugin}; # unmanaged
+
my $code = sub {
$self->{plugin}->post_create_hook($self->{conf}, $root_password);
};