第6章 コンテンツの作成
Red Hat Ansible Automation Platform で使用するコンテンツの開発に関する詳細は、作成者ガイド でこのセクションに関するガイドラインを参照してしてください。
6.1. Playbook の作成
Playbook には、1 つ以上のプレイが含まれます。基本的なプレイには以下のセクションが含まれます。
- Name: Playbook の全体的な機能について簡単に説明し、全ユーザーに対して読み取り可能かつ整理された状態を維持するのに役立ちます。
- Hosts: Ansible が実行するターゲットを特定します。
-
become ステートメント: この任意のステートメントは、become プラグイン (例:
sudo、su、pfexec、doas、pbrun、dzdo、ksu) を使用して権限のエスカレーションを有効にするためにtrue/yesに設定できます。 - tasks: これは、プレイの各ホストに対して実行されるアクションのリストです。
Playbook の例
- name: Set Up a Project and Job Template
hosts: host.name.ip
become: true
tasks:
- name: Create a Project
ansible.controller.project:
name: Job Template Test Project
state: present
scm_type: git
scm_url: https://github.com/ansible/ansible-tower-samples.git
- name: Create a Job Template
ansible.controller.job_template:
name: my-job-1
project: Job Template Test Project
inventory: Demo Inventory
playbook: hello_world.yml
job_type: run
state: present