Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let aii generate ansible playbook for supported components #331

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f62ee82
core: Shellfe: cleanup
stdweird Apr 26, 2018
91c9c62
Shellfe: set active config before running the plugin method
stdweird Sep 21, 2016
963ac1f
ks: ksuserhooks: set active config before running the hook method
stdweird Sep 22, 2016
f1f22a1
aii-ks: fix some more regex tests after new nmc-lib-blockdevices
stdweird Aug 7, 2020
e685e9c
aii-ks: factor out proxy url modification
stdweird Nov 5, 2019
57279c4
aii-ks: factor out repository proxy and baseurl modification
stdweird Nov 5, 2019
7fa0409
aii-ks: generate the kickstart repo command from the SPMA repository …
stdweird Nov 6, 2019
111240b
aii-ks: do not install kernel debug rpms in post
stdweird Nov 18, 2019
9b486e1
aii-pxelinux: fix panlint line too long in schema
stdweird Nov 21, 2019
db9578a
aii-ks: switch to globs for repository selection and some more code c…
stdweird Aug 7, 2020
1f0788f
aii-ks: allow finegrained enable/disable/ignore control when generati…
stdweird Aug 7, 2020
669c13e
aii-ks: generalise the glob pattern used by repo selection and also e…
stdweird Aug 14, 2020
b1b6c25
aii-pxelinux: fix bug when calling _kernel_params with correct varian…
stdweird Aug 14, 2020
2da99b8
aii-pxelinux: add globbing to the pxelinux initrd and kernel paths
stdweird Aug 14, 2020
3928f1c
aii-ks: handle disabled/ignored packages in post too
stdweird Aug 18, 2020
eb9c80a
aii-ks: add boolean to control installation of (exact) kernel package…
stdweird Aug 18, 2020
a5733f0
aii-ks: only root access to /tmp yum and log files
stdweird Aug 19, 2020
e0bf6b6
aii-pxelinux: Fix UEFI boot over http
stdweird Mar 16, 2021
b31044b
pxelinux: support hostname lookup for EFI
stdweird Apr 14, 2021
bd1d314
aii-core: support changing plugin modulename
stdweird Jul 1, 2021
585f48c
aii-ks: add kickstart_post_script plugin module to generate the post …
stdweird Jul 1, 2021
f5e7727
aii-ks: ks_post_script: generate the repos first
stdweird Aug 5, 2021
056468b
aii-ks: for kickstart as script, run ks-post-install in "post"
stdweird Sep 22, 2021
749d956
aii-ks: fix permission of ks-post-reboot script
stdweird Sep 24, 2021
fca85b0
aii-core: add ansible command
stdweird Oct 20, 2021
90c968f
aii-core: add ansible playbook, role and task module
stdweird Oct 20, 2021
539923d
aii-core: add more ansible tests
stdweird Oct 21, 2021
ace5b1b
aii-core: ansible task: support passing data on task creation
stdweird Oct 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
aii-ks: generate the kickstart repo command from the SPMA repository …
…configuration
stdweird committed Jul 1, 2021
commit 7fa040918c31454fbbfce6b4217dd666f0a9c609
3 changes: 3 additions & 0 deletions aii-ks/src/main/pan/quattor/aii/ks/schema.pan
Original file line number Diff line number Diff line change
@@ -108,6 +108,9 @@ type structure_ks_ks_info = {
"pre_install_script" ? type_absoluteURI
"post_install_script" ? type_absoluteURI
"post_reboot_script" ? type_absoluteURI
@{List of repositories (string in exact kickstart repo command syntax).
If a string starts with a '@', the repository is generated based on
the SPMA repositories with name(s) matching this pattern (without the leading '@').}
"repo" ? string[]
"timezone" : string
@{NTP servers used by Anaconda}
42 changes: 28 additions & 14 deletions aii-ks/src/main/perl/ks.pm
Original file line number Diff line number Diff line change
@@ -434,12 +434,31 @@ timezone --utc $tree->{timezone}$ntp_servers
rootpw --iscrypted $tree->{rootpw}
EOF

my $repos = get_repos($config);
# error reported in get_repos
return if ! $repos;

foreach my $url (@{$tree->{repo} || []}) {
if ($url =~ m/^@(.+)$/) {
# find at least one repo with matching name
my $pattern = $1;
my @matches = grep {m/$pattern/} sort keys %$repos;
if (@matches) {
foreach my $reponame (@matches) {
print "repo";
foreach my $key (qw(name baseurl proxy includepkgs excludepkgs)) {
my $val = $repos->{$reponame}->{$key};
print " --$key=". (ref($val) eq 'ARRAY' ? join(',', @$val) : $val) if defined($val);
}
print "\n";
}
} else {
$this_app->error("kickstart repo: no spma repositories that match $pattern");
}
} else {
$url = proxy_url($proxy_config, $url);
print "repo $url\n";
}
print "repo $url\n";
}

if ($tree->{cmdline}) {
@@ -549,8 +568,7 @@ EOF
print "\n";
print $version >= ANACONDA_VERSION_EL_6_0 ? '%end' : '', "\n";

return $unprocessed_packages;

return $unprocessed_packages, $repos;
}

# Writes the mountpoint definitions and LVM and MD settings
@@ -639,9 +657,9 @@ EOF
# ends with the %postconfig section
ksuserhooks ($config, ANACONDAHOOK);

my $packages = kscommands ($config);
my ($packages, $repos) = kscommands ($config);

return $packages;
return $packages, $repos;
}

