Skip to content

Commit 19d7fa9

Browse files
committed
Rename skip_upgrade to upgrade and add more use cases
1 parent b7f7356 commit 19d7fa9

9 files changed

Lines changed: 34 additions & 22 deletions

File tree

aws/infrastructure.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module "configuration" {
3131
software_stack = var.software_stack
3232
cloud_provider = local.cloud_provider
3333
cloud_region = local.cloud_region
34-
skip_upgrade = var.skip_upgrade
34+
upgrade = var.upgrade
3535
puppet_conf = var.puppet_conf
3636
}
3737

azure/infrastructure.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module "configuration" {
3131
software_stack = var.software_stack
3232
cloud_provider = local.cloud_provider
3333
cloud_region = local.cloud_region
34-
skip_upgrade = var.skip_upgrade
34+
upgrade = var.upgrade
3535
puppet_conf = var.puppet_conf
3636
}
3737

common/configuration/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ variable "guest_passwd" {}
2323

2424
variable "public_keys" {}
2525

26-
variable "skip_upgrade" {}
26+
variable "upgrade" {}
2727
variable "bastion_tags" {}
2828

2929
resource "tls_private_key" "ssh" {
@@ -127,7 +127,7 @@ locals {
127127
ssh_authorized_keys = local.public_keys
128128
tf_ssh_public_key = chomp(tls_private_key.ssh.public_key_openssh)
129129
terraform_facts = local.terraform_facts
130-
skip_upgrade = var.skip_upgrade
130+
upgrade = var.upgrade
131131
module_path = path.module
132132
user_tf_required = contains(values.tags, "puppet") || length(setintersection(values.tags, var.bastion_tags)) > 0
133133
hostkeys = {

common/configuration/puppet.yaml.tftpl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,13 @@ runcmd:
6464
# upload the terraform_data.yaml
6565
dnf -y install git pciutils unzip
6666
dnf -y remove cockpit\* firewalld --exclude=iptables
67-
%{ if ! skip_upgrade ~}
68-
# Upgrade all packages except openvox if already installed
69-
dnf -y upgrade -x openvox*
70-
%{ endif ~}
67+
fi
68+
# Upgrade all packages except openvox if already installed
69+
%{ if upgrade != "none" ~}
70+
- %{ if startswith(upgrade, "vanilla") }test -f /etc/magic-castle-release || %{ endif }dnf -y upgrade -x openvox* %{ if strcontains(upgrade, "security") }--security%{ endif }
71+
%{ endif }
72+
- |
73+
if ! test -f /etc/magic-castle-release; then
7174
# Puppet agent configuration and install
7275
dnf -y install https://yum.voxpupuli.org/openvox8-release-el-$(grep -oP 'VERSION_ID="\K\d*' /etc/os-release).noarch.rpm
7376
dnf -y install openvox-agent-8.23.1
@@ -148,7 +151,7 @@ runcmd:
148151
%{ endif ~}
149152
# If the current image has already been configured with Magic Castle Puppet environment,
150153
# we can start puppet and skip reboot, reducing the delay for bringing the node up.
151-
- test -f /etc/magic-castle-release && systemctl start puppet || true
154+
- dnf needs-restarting -r && test -f /etc/magic-castle-release && systemctl start puppet || true
152155
- test -f /run/cloud-init-failed && echo 'WARNING - some steps cloud-init runcmd failed, listed in /run/cloud-init-failed. Manual fixing and rebooting required. ' | tee /etc/motd || true
153156

154157
write_files:
@@ -241,7 +244,7 @@ output: { all: "| tee -a /var/log/cloud-init-output.log" }
241244
power_state:
242245
delay: now
243246
mode: reboot
244-
condition: test ! -f /etc/magic-castle-release && test ! -f /run/cloud-init-failed
247+
condition: "! dnf needs-restarting -r || (test ! -f /etc/magic-castle-release && test ! -f /run/cloud-init-failed)"
245248

246249
# Configure owner of /var/log/cloud-init.log
247250
syslog_fix_perms: root:systemd-journal

common/variables.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,14 @@ variable "pool" {
150150
default = []
151151
}
152152

153-
variable "skip_upgrade" {
154-
type = bool
155-
default = false
156-
description = "If set to true, the packages already installed in the base image will not be upgraded on first boot."
153+
variable "upgrade" {
154+
type = string
155+
default = "vanilla-all"
156+
description = "If set to all, all base packages are upgraded on first boot. When prefixed with `vanilla-`, upgrade only happen with vanilla based image."
157+
validation {
158+
condition = contains(["all", "none", "security", "vanilla-all", "vanilla-security"], var.upgrade)
159+
error_message = "Upgrade options are: all, none, security, vanilla-all, vanilla-security"
160+
}
157161
}
158162

159163
variable "puppetfile" {

docs/README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -951,16 +951,21 @@ managed by the workload scheduler through Terraform API. For more information, r
951951
will be instantiated, others will stay uninstantiated or will be destroyed
952952
if previously instantiated.
953953
954-
### 4.20 skip_upgrade (optional)
954+
### 4.20 upgrade (optional)
955955
956-
**default_value** = `false`
956+
**default_value** = `"vanilla-all"`
957957
958-
If true, the base image packages will not be upgraded during the first boot. By default,
959-
all packages are upgraded.
958+
Defines if base image packages are upgraded during the first boot. Possible values are:
959+
960+
- `"all"`: upgrade all packages
961+
- `"none"`: do not upgrade packages
962+
- `"security"`: upgrade security packages only
963+
- `"vanilla-all"`: upgrade all packages only when booting from a vanilla base image
964+
- `"vanilla-security"`: upgrade security packages only when booting from a vanilla base image
960965
961966
**Post build modification effect**: No effect on currently built instances. Ones created
962967
after the modification will take into consideration the new value of the parameter to determine
963-
whether they should upgrade the base image packages or not.
968+
how they should upgrade the base image packages.
964969
965970
### 4.21 puppetfile (optional)
966971

gcp/infrastructure.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module "configuration" {
3131
software_stack = var.software_stack
3232
cloud_provider = local.cloud_provider
3333
cloud_region = local.cloud_region
34-
skip_upgrade = var.skip_upgrade
34+
upgrade = var.upgrade
3535
puppet_conf = var.puppet_conf
3636
}
3737

incus/infrastructure.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module "configuration" {
2727
software_stack = var.software_stack
2828
cloud_provider = "incus"
2929
cloud_region = "local"
30-
skip_upgrade = var.skip_upgrade
30+
upgrade = var.upgrade
3131
puppet_conf = var.puppet_conf
3232
}
3333

openstack/infrastructure.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module "configuration" {
2626
software_stack = var.software_stack
2727
cloud_provider = local.cloud_provider
2828
cloud_region = local.cloud_region
29-
skip_upgrade = var.skip_upgrade
29+
upgrade = var.upgrade
3030
puppet_conf = var.puppet_conf
3131
}
3232

0 commit comments

Comments
 (0)