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

rhel8/9: make edge images properly sysroot.readonly=true #3178

Merged
merged 2 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions internal/distro/fedora/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ func iotRawImage(workload workload.Workload,
img.Users = users.UsersFromBP(customizations.GetUsers())
img.Groups = users.GroupsFromBP(customizations.GetGroups())

// "rw" kernel option is required when /sysroot is mounted read-only to
// keep stateful parts of the filesystem writeable (/var/ and /etc)
img.KernelOptionsAppend = []string{"modprobe.blacklist=vc4", "rw"}
achilleas-k marked this conversation as resolved.
Show resolved Hide resolved
img.Keyboard = "us"
img.Locale = "C.UTF-8"
Expand Down
5 changes: 4 additions & 1 deletion internal/distro/rhel8/pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -953,9 +953,12 @@ func ostreeDeployPipeline(
OSName: osname,
},
))
p.AddStage(osbuild.NewOSTreeConfigStage(ostreeConfigStageOptions(repoPath, false)))
p.AddStage(osbuild.NewOSTreeConfigStage(ostreeConfigStageOptions(repoPath, true)))
p.AddStage(osbuild.NewMkdirStage(efiMkdirStageOptions()))
kernelOpts := osbuild.GenImageKernelOptions(pt)
// "rw" kernel option is required when /sysroot is mounted read-only to
// keep stateful parts of the filesystem writeable (/var/ and /etc)
kernelOpts = append(kernelOpts, "rw")
p.AddStage(osbuild.NewOSTreeDeployStage(
&osbuild.OSTreeDeployStageOptions{
OsName: osname,
Expand Down
10 changes: 8 additions & 2 deletions internal/distro/rhel9/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,12 @@ func edgeRawImage(workload workload.Workload,
img.Users = users.UsersFromBP(customizations.GetUsers())
img.Groups = users.GroupsFromBP(customizations.GetGroups())

img.KernelOptionsAppend = []string{"modprobe.blacklist=vc4"}
// "rw" kernel option is required when /sysroot is mounted read-only to
// keep stateful parts of the filesystem writeable (/var/ and /etc)
img.KernelOptionsAppend = []string{"modprobe.blacklist=vc4", "rw"}
thozza marked this conversation as resolved.
Show resolved Hide resolved
img.Keyboard = "us"
img.Locale = "C.UTF-8"
img.SysrootReadOnly = true

img.Platform = t.platform
img.Workload = workload
Expand Down Expand Up @@ -361,9 +364,12 @@ func edgeSimplifiedInstallerImage(workload workload.Workload,
rawImg.Users = users.UsersFromBP(customizations.GetUsers())
rawImg.Groups = users.GroupsFromBP(customizations.GetGroups())

rawImg.KernelOptionsAppend = []string{"modprobe.blacklist=vc4"}
// "rw" kernel option is required when /sysroot is mounted read-only to
// keep stateful parts of the filesystem writeable (/var/ and /etc)
rawImg.KernelOptionsAppend = []string{"modprobe.blacklist=vc4", "rw"}
achilleas-k marked this conversation as resolved.
Show resolved Hide resolved
rawImg.Keyboard = "us"
rawImg.Locale = "C.UTF-8"
rawImg.SysrootReadOnly = true

rawImg.Platform = t.platform
rawImg.Workload = workload
Expand Down
6 changes: 3 additions & 3 deletions test/cases/ostree-raw-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ ansible_become_pass=${EDGE_USER_PASSWORD}
EOF

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e ostree_commit="${INSTALL_HASH}" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e edge_type=edge-raw-image -e ostree_commit="${INSTALL_HASH}" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
check_result

# Clean up BIOS VM
Expand Down Expand Up @@ -567,7 +567,7 @@ ansible_become_pass=${EDGE_USER_PASSWORD}
EOF

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e ostree_commit="${INSTALL_HASH}" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e edge_type=edge-raw-image -e ostree_commit="${INSTALL_HASH}" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
check_result

##################################################################
Expand Down Expand Up @@ -721,7 +721,7 @@ ansible_become_pass=${EDGE_USER_PASSWORD}
EOF

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e ostree_commit="${UPGRADE_HASH}" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e edge_type=edge-raw-image -e ostree_commit="${UPGRADE_HASH}" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
check_result

# Final success clean up
Expand Down
10 changes: 5 additions & 5 deletions test/cases/ostree-simplified-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ ansible_become_pass=${EDGE_USER_PASSWORD}
EOF

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type=redhat -e ostree_commit="${INSTALL_HASH}" -e fdo_credential="true" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type=redhat -e ostree_commit="${INSTALL_HASH}" -e edge_type=edge-simplified-installer -e fdo_credential="true" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
check_result

# Clean up BIOS VM
Expand Down Expand Up @@ -643,7 +643,7 @@ ansible_become_pass=${EDGE_USER_PASSWORD}
EOF

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type=redhat -e ostree_commit="${INSTALL_HASH}" -e fdo_credential="true" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type=redhat -e ostree_commit="${INSTALL_HASH}" -e edge_type=edge-simplified-installer -e fdo_credential="true" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
check_result

# Clean up BIOS VM
Expand Down Expand Up @@ -765,7 +765,7 @@ ansible_become_pass=${EDGE_USER_PASSWORD}
EOF

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type=redhat -e ostree_commit="${INSTALL_HASH}" -e fdo_credential="true" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type=redhat -e ostree_commit="${INSTALL_HASH}" -e edge_type=edge-simplified-installer -e fdo_credential="true" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
check_result

greenprint "🧹 Clean up VM"
Expand Down Expand Up @@ -882,7 +882,7 @@ ansible_become_pass=${EDGE_USER_PASSWORD}
EOF

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type=redhat -e ostree_commit="${INSTALL_HASH}" -e fdo_credential="false" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type=redhat -e ostree_commit="${INSTALL_HASH}" -e edge_type=edge-simplified-installer -e fdo_credential="false" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
check_result

########################
Expand Down Expand Up @@ -1016,7 +1016,7 @@ ansible_become_pass=${EDGE_USER_PASSWORD}
EOF

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type=redhat -e ostree_commit="${UPGRADE_HASH}" -e fdo_credential="false" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type=redhat -e ostree_commit="${UPGRADE_HASH}" -e edge_type=edge-simplified-installer -e fdo_credential="false" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
check_result

# Final success clean up
Expand Down
37 changes: 29 additions & 8 deletions test/data/ansible/check_ostree.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
workspace: "{{ lookup('env', 'WORKSPACE') }}"
skip_rollback_test: "false"
fdo_credential: "false"
edge_type: "none"
embeded_container: "false"
total_counter: "0"
failed_counter: "0"
Expand Down Expand Up @@ -232,7 +233,28 @@
shell: findmnt -r -o OPTIONS -n /sysroot | awk -F "," '{print $1}'
register: result_sysroot_mount_status

- name: /sysroot should be mount with rw permission
# https://fedoraproject.org/wiki/Changes/Silverblue_Kinoite_readonly_sysroot
# There are three checks here for /sysroot permission based on pr https://github.com/osbuild/osbuild-composer/pull/3053
# 1. for edge-commit and edge-installer, check ro when fedora >= 37
# 2. for edge-commit and edge-installer, check rw for other os.
# 3. for edge-simplified-installer and edge-raw-image, check ro for all os.
- name: /sysroot should be mount with ro permission for edge-commit and edge-installer on Fedora >= 37
block:
- assert:
that:
- result_sysroot_mount_status.stdout == "ro"
fail_msg: "/sysroot is not mounted with ro permission"
success_msg: "/sysroot is mounted with ro permission"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: (edge_type == "none") and (ansible_facts['distribution'] == 'Fedora' and ansible_facts['distribution_version'] is version('37', '>='))

- name: /sysroot should be mount with rw permission for edge-commit and edge-installer on all OS except Fedora >= 37
block:
- assert:
that:
Expand All @@ -246,11 +268,10 @@
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: (ansible_facts['distribution'] == 'Fedora' and ansible_facts['distribution_version'] is version('37', '<')) or
(ansible_facts['distribution'] == 'CentOS') or (ansible_facts['distribution'] == 'RedHat')
when: (edge_type == "none") and ((ansible_facts['distribution'] == 'Fedora' and ansible_facts['distribution_version'] is version('37', '<')) or
(ansible_facts['distribution'] == 'CentOS') or (ansible_facts['distribution'] == 'RedHat'))

# https://fedoraproject.org/wiki/Changes/Silverblue_Kinoite_readonly_sysroot
- name: /sysroot should be mount with ro permission since Fedora 37
- name: /sysroot should be mount with ro permission for edge-simplified-installer and edge-raw-image
block:
- assert:
that:
Expand All @@ -264,7 +285,7 @@
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: ansible_facts['distribution'] == 'Fedora' and ansible_facts['distribution_version'] is version('37', '>=')
when: edge_type == "edge-simplified-installer" or edge_type == "edge-raw-image"

# case: check /var mount point
- name: check /var mount point
Expand Down Expand Up @@ -397,8 +418,8 @@
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: (ansible_facts['distribution'] == 'Fedora' and ansible_facts['distribution_version'] is version('37', '<')) or
(ansible_facts['distribution'] == 'CentOS') or (ansible_facts['distribution'] == 'RedHat')
when: (edge_type == "none") and ((ansible_facts['distribution'] == 'Fedora' and ansible_facts['distribution_version'] is version('37', '<')) or
(ansible_facts['distribution'] == 'CentOS') or (ansible_facts['distribution'] == 'RedHat'))

# case: check dmesg error and failed log
- name: check dmesg output
Expand Down
5 changes: 3 additions & 2 deletions test/data/manifests/centos_8-aarch64-edge_raw_image-boot.json
Original file line number Diff line number Diff line change
Expand Up @@ -2466,7 +2466,7 @@
"repo": "/ostree/repo",
"config": {
"sysroot": {
"readonly": false,
"readonly": true,
"bootloader": "none"
}
}
Expand Down Expand Up @@ -2497,7 +2497,8 @@
"label": "root"
},
"kernel_opts": [
"luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75"
"luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
"rw"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2506,7 +2506,7 @@
"repo": "/ostree/repo",
"config": {
"sysroot": {
"readonly": false,
"readonly": true,
"bootloader": "none"
}
}
Expand Down Expand Up @@ -2537,7 +2537,8 @@
"label": "root"
},
"kernel_opts": [
"luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75"
"luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
"rw"
]
}
},
Expand Down
5 changes: 3 additions & 2 deletions test/data/manifests/centos_8-x86_64-edge_raw_image-boot.json
Original file line number Diff line number Diff line change
Expand Up @@ -2514,7 +2514,7 @@
"repo": "/ostree/repo",
"config": {
"sysroot": {
"readonly": false,
"readonly": true,
"bootloader": "none"
}
}
Expand Down Expand Up @@ -2545,7 +2545,8 @@
"label": "root"
},
"kernel_opts": [
"luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75"
"luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
"rw"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2570,7 +2570,7 @@
"repo": "/ostree/repo",
"config": {
"sysroot": {
"readonly": false,
"readonly": true,
"bootloader": "none"
}
}
Expand Down Expand Up @@ -2601,7 +2601,8 @@
"label": "root"
},
"kernel_opts": [
"luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75"
"luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
"rw"
]
}
},
Expand Down
7 changes: 4 additions & 3 deletions test/data/manifests/centos_9-aarch64-edge_raw_image-boot.json
Original file line number Diff line number Diff line change
Expand Up @@ -2222,7 +2222,8 @@
},
"kernel_opts": [
"luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
"modprobe.blacklist=vc4"
"modprobe.blacklist=vc4",
"rw"
]
}
},
Expand Down Expand Up @@ -2253,7 +2254,7 @@
"repo": "/ostree/repo",
"config": {
"sysroot": {
"readonly": false,
"readonly": true,
"bootloader": "none"
}
}
Expand Down Expand Up @@ -2379,7 +2380,7 @@
"options": {
"root_fs_uuid": "fb180daf-48a7-4ee0-b10d-394651850fd4",
"boot_fs_uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"kernel_opts": "luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75,modprobe.blacklist=vc4",
"kernel_opts": "luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75,modprobe.blacklist=vc4,rw",
"uefi": {
"vendor": "centos",
"install": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2606,7 +2606,8 @@
},
"kernel_opts": [
"luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
"modprobe.blacklist=vc4"
"modprobe.blacklist=vc4",
"rw"
]
}
},
Expand Down Expand Up @@ -2637,7 +2638,7 @@
"repo": "/ostree/repo",
"config": {
"sysroot": {
"readonly": false,
"readonly": true,
"bootloader": "none"
}
}
Expand Down Expand Up @@ -2763,7 +2764,7 @@
"options": {
"root_fs_uuid": "fb180daf-48a7-4ee0-b10d-394651850fd4",
"boot_fs_uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"kernel_opts": "luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75,modprobe.blacklist=vc4",
"kernel_opts": "luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75,modprobe.blacklist=vc4,rw",
"uefi": {
"vendor": "centos",
"install": true,
Expand Down
7 changes: 4 additions & 3 deletions test/data/manifests/centos_9-x86_64-edge_raw_image-boot.json
Original file line number Diff line number Diff line change
Expand Up @@ -2349,7 +2349,8 @@
},
"kernel_opts": [
"luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
"modprobe.blacklist=vc4"
"modprobe.blacklist=vc4",
"rw"
]
}
},
Expand Down Expand Up @@ -2380,7 +2381,7 @@
"repo": "/ostree/repo",
"config": {
"sysroot": {
"readonly": false,
"readonly": true,
"bootloader": "none"
}
}
Expand Down Expand Up @@ -2506,7 +2507,7 @@
"options": {
"root_fs_uuid": "fb180daf-48a7-4ee0-b10d-394651850fd4",
"boot_fs_uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"kernel_opts": "luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75,modprobe.blacklist=vc4",
"kernel_opts": "luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75,modprobe.blacklist=vc4,rw",
"legacy": "i386-pc",
"uefi": {
"vendor": "centos",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2661,7 +2661,8 @@
},
"kernel_opts": [
"luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
"modprobe.blacklist=vc4"
"modprobe.blacklist=vc4",
"rw"
]
}
},
Expand Down Expand Up @@ -2692,7 +2693,7 @@
"repo": "/ostree/repo",
"config": {
"sysroot": {
"readonly": false,
"readonly": true,
"bootloader": "none"
}
}
Expand Down Expand Up @@ -2818,7 +2819,7 @@
"options": {
"root_fs_uuid": "fb180daf-48a7-4ee0-b10d-394651850fd4",
"boot_fs_uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"kernel_opts": "luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75,modprobe.blacklist=vc4",
"kernel_opts": "luks.uuid=6e4ff95f-f662-45ee-a82a-bdf44a2d0b75,modprobe.blacklist=vc4,rw",
"uefi": {
"vendor": "centos",
"install": true,
Expand Down
Loading