1Z0-1067-25 Question 40
Select 2You have launched an Oracle Linux 8 compute instance on OCI. You want to automatically install a web server, enable it, and allow HTTP traffic on the firewall during the first boot. You placed these instructions in a YAML-based cloud-init user data script, but the instance boot logs indicate that the script never executed. Which two steps are recommended to fix this issue so that your script executes properly on first boot? (Choose two.)
- A
Use '#cloud-config' as the first line in your user data YAML to ensure cloud-init recognizes the format
- B
Place your script in /var/lib/cloud/scripts/per-boot so it will run every time the instance restarts
- C
Leverage cloud-init directives (e.g., 'packages' and 'runcmd') under the '#cloud-config' section to handle software installation and firewall configuration
- D
Remove and permanently disable the firewall service in the instance prior to installing packages to avoid conflicts
- E
Use '#!/bin/bash' at the beginning of the file to treat the entire script as a generic shell script for first-boot
Show answer and explanation
Correct answers: A, C
Explanation
When creating a cloud-init user data script for Oracle Cloud Infrastructure, using '#cloud-config' as the first line is essential so that cloud-init recognizes and processes YAML instructions. Under this directive, 'packages' automatically installs software, and 'runcmd' can configure firewall settings and enable services. Refer to the Oracle Cloud Infrastructure Documentation on cloud-init (https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/usingcloudinit.htm) for best practices on properly formatting and placing your YAML directives to ensure they execute upon first boot.
- A. Correct.
Correct. Including '#cloud-config' at the very top ensures cloud-init treats the user data as a YAML configuration file, allowing you to specify package installations and commands under recognized keys.
- B. Incorrect.
Incorrect. Scripts in /var/lib/cloud/scripts/per-boot run every time the instance boots, not just at first boot. This will cause repeated installations and configurations, which is usually undesired.
- C. Correct.
Correct. Using recognized directives such as 'packages' and 'runcmd' under '#cloud-config' automatically triggers the relevant cloud-init modules to install software and execute commands during first boot.
- D. Incorrect.
Incorrect. Permanently disabling the firewall service is unnecessary and insecure. Also, cloud-init can configure the firewall without disabling it entirely.
- E. Incorrect.
Incorrect. While '#!/bin/bash' is valid for shell scripts, it does not leverage the cloud-init YAML-based configuration. When using YAML-based user data, you should lead with '#cloud-config' instead of a bash shebang.