From 9eb232d53182644f50a286013d2be2b04bd0d47a Mon Sep 17 00:00:00 2001 From: maximenoel8 <55169628+maximenoel8@users.noreply.github.com> Date: Fri, 22 Jul 2022 10:06:59 +1200 Subject: [PATCH] Migration test support aws (#1126) remove some SCC modules for minion for an easier migration test fix install_salt_bundle declaration in host/main.tf create SCC to support build_host module add sles15sp4 to image declaration --- backend_modules/aws/base/main.tf | 22 ++++++++++++++++++++++ backend_modules/aws/host/main.tf | 1 + modules/build_host/main.tf | 1 + modules/build_host/variables.tf | 5 +++++ salt/build_host/init.sls | 3 +++ salt/client/testsuite.sls | 1 - salt/default/testsuite.sls | 1 + salt/repos/build_host.sls | 2 +- salt/scc/build_host.sls | 23 +++++++++++++++++++++++ salt/scc/init.sls | 2 ++ salt/scc/minion.sls | 14 +------------- 11 files changed, 60 insertions(+), 15 deletions(-) create mode 100644 salt/scc/build_host.sls create mode 100644 salt/scc/init.sls diff --git a/backend_modules/aws/base/main.tf b/backend_modules/aws/base/main.tf index 717b85a82..da734994c 100644 --- a/backend_modules/aws/base/main.tf +++ b/backend_modules/aws/base/main.tf @@ -145,6 +145,27 @@ data "aws_ami" "sles15sp3o" { } } +data "aws_ami" "sles15sp4o" { + most_recent = true + name_regex = "^suse-sles-15-sp4-byos-v" + owners = ["013907871322"] + + filter { + name = "architecture" + values = ["x86_64"] + } + + filter { + name = "virtualization-type" + values = ["hvm"] + } + + filter { + name = "root-device-type" + values = ["ebs"] + } +} + data "aws_ami" "sles12sp5" { most_recent = true name_regex = "^suse-sles-12-sp5-byos-v" @@ -415,6 +436,7 @@ locals { sles15sp1o = { ami = data.aws_ami.sles15sp1o.image_id }, sles15sp2o = { ami = data.aws_ami.sles15sp2o.image_id }, sles15sp3o = { ami = data.aws_ami.sles15sp3o.image_id }, + sles15sp4o = { ami = data.aws_ami.sles15sp4o.image_id }, sles12sp5 = { ami = data.aws_ami.sles12sp5.image_id }, sles12sp4 = { ami = data.aws_ami.sles12sp4.image_id }, sles12sp3 = { ami = data.aws_ami.sles12sp3.image_id }, diff --git a/backend_modules/aws/host/main.tf b/backend_modules/aws/host/main.tf index 191da00b7..3c25b78b7 100644 --- a/backend_modules/aws/host/main.tf +++ b/backend_modules/aws/host/main.tf @@ -203,6 +203,7 @@ resource "null_resource" "host_salt_configuration" { additional_repos_only = var.additional_repos_only additional_certs = var.additional_certs additional_packages = var.additional_packages + install_salt_bundle = var.install_salt_bundle swap_file_size = var.swap_file_size authorized_keys = concat( var.base_configuration["ssh_key_path"] != null ? [trimspace(file(var.base_configuration["ssh_key_path"]))] : [], diff --git a/modules/build_host/main.tf b/modules/build_host/main.tf index 2412933db..f34250e84 100644 --- a/modules/build_host/main.tf +++ b/modules/build_host/main.tf @@ -24,6 +24,7 @@ module "build_host" { server = var.server_configuration["hostname"] auto_connect_to_master = var.auto_connect_to_master avahi_reflector = var.avahi_reflector + sles_registration_code = var.sles_registration_code } diff --git a/modules/build_host/variables.tf b/modules/build_host/variables.tf index d764a28a0..7f179d44f 100644 --- a/modules/build_host/variables.tf +++ b/modules/build_host/variables.tf @@ -113,3 +113,8 @@ variable "provider_settings" { description = "Map of provider-specific settings, see the modules/libvirt/README.md" default = {} } + +variable "sles_registration_code" { + description = "SUMA SCC registration code to enable the SLES server" + default = null +} diff --git a/salt/build_host/init.sls b/salt/build_host/init.sls index efc396f60..e19f61a4f 100644 --- a/salt/build_host/init.sls +++ b/salt/build_host/init.sls @@ -1,3 +1,6 @@ +include: + - scc.build_host + certificate_authority_certificate: file.managed: - name: /etc/pki/trust/anchors/ca.cert.pem diff --git a/salt/client/testsuite.sls b/salt/client/testsuite.sls index dacff5c7e..cf13fa38b 100644 --- a/salt/client/testsuite.sls +++ b/salt/client/testsuite.sls @@ -1,7 +1,6 @@ {% if grains.get('testsuite') | default(false, true) %} include: - - scc.minion - repos - client diff --git a/salt/default/testsuite.sls b/salt/default/testsuite.sls index 45a2fd157..238d9c0e8 100644 --- a/salt/default/testsuite.sls +++ b/salt/default/testsuite.sls @@ -2,6 +2,7 @@ {% if 'client' in grains.get('roles') or 'minion' in grains.get('roles') or 'sshminion' in grains.get('roles') %} include: + - scc - repos {% if grains['os'] == 'SUSE' %} diff --git a/salt/repos/build_host.sls b/salt/repos/build_host.sls index 966b65847..071c908eb 100644 --- a/salt/repos/build_host.sls +++ b/salt/repos/build_host.sls @@ -1,4 +1,4 @@ -{% if 'build_host' in grains.get('roles') and grains.get('testsuite') | default(false, true) and grains['osfullname'] == 'SLES' %} +{% if 'build_host' in grains.get('roles') and grains.get('testsuite') | default(false, true) and grains['osfullname'] == 'SLES' and not grains.get('sles_registration_code')%} {% if '12' in grains['osrelease'] %} containers_pool_repo: diff --git a/salt/scc/build_host.sls b/salt/scc/build_host.sls new file mode 100644 index 000000000..e7c557ff5 --- /dev/null +++ b/salt/scc/build_host.sls @@ -0,0 +1,23 @@ +{% if 'build_host' in grains.get('roles') and grains.get('sles_registration_code') and '15' in grains['osrelease'] %} + +register_sles_server: + cmd.run: + - name: SUSEConnect --url https://scc.suse.com -r {{ grains.get("sles_registration_code") }} + +basesystem_activation: + cmd.run: + - name: SUSEConnect -p sle-module-basesystem/{{ grains['osrelease'] }}/x86_64 + +containers_activation: + cmd.run: + - name: SUSEConnect -p sle-module-containers/{{ grains['osrelease'] }}/x86_64 + +desktop_activation: + cmd.run: + - name: SUSEConnect -p sle-module-desktop-applications/{{ grains['osrelease'] }}/x86_64 + +devel_activation: + cmd.run: + - name: SUSEConnect -p sle-module-development-tools/{{ grains['osrelease'] }}/x86_64 + +{% endif %} diff --git a/salt/scc/init.sls b/salt/scc/init.sls new file mode 100644 index 000000000..5b59f4fd3 --- /dev/null +++ b/salt/scc/init.sls @@ -0,0 +1,2 @@ +include: + - scc.minion diff --git a/salt/scc/minion.sls b/salt/scc/minion.sls index 98831d252..9050972ad 100644 --- a/salt/scc/minion.sls +++ b/salt/scc/minion.sls @@ -1,4 +1,4 @@ -{% if 'minion' in grains.get('roles') and grains.get('sles_registration_code') and '15' in grains['osrelease'] %} +{% if ( 'minion' in grains.get('roles') or 'sshminion' in grains.get('roles') ) and grains.get('sles_registration_code') and '15' in grains['osrelease'] %} register_sles_server: cmd.run: @@ -8,16 +8,4 @@ basesystem_activation: cmd.run: - name: SUSEConnect -p sle-module-basesystem/{{ grains['osrelease'] }}/x86_64 -containers_activation: - cmd.run: - - name: SUSEConnect -p sle-module-containers/{{ grains['osrelease'] }}/x86_64 - -desktop_activation: - cmd.run: - - name: SUSEConnect -p sle-module-desktop-applications/{{ grains['osrelease'] }}/x86_64 - -devel_activation: - cmd.run: - - name: SUSEConnect -p sle-module-development-tools/{{ grains['osrelease'] }}/x86_64 - {% endif %}