Skip to content

Skip nodev mount option for polyinstantiated dirs#14374

Merged
Mab879 merged 3 commits intoComplianceAsCode:masterfrom
asser:fix_mount_option_nodev_polyinstantiated
Feb 12, 2026
Merged

Skip nodev mount option for polyinstantiated dirs#14374
Mab879 merged 3 commits intoComplianceAsCode:masterfrom
asser:fix_mount_option_nodev_polyinstantiated

Conversation

@asser
Copy link
Contributor

@asser asser commented Feb 9, 2026

Skip attempting to set nodev mount option for polyinstantiated /tmp and /var/tmp mounts when enabled

Description:

Add clauses to skip trying to set the nodev mount option for the polyinstantiated /tmp/tmp-inst and /var/tmp/tmp-inst mounts, when polyinstantiation is enabled.

Rationale:

When applying the Ansible playbook with polyinstantiation enabled through become/sudo as a non-root user, the polyinstantiated /var/tmp/tmp-inst (and /tmp/tmp-inst) bind mounts are present in ansible_facts.mounts, but cannot be changed with the ansible.posix.mount module, which fails with an error (example from the generated role RedHatOfficial.rhel10_anssi_bp28_high):

...
TASK [RedHatOfficial.rhel10_anssi_bp28_high : Add nodev Option to Non-Root Local Partitions: Ensure non-root local partitions are mounted with nodev option] ***************************************************************************
...
failed: [localhost -> template_vm(10.23.240.211)] (item={'mount': '/var/tmp/tmp-inst', 'device': '/dev/mapper/vg00-vartmp', 'fstype': 'xfs', 'options': 'rw,seclabel,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota,bind', 'dump': 0, 'passno': 0, 'uuid': '30dedaf5-f560-4dc6-89ae-97fcad6a9478'}) => {"ansible_loop_var": "item", "changed": false, "item": {"device": "/dev/mapper/vg00-vartmp", "dump": 0, "fstype": "xfs", "mount": "/var/tmp/tmp-inst", "options": "rw,seclabel,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota,bind", "passno": 0, "uuid": "30dedaf5-f560-4dc6-89ae-97fcad6a9478"}, "msg": "Error mounting /var/tmp/tmp-inst: mount: /var/tmp/tmp-inst: wrong fs type, bad option, bad superblock on /dev/mapper/vg00-vartmp, missing codepage or helper program, or other error.\n       dmesg(1) may have more information after failed mount system call.\n"}

Review Hints:

N/A

Skip attempting to set `nodev` mount option for polyinstantiated /tmp
and /var/tmp mounts when enabled
@openshift-ci
Copy link

openshift-ci bot commented Feb 9, 2026

Hi @asser. Thanks for your PR.

I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Feb 9, 2026
- "item.options is not search('nodev')"
- "item.fstype not in excluded_fstypes"
# Attempting to change polyinstantiated mounts for /tmp and /var/tmp, if present, will fail
- "not accounts_polyinstantiated_var_tmp or item.mount != '/var/tmp/tmp-inst'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this variable and the one below are sometimes not defined as will cause errors, as picked up by CI.

Something like:

Suggested change
- "not accounts_polyinstantiated_var_tmp or item.mount != '/var/tmp/tmp-inst'"
- "(not accounts_polyinstantiated_var_tmp | default(false)) or item.mount != '/var/tmp/tmp-inst'"

might help.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, thank you. Updated :)

* Add default filter to set `accounts_polyinstantiated_tmp` and
  `accounts_polyinstantiated_var_tmp` to false if not defined
@Mab879 Mab879 self-assigned this Feb 12, 2026
@github-actions
Copy link

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_mount_option_nodev_nonroot_local_partitions' differs.
--- xccdf_org.ssgproject.content_rule_mount_option_nodev_nonroot_local_partitions
+++ xccdf_org.ssgproject.content_rule_mount_option_nodev_nonroot_local_partitions
@@ -100,8 +100,6 @@
   - item.mount is match('/\w')
   - item.options is not search('nodev')
   - item.fstype not in excluded_fstypes
-  - (not accounts_polyinstantiated_var_tmp | default(false)) or item.mount != '/var/tmp/tmp-inst'
-  - (not accounts_polyinstantiated_tmp | default(false)) or item.mount != '/tmp/tmp-inst'
   with_items:
   - '{{ ansible_facts.mounts }}'
   tags:

@Mab879 Mab879 added this to the 0.1.80 milestone Feb 12, 2026
@Mab879 Mab879 added the Ansible Ansible remediation update. label Feb 12, 2026
@Mab879 Mab879 merged commit 0ec1efd into ComplianceAsCode:master Feb 12, 2026
121 of 131 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ansible Ansible remediation update. needs-ok-to-test Used by openshift-ci bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants