Nama templat
ACS-ECS-ApplyAnsiblePlayBooks menjalankan Ansible Playbook pada sebuah Instance ECS.
Deskripsi templat
Menjalankan Ansible Playbook pada Instance ECS. Sistem operasi yang didukung: CentOS, Alibaba Cloud Linux, dan Ubuntu.
Jenis templat
Otomatisasi
Pemilik
Alibaba Cloud
Parameter input
|
Nama parameter |
Deskripsi |
Tipe |
Wajib |
Nilai default |
Batasan |
|
|
targets |
Instans target. |
JSON |
Ya |
|||
|
sourceType |
Tipe penyimpanan playbook. |
String |
Ya |
|||
|
sourcePath |
URL tempat playbook disimpan. |
String |
Ya |
|||
|
playbookFile |
Nama playbook yang akan dijalankan. |
String |
Ya |
|||
|
regionId |
ID Wilayah. |
String |
Tidak |
{{ ACS::RegionId }} |
||
|
tokenInfo |
Token yang digunakan untuk mengunduh playbook. |
String |
Tidak |
"" |
||
|
hosts |
File hosts yang digunakan untuk menjalankan playbook. |
String |
Tidak |
/etc/ansible/hosts |
||
|
installDependencies |
Apakah OOS menginstal Ansible dan dependensinya dari repositori Python Package Index (PyPI). |
Boolean |
Tidak |
True |
||
|
workingDir |
Direktori tempat playbook dijalankan. |
String |
Tidak |
/root/ansible-workspace |
||
|
check |
Menjalankan pemeriksaan eksekusi Ansible menggunakan parameter check. |
Boolean |
Tidak |
True |
||
|
extraVariables |
Variabel tambahan yang diteruskan ke Ansible saat waktu proses. |
String |
Tidak |
color=red |
Ekspresi reguler validasi string: ^$ |
^\w+=\S+(\s\w+=\S+)*$ |
|
verbose |
Tingkat verbosity untuk mencatat eksekusi playbook. |
String |
Tidak |
-v |
||
|
rateControl |
Laju konkurensi eksekusi tugas. |
JSON |
Tidak |
{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10} |
||
|
OOSAssumeRole |
Peran Resource Access Management (RAM) yang diasumsikan oleh OOS. |
String |
Tidak |
"" |
Parameter output
|
Nama parameter |
Deskripsi |
Tipe |
|
commandOutput |
String |
Kebijakan akses yang diperlukan untuk menjalankan templat ini
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Detail
Detail ACS-ECS-ApplyAnsiblePlayBooks
Konten templat
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