Skip to content

Commit

Permalink
Migration test support aws (#1126)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
maximenoel8 authored Jul 21, 2022
1 parent 50f180a commit 9eb232d
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 15 deletions.
22 changes: 22 additions & 0 deletions backend_modules/aws/base/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 },
Expand Down
1 change: 1 addition & 0 deletions backend_modules/aws/host/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"]))] : [],
Expand Down
1 change: 1 addition & 0 deletions modules/build_host/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down
5 changes: 5 additions & 0 deletions modules/build_host/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions salt/build_host/init.sls
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
include:
- scc.build_host

certificate_authority_certificate:
file.managed:
- name: /etc/pki/trust/anchors/ca.cert.pem
Expand Down
1 change: 0 additions & 1 deletion salt/client/testsuite.sls
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% if grains.get('testsuite') | default(false, true) %}

include:
- scc.minion
- repos
- client

Expand Down
1 change: 1 addition & 0 deletions salt/default/testsuite.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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' %}
Expand Down
2 changes: 1 addition & 1 deletion salt/repos/build_host.sls
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
23 changes: 23 additions & 0 deletions salt/scc/build_host.sls
Original file line number Diff line number Diff line change
@@ -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 %}
2 changes: 2 additions & 0 deletions salt/scc/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include:
- scc.minion
14 changes: 1 addition & 13 deletions salt/scc/minion.sls
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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 %}

0 comments on commit 9eb232d

Please sign in to comment.