Configuration as Code


Red Hat Ansible Automation Platform 2.6

設定ファイルを使用した Ansible Automation Platform Controller の設定と管理

Red Hat Customer Content Services

概要

このガイドでは、Configuration as Code アプローチを使用して Ansible Automation Platform Controller を効率的に設定することで、時間の節約、エラーの削減、エンタープライズ自動化の迅速な拡張を実現する方法を説明します。

Red Hat ドキュメントへのフィードバック (英語のみ)

このドキュメントの改善に関するご意見がある場合や、エラーを発見した場合は、https://access.redhat.com からテクニカルサポートに連絡してリクエストを送信してください。

第1章 Configuration as Code 用の自動化環境のセットアップ

Configuration as Code は、Web UI をクリックする代わりに、バージョン管理された設定ファイル (YAML や JSON など) を使用して Ansible Automation Platform 自体の設定を定義および管理する方法です。

Ansible コンテンツ開発者は、Configuration as Code アプローチを使用して自動化コントローラーに設定を適用できます。このアプローチには、次のような利点があります。

  • 予測可能なジョブの挙動
  • 新規クラスターへの容易かつ迅速なスケーリング
  • バージョン管理への対応が実現する差分とロールバック機能を備えた変更履歴
  • 障害や移行後の迅速な復旧
  • CI/CD パイプラインとプルリクエストを通じた変更 (ピアレビューおよび自動テストが適用される) によるエラーリスクの軽減

前提条件

  • Git アカウントがある。
  • プラットフォームゲートウェイインスタンスにアクセスできる。
  • 独自の実行環境をビルドして登録した。または、ansible.platform コレクションを使用する Playbook を実行するために使用できるサポート対象の実行環境がある。詳細は、実行環境の作成と使用 を参照してください。

