plus3it / spel

STIG-Partitioned Enterprise Linux (spel)
Other
94 stars 61 forks source link

Addition of `free-root.sh` to EL8 builders can cause failures if bootstrap image doesn't have audit service #665

Closed ferricoxide closed 7 months ago

ferricoxide commented 7 months ago

Expected behavior

Execution of the free-root.sh script results in the root-disk being fully freed for re-use by the AMIgen scripts.

Actual behavior

Execution of the free-root.sh script results in an error if the bootstrap image doesn't have the audit service configured. Thus far, only encountered on the Oracle-published AMI for OL 8.8 (ami-02a7419f257858fad in the us-east-1 region).

Steps to reproduce behavior

  1. Activate spel's amazon-ebs.minimal-ol-8-hvm builder
  2. Override the default image-selection with aws_source_ami_filter_ol8_hvm set to {name = "OL8.8-x86_64-HVM-*", owners = ["131827586825"]}
  3. Start build
  4. Watch for job to error out like:
    ==> amazon-ebs.minimal-ol-8-hvm: Provisioning with shell script: spel/scripts/free-root.sh
        amazon-ebs.minimal-ol-8-hvm: + set -e
        amazon-ebs.minimal-ol-8-hvm: + echo 'Restarting systemd'
        amazon-ebs.minimal-ol-8-hvm: Restarting systemd
        amazon-ebs.minimal-ol-8-hvm: + systemctl daemon-reexec
        amazon-ebs.minimal-ol-8-hvm: + echo 'Killing auditd'
        amazon-ebs.minimal-ol-8-hvm: Killing auditd
        amazon-ebs.minimal-ol-8-hvm: + service auditd stop
        amazon-ebs.minimal-ol-8-hvm: Redirecting to /bin/systemctl stop auditd.service
        amazon-ebs.minimal-ol-8-hvm: Failed to stop auditd.service: Unit auditd.service not loaded.
    ==> amazon-ebs.minimal-ol-8-hvm: Provisioning step had errors: Running the cleanup provisioner, if present...
    ==> amazon-ebs.minimal-ol-8-hvm: Terminating the source AWS instance...

Suggestions for fix

Update free-root.sh to conditionally attempt to execute service auditd stop