# Create the action to be taken on the log files
@@ -1378,7 +1396,7 @@ sub get_repos

sub yum_setup
{
my ($self, $config) = @_;
my ($self, $config, $repos) = @_;

$self->debug(5, "Configuring YUM repositories...");

@@ -1388,10 +1406,6 @@ sub yum_setup
$obsoletes = $config->getElement (SPMA_OBSOLETES)->getTree();
}

my $repos = get_repos($config);
# error reported in get_repos
return if ! $repos;

my $extra_yum_opts = {};
if ( $config->elementExists(SPMA_YUMCONF) ) {
$extra_yum_opts = $config->getElement (SPMA_YUMCONF)->getTree();
@@ -1583,7 +1597,7 @@ EOF
# this method.
sub post_install_script
{
my ($self, $config, $packages) = @_;
my ($self, $config, $packages, $repos) = @_;

my $tree = $config->getElement (KS)->getTree;
my $version = get_anaconda_version($tree);
@@ -1626,7 +1640,7 @@ EOF
print "\n# Disable selinux via kernel parameter\ngrubby --update-kernel=DEFAULT --args=selinux=0\n";
};

$self->yum_setup ($config);
$self->yum_setup ($config, $repos);
$self->yum_install_packages ($config, $packages);
ksuserscript ($config, POSTSCRIPT);

@@ -1807,9 +1821,9 @@ sub Configure
}

