This topic describes how to update custom images by using Operation Orchestration Service (OOS). OOS provides public templates to update images automatically. To create an immediate or scheduled O&M task, you only need to select a source image and specify required parameters such as the Cloud Assistant command in a public template. The O&M task is then automatically executed based on the definitions in the template.
You must have registered an Alibaba Cloud account before you follow the instructions provided in the tutorial. If not, create a new Alibaba Cloud account first.
- Check whether the name of the new custom image already exists and make sure that the name complies with the naming conventions.
- Create and launch a temporary ECS instance based on parameters such as the instance type, source image ID, and security group ID that you have configured.
- Check whether the Cloud Assistant client is installed on the temporary ECS instance. If not, install the Cloud Assistant client.
- Run scripts by using Cloud Assistant to update the system environment of the instance.
Note OOS calls Cloud Assistant API operations to run shell, bat, or PowerShell scripts to update the system environments of ECS instances. For more information, see Overview.
- Stop the temporary ECS instance.
- Create a custom image from the temporary ECS instance.
- Release the temporary ECS instance.
- Log on to the OOS console.
- Optional:If you are using OOS for the first time, click Enable Now to activate OOS.
- In the left-side navigation pane, click Public Templates.
- In the top navigation bar, select a region.
- In the ACS-ECS-UpdateImage section, click Create Execution.
- On the Create page, perform the following operations:
- In the Basic Information step, retain the default settings and click Next: Parameter Settings.
- In the Parameter Settings step, specify parameters to automatically create or update custom images. The following
table describes these parameters.
Parameter Description Example targetImageName The name of the new custom image. The name must comply with the regular expression /^[A-Za-z0-9\-_]*$/, and cannot be the same as an existing image name. add_testtxt_20191010 sourceImageId The ID of the image that you want to update.Note If you have not created a custom image, you can use a public image, such as centos_7_06_64_20G_alibase_20190711.vhd. m-bp13y4of6mdoqw****** instanceType The instance type of the temporary ECS instance to be created. For more information, see Instance families. ecs.g5.xlarge securityGroupId The ID of the security group to which the temporary ECS instance belongs. sg-bp1azkttqpldxg****** vSwitchId The ID of the vSwitch for the temporary ECS instance. The vSwitch and the security group must be in the same VPC. vsw-bp1s5fnvk4gn2tw****** ramRoleName The RAM role of the temporary ECS instance. TestRAMRole commandType The type of the script that you plan to run by using Cloud Assistant.
- RunShellScript: shell scripts for Linux instances.
- RunBatScript: bat scripts for Windows instances.
- RunPowerShellScript: PowerShell scripts for Windows instances.
RunShellScript tags The tag of the image.
- Tag Key (Required): the tag key of the image.
- Tag Value (Optional): the tag value of the image.
- Attach Resource Tag to Execution: binds resource tags to the OOS template. This option is selected by default. After resource tags are bound to the OOS template, you can use tags to filter the execution results of resources.
- Tag key: ECS
- Tag value: Image
commandContent The content of the script to be run on the temporary ECS instance.
echo "hello world" >/root/test.txt.
Permissions Optional. Valid values:
- Use Existing Permissions of Current Account: This is the default value. You have all the permissions granted to your account. Make sure that you have the permissions to call the ECS API operations required to create custom images.
- Specify RAM Role and Use Permissions Granted to This Role: If a RAM role is specified, OOS performs O&M tasks by assuming that RAM role.
Use Existing Permissions of Current Account
- Click Next: OK.
- Confirm O&M task details and high-risk operations. Then, click Confirm and Create.
- In the left-side navigation pane, click Executions to view the created O&M task.