Operations and Maintenance Layout Scene Series - -- One-click batch reset instance password

When you need to be on a page, you can batch select instances and enter the passwords that the instances need to reset to make it easier to reset multiple instances'passwords.Use at this time OOS Service This can be achieved.

Prerequisite

  1. Instance password cannot be reset when instance state is Starting
  2. cover safety control OperationLocks for ECS instances of cannot be marked LockReason:'security'.

Template description:

The main functions of this template are:

  1. Get Instances
  2. Check that the instance runs with the modified password
  3. Change Password
  4. Restart ECS instance
FormatVersion: OOS-2019-06-01
Description:
  en: Reset ECS instance password and reboot instance.
  zh-cn: Reset instance password and restart ECS Example.
  name-en: ResetPasswordAndRebootInstance
  name-zh-cn: Reset instance password and restart instance
Parameters:
  Targets:
    Type: Json
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: ALIYUN::ECS::Instance
  Password:
    Type: String
    Description:
      en: The ECS instance, 8 to 30 characters in length, which must include three types of characters:uppercase and lowercase letters, numbers, and special symbols.
      zh-cn: Instance password, 8 to 30 characters in length, must contain three types of characters in both uppercase and lowercase English letters, numbers, and special symbols.
    MinLength: 8
    MaxLength: 30
  RateControl:
    Description:
      en: Concurrency ratio of task execution.
      zh-cn: Concurrent rate of task execution.
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Description: The RAM role to be assumed by OOS.
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: Views the ECS instances.
      zh-cn: Obtain ECS Example.
    Action: ACS::SelectTargets
    Properties:
      ResourceType: ALIYUN::ECS::Instance
      Filters:
        - '{{ Targets }}'
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: Instances.Instance[].InstanceId
  - Name: checkInstanceReady
    Action: ACS::CheckFor
    Description: Check the ECS instance is running status.
    Properties:
      Service: ECS
      API: DescribeInstances
      Parameters:
        InstanceIds:
          - '{{ ACS::TaskLoopItem }}'
      NotDesiredValues:
        - Starting
      PropertySelector: Instances.Instance[].Status
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: Instances.Instance[]
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ getInstance.instanceIds }}'
  - Name: ModifyInstanceAttribute
    Action: ACS::ExecuteAPI
    Description:
      en: Upgrade ECS instance temporary bandwidth.
      zh-cn: upgrade ECS Instance temporary bandwidth.
    Properties:
      Service: ECS
      API: ModifyInstanceAttribute
      Parameters:
        InstanceId: '{{ ACS::TaskLoopItem }}'
        Password: '{{ Password }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ getInstance.instanceIds }}'
  - Name: rebootInstance
    Action: ACS::ECS::RebootInstance
    Description:
      en: Restarts the ECS instances.
      zh-cn: Restart the instance.
    Properties:
      instanceId: '{{ ACS::TaskLoopItem }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ getInstance.instanceIds }}'

Template parameter description:

parameter Explain Example
Targets Select the desired instance based on the instance tags or InstanceId. i-11111111111
Password The password of the instance.It is 8 to 30 characters long and must contain three types of characters: uppercase and lowercase letters, numbers, and special symbols.Special symbols can be:
()~!@#$%^&*-_+={}[]:;'<>,.?/`
qwer1234Q
RateControl Fixed parameters.
-Rate control type: concurrency control
-Concurrency rate: 1
-Maximum number of errors:0
OOSAssumeRole Optional parameters.
-(Default) Existing permissions for the current account: Perform the permission action for the account you are using.Make sure you have all the ECS API calls involved in creating a custom image.
- Specify the RAM role and the permissions to use it: If the RAM role name is specified, the OOS plays the RAM role to perform operations and maintenance tasks.
Existing permissions for the current account

Operation steps

  1. Please visit Control of Operations and Maintenance Layout OOS.
  2. Click My Template, click the Create Template button, and select a blank template.
  3. Paste the template provided above into the yaml column, enter the name ResetPasswordAndRebootInstance or a custom name, and click Create Template.
  4. Click Create Execution.
  5. Keep the default settings for basic information and click Next: Set parameters.
  6. Complete the parameter settings and click Next: Confirm.
  7. Check to see if the parameter settings are correct and click Create to execute.
  8. View the created maintenance tasks in execution management.
  9. results of enforcement

Series articles

Topic Articles

Ali Cloud Heavy Release Cloud Automation Tool-Operations and Maintenance Organization OOS

Best Practices

Permissions to play the Transport Maintenance Layout Service: Assume Role+Pass Role
Ali Cloud Operation and Maintenance New Function: One-Click Batch Cloning ECS
Batch command execution within multiple ECS s

Scene Series

Operations Maintenance Layout Scene Series - Update ECS Mirrors
Operations and Maintenance Layout Scene Series - Automatically type TAG for ECS instances
Operations Maintenance Layout Scene Series - Copying files from instances to OSS
Operations and Maintenance Layout Scene Series - Add Instances to SLS Machine Group
Operations Maintenance Layout Scene Series - Detect MFA Functional Status
Operations and Maintenance Layout Scene Series - Daily statistics of the running status of multiple Region instances
Operations and Maintenance Scene Series - How to Use jq
Operations and Maintenance Layout Scene Series - Run commands on machines in batches
Operations Maintenance Layout Scene Series - Update the scaling configuration mirror automatically after updating the mirror
Operations and Maintenance Scheduling Scene Series - Uploading files to Linux instances
Operations Maintenance Layout Scene Series - Run remote shell scripts
Operations Maintenance Layout Scene Series - Run Ansible-playbook on an ECS instance
Operations and Maintenance Layout Scene Series - Download JVM Stack to OSS
Operations and Maintenance Layout Series Scenario - Converting the fixed public network IP of an instance to another new EIP
Operations Maintenance Layout Scene Series - Automatic Timing Upgrade Temporary Bandwidth
Operations Maintenance Layout Scene Series - Bulk Update Cloud Assistant Client
Operations Maintenance Layout Series Scenarios - Bulk Release Instances
Operations Maintenance Layout Scene Series - ECS instance system snapshots downloaded locally
Operations and Maintenance Layout Scene Series - Batch Change System Disk
Operations and Maintenance Layout Scene Series - Automatically create multiple areas with the same type of storage

Tags: Linux JSON shell ansible

Posted on Thu, 19 Dec 2019 02:36:12 -0500 by Akinraze