7.6. Playbook の使用
このドキュメントでは、すべてではありませんが、一部の Playbook を説明します。ここでは、Ansible on Clouds デプロイメントから情報を取得するか、情報を確認するために使用されるものを説明します。これらの 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 は、追加または更新する key=value ペアのコンマ区切りのリストです。たとえば、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 on Cloud のバージョンがコマンドジェネレーターコンテナーと同じかどうかを確認します。この確認は、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
failed がゼロ以外の場合は、Ansible on Clouds デプロイメントのバージョンが command_generator コンテナーと一致せず、コマンドジェネレーターがそのデプロイメントを管理するには別のバージョンが必要であることを示します。
aws_get_aoc_version
この Playbook は、Ansible on Clouds デプロイメントのバージョンを取得します。
$ 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