Tous les produits
Search
Centre de documentation

CloudOps Orchestration Service:ACS-ECS-ApplyAnsiblePlayBooks

Dernière mise à jour :Aug 11, 2026

Nom du modèle

Le modèle ACS-ECS-ApplyAnsiblePlayBooks exécute un playbook Ansible sur une instance.

Exécuter maintenant

Description du modèle

Ce modèle exécute un playbook Ansible sur une instance ECS. Seuls les systèmes CentOS, Alibaba Cloud Linux et Ubuntu sont pris en charge.

Type de modèle

Automatisation

Propriétaire

Alibaba Cloud

Paramètres d'entrée

Nom du paramètre

Description

Type

Obligatoire

Valeur par défaut

Contraintes

targets

Instances cibles.

JSON

Oui

sourceType

Type de stockage du playbook.

String

Oui

sourcePath

URL de stockage du playbook.

String

Oui

playbookFile

Nom du playbook à exécuter.

String

Oui

regionId

ID de la région.

String

Non

{{ ACS::RegionId }}

tokenInfo

Jeton utilisé pour télécharger le playbook.

String

Non

""

hosts

Fichier hosts utilisé pour exécuter le playbook.

String

Non

/etc/ansible/hosts

installDependencies

Indique si OOS installe Ansible et ses dépendances depuis le référentiel Python Package Index (PyPI).

Boolean

Non

True

workingDir

Répertoire d'exécution du playbook.

String

Non

/root/ansible-workspace

check

Vérifie l'exécution Ansible à l'aide du paramètre check.

Boolean

Non

True

extraVariables

Variables supplémentaires transmises à Ansible lors de l'exécution.

String

Non

color=red

Expression régulière de validation de chaîne : ^$

^\w+=\S+(\s\w+=\S+)*$

verbose

Niveau de verbosité des journaux d'exécution du playbook.

String

Non

-v

rateControl

Taux de simultanéité de l'exécution des tâches.

JSON

Non

{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10}

OOSAssumeRole

Rôle Resource Access Management (RAM) endossé par OOS.

String

Non

""

Paramètres de sortie

Nom du paramètre

Description

Type

commandOutput

String

Politique d'accès requise pour exécuter ce modèle

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeInstances",
                "ecs:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Détails

Détails de ACS-ECS-ApplyAnsiblePlayBooks

Contenu du modèle

