7.6. 使用 playbook
本文档中描述了一些,但不是所有 playbook。在这里,用于从云部署上的 Ansible 检索信息或检查信息的用户已描述。这些 playbook 不修改部署。
aws_add_labels
此 playbook 为部署添加标签。
$ docker run --rm $IMAGE command_generator_vars aws_add_labels
生成以下输出:
=============================================== Playbook: aws_add_labels Description: This playbook adds labels to the deployment. ----------------------------------------------- Add labels to the Ansible Automation Platform from AWS Marketplace deployment. ----------------------------------------------- Command generator template: docker run --rm $IMAGE command_generator aws_add_labels -d <deployment_name> -c <cloud_credentials_path> --extra-vars 'aws_region=<aws_region> aws_labels=<aws_labels>' ===============================================
参数 aws_labels 是以逗号分隔的 键=值对列表,用于添加或更新。例如: key1=value1,key2=value2
通过替换参数启动这个命令会生成新命令来启动和输出:
... PLAY RECAP ********************************************************************* localhost : ok=22 changed=2 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
aws_check_aoc_version
此 playbook 检查云版本的 Ansible 是否与命令生成器容器相同。每次调用 playbook 时都会进行检查。
$ docker run --rm $IMAGE command_generator_vars aws_check_aoc_version
生成以下输出:
=============================================== Playbook: aws_check_aoc_version Description: Check the operational container version matches the Ansible on Clouds version. ----------------------------------------------- Check the operational container version matches the Ansible on Clouds version. ----------------------------------------------- Command generator template: docker run --rm $IMAGE command_generator aws_check_aoc_version [--ansible-config ansible_config_path>] -d <deployment_name> -c <cloud_credentials_path> --extra-vars 'aws_region=<aws_region> aws_ssm_bucket_name=<aws_ssm_bucket_name>' ===============================================
通过替换参数启动这个命令会生成新命令来启动和输出:
...
TASK [redhat.ansible_on_clouds.standalone_check_aoc_version : Verify operational playbook and Ansible on Clouds deployment versions] ***
fatal: [localhost]: FAILED! => {
"assertion": "ops_version == aoc_version",
"changed": false,
"evaluated_to": false,
"msg": "This operation playbook version 2.4.20230606-00 is not valid for the Ansible on Clouds deployment version 2.4.20230531-00"
}
PLAY RECAP *********************************************************************
localhost : ok=7 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
失败 为零表示 Clouds 部署版本的 Ansible 与 command_generator 容器不匹配,而命令生成器需要不同的版本来管理该部署。
aws_get_aoc_version
此 playbook 在云部署中检索 Ansible 的版本。
$ docker run --rm $IMAGE command_generator_vars aws_get_aoc_version
生成以下输出:
=============================================== Playbook: aws_get_aoc_version Description: Get the current Ansible on Clouds version. ----------------------------------------------- Get the current Ansible on Clouds version. ----------------------------------------------- Command generator template: docker run --rm $IMAGE command_generator aws_get_aoc_version [--ansible-config ansible_config_path>] -d <deployment_name> -c <cloud_credentials_path> --extra-vars 'aws_region=<aws_region> aws_ssm_bucket_name=<aws_ssm_bucket_name>' ===============================================
通过替换参数启动这个命令会生成新命令来启动和输出:
...
TASK [Print version] ***********************************************************
ok: [localhost] => {
"msg": "The AOC version is 2.4.20230531-00"
}
PLAY RECAP *********************************************************************
localhost : ok=5 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0aws_remove_labels
此 playbook 从部署中删除标签。
$ docker run --rm $IMAGE command_generator_vars aws_remove_labels
生成以下输出:
=============================================== Playbook: aws_remove_labels Description: This playbook removes labels from the deployment. ----------------------------------------------- Remove labels from the Ansible Automation Platform from AWS Marketplace deployment. ----------------------------------------------- Command generator template: docker run --rm $IMAGE command_generator aws_remove_labels -d <deployment_name> -c <cloud_credentials_path> --extra-vars 'aws_region=<aws_region> aws_labels=<aws_labels>' ===============================================
参数 aws_labels 是要删除的单个密钥。例如,key1。要删除多个密钥,请多次运行命令。
通过替换参数启动这个命令会生成新命令来启动和输出:
... PLAY RECAP ********************************************************************* localhost : ok=22 changed=2 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0