1Z0-1067-25 Question 39
Single answerYou are provisioning a new Linux compute instance in Oracle Cloud Infrastructure (OCI). During initialization, you want to ensure that the instance automatically installs Apache HTTP Server and sets a custom environment variable for your application. Which approach correctly uses cloud-init to achieve this?
- A
Embed a #cloud-config YAML file in the instance� user data that specifies packages to install and commands to set environment variables.
- B
Upload a user script to Object Storage and rely on the metadata service to invoke it without additional configuration.
- C
Place an init.d script in the default boot volume before launching the instance, assuming it will run on startup for any OCI Linux image.
- D
Use the instance creation wizard� 'Custom Metadata' field to enter a raw bash script without a cloud-init header or YAML syntax.
Show answer and explanation
Correct answer: A
Explanation
In OCI, cloud-init is a powerful method to automate instance configuration at first boot. You typically place a #cloud-config (YAML-based) script within the 'User data' field when creating a compute instance. This allows you to specify package installations, user creation, configuration tasks, and environment variables. Refer to the official Oracle Cloud Infrastructure documentation on using cloud-init (https://docs.oracle.com/en-us/iaas) for detailed examples and best practices.
- A. Correct.
Correct. Cloud-init can process the #cloud-config header and YAML content to install packages (such as httpd) and set environment variables on first boot. You embed this content directly in the OCI console� 'User data' section or via CLI/SDK when creating the instance.
- B. Incorrect.
Incorrect. While you can host a script in Object Storage, you must still configure cloud-init or another mechanism to fetch and run it automatically. Merely placing the script in Object Storage and referencing it in metadata will not make cloud-init run it by default.
- C. Incorrect.
Incorrect. Simply placing a script in init.d or similar paths in the boot volume does not guarantee cloud-init will trigger it. This is a more manual approach that may vary by operating system configuration, and it does not leverage cloud-init� capabilities or best practices.
- D. Incorrect.
Incorrect. Providing a raw bash script without the #cloud-config header or a recognized syntax means cloud-init may not interpret it properly. Cloud-init expects specific headers or directives to parse and run scripts effectively.