FormatVersion: OOS-2019-06-01
Description:
  en: 'Use this template to run an Ansible playbook on an ECS instance. This template supports only CentOS, Alibaba Cloud Linux, and Ubuntu.'
  zh-cn: 'Use this template to run an Ansible Playbook on an ECS instance. This template supports only CentOS, Alibaba Cloud Linux, and Ubuntu.'
  name-en: ACS-ECS-ApplyAnsiblePlayBooks
  name-zh-cn: Run an Ansible Playbook in an instance
  categories:
    - run_command
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: Region ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  targets:
    Label:
      en: TargetInstance
      zh-cn: Target instance
    Type: Json
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: regionId
  sourceType:
    Type: String
    Label:
      en: SourceType
      zh-cn: The storage type of the playbook
    AllowedValues:
      - oss
      - https
      - github
  sourcePath:
    Type: String
    Label:
      en: SourcePath
      zh-cn: The URL where the playbook is stored.
    Description:
      en: 'Specify the URL in a format such as https://example.com/playbook.yml'
      zh-cn: 'Specify the URL in a format such as https://example.com/playbook.yml'
  playbookFile:
    Label:
      en: PlaybookFile
      zh-cn: The name of the playbook to run.
    Description:
      en: 'For example: example.yml'
      zh-cn: 'For example: example.yml'
    Type: String
  tokenInfo:
    Type: String
    Label:
      en: TokenInfo
      zh-cn: The token used to download the playbook.
    Description:
      en: 'Required only when you download a playbook from GitHub.'
      zh-cn: 'Required only when you download a playbook from GitHub.'
    Default: ""
  hosts:
    Type: String
    Label:
      en: Hosts
      zh-cn: The hosts file used to run the playbook.
    Default: /etc/ansible/hosts
  installDependencies:
    Label:
      en: InstallDependencies
      zh-cn: Specifies whether OOS installs Ansible and its dependencies from the PyPI repository.
    Description:
      en: 'If set to True, OOS installs Ansible and its dependencies, including Python, from the PyPI repository. If set to False, verify that Ansible and its dependencies are installed on the target instances.'
      zh-cn: 'If set to True, OOS installs Ansible and its dependencies, including Python, from the PyPI repository. If set to False, verify that Ansible and its dependencies are installed on the target instances.'
    Type: Boolean
    Default: true
  workingDir:
    Label:
      en: WorkingDir
      zh-cn: The directory where the playbook is run.
    Type: String
    Default: /root/ansible-workspace
  check:
    Label:
      en: Check
      zh-cn: Runs an Ansible execution check using the check parameter.
    Type: Boolean
    Default: true
  extraVariables:
    Type: String
    Label:
      en: ExtraVariables
      zh-cn: The extra variables that are passed to Ansible at runtime.
    Description:
      en: 'Enter a space-separated list of key-value pairs. For example: color=red flavor=lime'
      zh-cn: 'Enter a space-separated list of key-value pairs. For example: color=red flavor=lime'
    Default: color=red
    AllowedPattern: ^$|^\w+\=\S+(\s\w+\=\S+)*$
  verbose:
    Type: String
    Label:
      en: Verbose
      zh-cn: The verbosity level for logging the playbook execution.
    Description:
      en: 'Specify -v for low verbosity, -vv or -vvv for medium verbosity, and -vvvv for the debug level.'
      zh-cn: 'Specify -v for low verbosity, -vv or -vvv for medium verbosity, and -vvvv for the debug level.'
    AllowedValues:
      - '-v'
      - '-vv'
      - '-vvv'
      - '-vvvv'
    Default: '-v'
  rateControl:
    Label:
      en: RateControl
      zh-cn: The concurrency rate of the task execution.
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: The RAM role that OOS assumes.
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: Views the ECS instances
      zh-cn: Get ECS instances.
    Action: 'ACS::SelectTargets'
    Properties:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: '{{ regionId }}'
      Filters:
        - '{{ targets }}'
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: 'Instances.Instance[].InstanceId'
  - Name: applyPlaybook
    Action: 'ACS::ECS::ApplyAnsiblePlayBook'
    Description:
      en: Apply the specified playbook
      zh-cn: Apply the specified playbook.
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
      sourceType: '{{ sourceType }}'
      sourcePath: '{{ sourcePath }}'
      playbookFile: '{{ playbookFile }}'
      tokenInfo: '{{ tokenInfo }}'
      hosts: '{{ hosts }}'
      installDependencies: '{{ installDependencies }}'
      workingDir: '{{ workingDir }}'
      check: '{{ check }}'
      extraVariables: '{{ extraVariables }}'
      verbose: '{{ verbose }}'
    Loop:
      Items: '{{ getInstance.instanceIds }}'
      RateControl: '{{ rateControl }}'
      Outputs:
        commandOutputs:
          AggregateType: 'Fn::ListJoin'
          AggregateField: commandOutput
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: commandOutput
Outputs:
  commandOutput:
    Type: String
    Value: '{{ applyPlaybook.commandOutputs }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - sourceType
          - sourcePath
          - playbookFile
          - tokenInfo
          - hosts
          - installDependencies
          - workingDir
          - check
          - extraVariables
          - verbose
        Label:
          default:
            zh-cn: Configure parameters
            en: Configure parameters
      - Parameters:
          - regionId
          - targets
        Label:
          default:
            zh-cn: Select instances
            en: Select instances
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: Advanced options
            en: Advanced options