手順

  1. 新しい Git リポジトリーを作成します。
  2. ローカルマシンで、プラットフォームゲートウェイのパスワードを暗号化します。

    $ ansible-vault encrypt_string '<gateway_password>' --name 'aap_password'
    New Vault password: <vault_password>
    Confirm New Vault password: <vault_password>
    Encryption successful
    aap_password: !vault |
              $ANSIBLE_VAULT;1.1;AES256
              63633763653530343566363864333130656433613634333465363733326261336465333362623635
              3061333439626238616332313663633431663962353735320a633732346232396165373931653039
              64326462306162396366373565316631343033656230363038623237313036613166313331623533
              3363636462646534330a616437646665393738386235306361653333313338656563346633396434
              35346164656437326231326433323934643133353436323562373762616531326463
    Copy to Clipboard Toggle word wrap

    次のステップで使用する aap_password 変数の値を暗号化しました。

  3. Ansible Automation Platform に接続するための変数と、ロールベースのアクセス制御 (RBAC) オブジェクトを作成するための変数を格納した /my_ansible_project/vars/all.yml ファイルを作成します。

    ---
    # Ansible Automation Platform related variables
    aap_hostname: "<GATEWAY>"
    aap_username: "<GATEWAY_USER>"
    aap_password: !vault |
              $ANSIBLE_VAULT;1.1;AES256
              63633763653530343566363864333130656433613634333465363733326261336465333362623635
              3061333439626238616332313663633431663962353735320a633732346232396165373931653039
              64326462306162396366373565316631343033656230363038623237313036613166313331623533
              3363636462646534330a616437646665393738386235306361653333313338656563346633396434
              35346164656437326231326433323934643133353436323562373762616531326463
    aap_validate_certs: false
    
    # Details for creating organization, team, and user
    org_name: "Demo-Organization"
    team_name: "Demo-Team"
    user_username: "Demo-User"
    user_email: "demo.user@example.com"
    user_password: "3ncrypt3d_P@$$word"
    
    # Role names as they exist in your Ansible Automation Platform
    role_for_team_in_org: "Organization Inventory Admin" # "Executor"
    role_for_user_in_org: "Organization Auditor"
    role_for_user_in_team: "Auditor" # if your platform supports team-scoped roles
    
    # Custom role definition details
    custom_role_name: "NetOps ReadOnly"
    custom_role_description: "Read-only access to network objects"
    Copy to Clipboard Toggle word wrap
  4. /my_ansible_project/RBAC_settings.yml Playbook を作成します。この Playbook は、RBAC オブジェクトを作成し、それらのオブジェクトにロールを割り当てます。

    ---
    - name: Create RBAC objects and assign roles to them
      hosts: localhost
      gather_facts: false
      vars_files:
        - ./vars/all.yml
      tasks:
        - name: Ensure new organization exists
          ansible.platform.organization:
            name: "{{ org_name }}"
            state: present
            aap_hostname: "{{ aap_hostname }}"
            aap_username: "{{ aap_username }}"
            aap_password: "{{ aap_password }}"
            aap_validate_certs: "{{ aap_validate_certs }}"
    
        - name: Ensure new team exists in organization
          ansible.platform.team:
            name: "{{ team_name }}"
            organization: "{{ org_name }}"
            state: present
            aap_hostname: "{{ aap_hostname }}"
            aap_username: "{{ aap_username }}"
            aap_password: "{{ aap_password }}"
            aap_validate_certs: "{{ aap_validate_certs }}"
    
        - name: Ensure new user exists
          ansible.platform.user:
            username: "{{ user_username }}"
            email: "{{ user_email }}"
            password: "{{ user_password }}"
            state: present
            aap_hostname: "{{ aap_hostname }}"
            aap_username: "{{ aap_username }}"
            aap_password: "{{ aap_password }}"
            aap_validate_certs: "{{ aap_validate_certs }}"
    
        - name: Ensure new custom role exists
          ansible.platform.role_definition:
            name: "{{ custom_role_name }}"
            description: "{{ custom_role_description }}"
            content_type: awx.inventory
            permissions:
              - awx.view_inventory
              - awx.change_inventory
            state: present
            aap_hostname: "{{ aap_hostname }}"
            aap_username: "{{ aap_username }}"
            aap_password: "{{ aap_password }}"
            aap_validate_certs: "{{ aap_validate_certs }}"
    
        - name: Assign already existing role to team in organization
          ansible.platform.role_team_assignment:
            team: "{{ team_name }}"
            assignment_objects:
              - name: "{{ org_name }}"
                type: "organizations"
            role_definition: "{{ role_for_team_in_org }}"
            state: present
            aap_hostname: "{{ aap_hostname }}"
            aap_username: "{{ aap_username }}"
            aap_password: "{{ aap_password }}"
            aap_validate_certs: "{{ aap_validate_certs }}"
    
        - name: Assign already existing role to user in organization
          ansible.platform.role_user_assignment:
            user: "{{ user_username }}"
            object_ids:
              - "{{ org_name }}"
            role_definition: "{{ role_for_user_in_org }}"
            state: present
            aap_hostname: "{{ aap_hostname }}"
            aap_username: "{{ aap_username }}"
            aap_password: "{{ aap_password }}"
            aap_validate_certs: "{{ aap_validate_certs }}"
    Copy to Clipboard Toggle word wrap

    この Playbook 内の多くの値は、オブジェクト名、その詳細、Ansible Automation Platform 認証情報などの変数形式で提供されます。Ansible プロジェクト内のすべてのファイルで変数を簡単に再利用できるため、プロジェクトの作成と保守が単純化され、エラーの数も減ります。

    これらの変数の拡張された値を確認するには、all.yml ファイルを参照してください。モジュールパラメーター、デフォルト値、モジュールの使用方法の詳細な例は、Automation Hub の ansible.platform コレクションのリソースを参照してください。

  5. 後で Automation Controller が正しいデータを読み取ることができるように、変数と Playbook を Git リポジトリーにプッシュします。

    git add .
    git commit -m "Provide variables and RBAC_settings.yml playbook resources for Ansible Automation Platform project"
    git push origin _<relevant_branch_name>_
    Copy to Clipboard Toggle word wrap
  6. プラットフォームゲートウェイ UI を使用して、次の値を持つ新規プロジェクトを作成します。

    • Name: Platform collection testing
    • Description: Automation resources to test the CaC capability of RBAC modules from the ansible.platform collection
    • Execution Environment: ee-supported
    • Organization: Default
    • Source Control Type: Git
    • Source Control URL: https://my_git_url/my_git_repository/my_ansible_project

  7. 暗号化された aap_password 変数の Ansible Vault パスワードの認証情報を作成します。

    • Name: aap_password_vault
    • Description: Holds vault password for decrypting the value of the aap_password variable
    • Credential type: Vault
    • Vault Password: <vault_password>

  8. 次の値を持つジョブテンプレートを作成します。

    • Name: RBAC_settings
    • Description: Create organization, team, user, and custom role RBAC objects.Assign a pre-existing role to the created team and assign a pre-existing role to the created user.
    • Job type: Run
    • Inventory: Demo Inventory
    • Project: Platform collection testing
    • Playbook: RBAC_settings.yml
    • Execution Environment: ee-supported
    • Credentials: aap_password_vault | Vault

  9. RBAC_settings ジョブテンプレートを起動します。テンプレートジョブが正常に終了すると、出力は次のようになります。

    Vault password:
    [WARNING]: Collection ansible.platform does not support Ansible version 2.15.13
    
    PLAY [Create organization] *****************************************************
    
    TASK [Ensure new organization exists] ******************************************
    changed: [localhost]
    
    PLAY [Create team] *************************************************************
    
    TASK [Ensure new team exists in organization] **********************************
    changed: [localhost]
    
    PLAY [Create user] *************************************************************
    
    TASK [Ensure new user exists] **************************************************
    changed: [localhost]
    
    PLAY [Create custom role] ******************************************************
    
    TASK [Ensure new custom role exists] *******************************************
    changed: [localhost]
    
    PLAY [Team gets role] **********************************************************
    
    TASK [Assign already existing role to team in organization] ********************
    changed: [localhost]
    
    PLAY [User gets role] **********************************************************
    
    TASK [Assign already existing role to user in organization] ********************
    changed: [localhost]
    
    PLAY RECAP *********************************************************************
    localhost: ok=6 changed=6 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
    Copy to Clipboard Toggle word wrap

    出力メッセージには、ジョブテンプレートを 1 つのターゲット (ローカルホスト) に対して実行したことが示されます。同時に、以下が作成されました。

    • 組織。
    • 作成された組織内に存在するチーム。チームには、何らかの既存ロールが割り当てられています。
    • 作成された組織内に存在するユーザー。ユーザーには、何らかの既存のロールが割り当てられています。
    • カスタムロール。

検証

  • ナビゲーションパネルで、作成した組織が表示されていることを確認します。

  • 作成したチームが組織に属しており、正しい既存ロールが割り当てられていることを確認します。

  • 作成したユーザーが組織に属しており、正しい既存ロールが割り当てられていることを確認します。

  • 作成したカスタムロールが表示され、RBAC_settings.yml Playbook で指定したとおりの権限が割り当てられていることを確認します。

法律上の通知

Copyright © 2025 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat