1Z0-1067-25 Question 42
Select 2An engineering team is launching a set of compute instances in Oracle Cloud Infrastructure. They must run a script at first boot to install custom packages, configure environment variables, and create a new user. They decide to leverage cloud-init for this initialization. Which two steps are required to ensure the script executes automatically when each new instance is created?
- A
Include the script in the 'User data' section of the instance launch configuration with the appropriate #cloud-config or #!/bin/bash header.
- B
Disable cloud-init in the instance metadata to ensure that only your custom script runs on first boot.
- C
Place the script in /var/lib/cloud/instance/scripts/ with executable permissions so that it is processed at first boot.
- D
Configure the instance console settings to log all initialization steps, thereby forcing cloud-init to start.
Show answer and explanation
Correct answers: A, C
Explanation
To utilize cloud-init for instance initialization, user data can be provided at launch and/or placed in recognized cloud-init script directories. The #cloud-config or #!/bin/bash header ensures cloud-init identifies the script type and runs it. Refer to the Oracle Cloud Infrastructure documentation on provisioning user data (https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/preparinguserdata.htm) for best practices.
- A. Correct.
Correct. When launching a compute instance, you can provide user data in the 'User data' field, and cloud-init will automatically execute the script at first boot. Using #cloud-config (for YAML-based configuration) or #!/bin/bash (for a shell script) ensures cloud-init recognizes and runs the content properly.
- B. Incorrect.
Incorrect. Disabling cloud-init in the instance metadata would prevent the entire cloud-init process from running, which would block the custom script from executing automatically.
- C. Correct.
Correct. Placing scripts in /var/lib/cloud/instance/scripts/ with the correct permissions is a known method to have scripts executed by cloud-init. The script must be executable and located in a directory recognized by cloud-init for first-boot execution.
- D. Incorrect.
Incorrect. While console logs can help with debugging, merely configuring logging does not trigger cloud-init to run. Cloud-init starts automatically if it is enabled and properly configured; the console settings do not force execution.