$self->ksopen ($config);
my $packages = $self->install ($config);
my ($packages, $repos) = $self->install ($config);
$self->pre_install_script ($config);
$self->post_install_script ($config, $packages);
$self->post_install_script ($config, $packages, $repos);
$self->ksclose;
return 1;
}
3 changes: 3 additions & 0 deletions aii-ks/src/test/perl/kickstart_commands.t
Original file line number Diff line number Diff line change
@@ -39,6 +39,9 @@ like($fh, qr{^firewall\s--disabled }m, 'firwewall disabled present');
like($fh, qr{^network\s--bootproto=dhcp}m, 'network dhcp present');
like($fh, qr{^zerombr$}m, 'zerombr present');
like($fh, qr{^services\s--disabled=disable1,DISABLE2\s--enabled=enable1,ENABLE2}m, "--dis/enable services present");
like($fh, qr{^repo someurl}m, "repo as string");
like($fh, qr{^repo --name=repo1 --baseurl=http://www.example.com --includepkgs=everything,else --excludepkgs=woo,hoo\*}m, "repo from pattern");
unlike($fh, qr{^repo --name=repo0}m, "repo from pattern did not match other repo");

like($fh, qr{^%packages\s--ignoremissing\s--resolvedeps\n^package\n^package2\nbind-utils\n}m, 'packages present');

2 changes: 1 addition & 1 deletion aii-ks/src/test/perl/kickstart_packagesinpost.t
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ select($fh);
my $ks = NCM::Component::ks->new('ks');
my $cfg = get_config_for_profile('kickstart_packagesinpost');

my $packref = NCM::Component::ks::kscommands($cfg);
my ($packref, $repos) = NCM::Component::ks::kscommands($cfg);
like($fh, qr{^%packages --ignoremissing --resolvedeps\n-notthispackage\n%end}m, "Only disabled packages in packages section");
unlike($fh, qr{package2}, "No package2 in commands"); # one of the packages
unlike($fh, qr{bind-utils}, "No bind-utils in commands"); # one of the auto-added packages
4 changes: 3 additions & 1 deletion aii-ks/src/test/perl/kickstart_yum_setup.t
Original file line number Diff line number Diff line change
@@ -25,7 +25,9 @@ select($fh);
my $ks = NCM::Component::ks->new('ks');
my $cfg = get_config_for_profile('kickstart_yum_setup');

NCM::Component::ks::yum_setup($ks, $cfg);
my $repos = NCM::Component::ks::get_repos($cfg);

NCM::Component::ks::yum_setup($ks, $cfg, $repos);

diag "$fh";

21 changes: 21 additions & 0 deletions aii-ks/src/test/resources/kickstart.pan
Original file line number Diff line number Diff line change
@@ -21,6 +21,27 @@ prefix "/software/packages";
"{ncm-spma}/{14.2.1-1}/arch/noarch" = "";
"{kernel-module-foo}" = nlist();

prefix "/software/repositories/0";
"name" = "repo0";
"owner" = "me@example.com";
"protocols/0/name" = "http";
"protocols/0/url" = "http://www.example.com";
"gpgcheck" = false;
"repo_gpgcheck" = false;
"gpgkey" = list(
"file:///path/to/key",
"https://somewhere/very/very/far",
"ftp://because/ftp/and/security/go/well/together",
);
"gpgcakey" = "file:///super/ca/key";

prefix "/software/repositories/1";
"name" = "repo1";
"owner" = "me@example.com";
"protocols/0/name" = "http";
"protocols/0/url" = "http://www.example.com";
"excludepkgs" = list('woo', 'hoo*');
"includepkgs" = list('everything', 'else');

# pxelinux and kickstart couple if bootproto is not dhcp
prefix "/system/aii/nbp/pxelinux";
10 changes: 5 additions & 5 deletions aii-ks/src/test/resources/kickstart_bonding.pan
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@{
Profile to test kickstart bonding configuration
@{
Profile to test kickstart bonding configuration
@}
object template kickstart_bonding;

include 'kickstart';

prefix "/system/network";
prefix "/system/network";
"interfaces/bond0/ip" = "1.2.3.0";
"interfaces/bond0/netmask" = "255.255.255.0";
"interfaces/bond0/bonding_opts" = nlist(
@@ -23,6 +23,6 @@ prefix "/system/network";
);

prefix "/system/aii/osinstall/ks";
"bootproto" = "static";
"bootproto" = "static";
"version" = "13.21";
"bonding" = true;
"bonding" = true;
3 changes: 3 additions & 0 deletions aii-ks/src/test/resources/kickstart_commands.pan
Original file line number Diff line number Diff line change
@@ -5,3 +5,6 @@ object template kickstart_commands;

include 'kickstart';

prefix "/system/aii/osinstall/ks";
"repo/0" = "someurl";
"repo/1" = "@po1"; # should match repo1, not repo0
22 changes: 0 additions & 22 deletions aii-ks/src/test/resources/kickstart_yum_setup.pan
Original file line number Diff line number Diff line change
@@ -5,28 +5,6 @@ object template kickstart_yum_setup;

include 'kickstart';

prefix "/software/repositories/0";
"name" = "repo0";
"owner" = "me@example.com";
"protocols/0/name" = "http";
"protocols/0/url" = "http://www.example.com";
"gpgcheck" = false;
"repo_gpgcheck" = false;
"gpgkey" = list(
"file:///path/to/key",
"https://somewhere/very/very/far",
"ftp://because/ftp/and/security/go/well/together",
);
"gpgcakey" = "file:///super/ca/key";

prefix "/software/repositories/1";
"name" = "repo1";
"owner" = "me@example.com";
"protocols/0/name" = "http";
"protocols/0/url" = "http://www.example.com";
"excludepkgs" = list('woo', 'hoo*');
"includepkgs" = list('everything', 'else');

prefix "/software/components/spma/main_options";
"exclude" = list("a", "b");
"retries" = 40;