1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ansible Automation Platform の構成情報の取得: curl コマンドで json 出力

1
Posted at

はじめに

Ansible Automation Platform (AAP) の構成情報を REST API + curl で一括バックアップする方法をまとめました。

この記事でできること:

  • AAP の主要リソース(Organization / Project / Inventory / Job Template 等)を JSON ファイルとしてエクスポート
  • バックアップの差分確認・環境移行時の参考情報として活用
  • awx CLI や infra.aap_configuration を使わず、curl のみで完結

対象読者:

  • AAP の運用・管理を行っているインフラエンジニア
  • 構成管理や DR 対策として AAP のバックアップを検討している方

動画

当記事の内容を動画にしました。理解の一助にご参照ください。


環境

Ansible Automation Platform 2.6 (Container install 版)
OS: RHEL 10.1


前提

  • awx コマンドは使用しない
  • infra.aap_configuration コレクションは使用しない
  • AAP が提供する Automation Controller REST API のみを利用する

【必要項目】

  • AAP Controller への HTTPS アクセス
  • 管理者権限または参照権限を持つ AAP ユーザー名・パスワード
  • curl コマンド
  • jq コマンド(JSON 整形用)
  • ansible ユーザーで実行

【認証方針】
Bearer Token ではなく、ユーザー名・パスワードを使用して REST API を実行する。
curl コマンドでは -u "${AAP_USER}:${AAP_PASSWORD}" を指定する。
パスワードはスクリプトやファイルに平文で保存せず、実行時に対話入力する。

【API で取得できない情報(セキュリティ上の理由)】

  • Credential Secret / パスワード
  • SSH 秘密鍵
  • OAuth Token
  • Vault Password

取得対象一覧

# リソース API エンドポイント 出力ファイル
1 Organization /api/controller/v2/organizations/ organizations.json
2 User /api/controller/v2/users/ users.json
3 Project /api/controller/v2/projects/ projects.json
4 Inventory /api/controller/v2/inventories/ inventories.json
5 Host /api/controller/v2/hosts/ hosts.json
6 Credential /api/controller/v2/credentials/ credentials.json
7 Credential Type /api/controller/v2/credential_types/ credential_types.json
8 Settings - Jobs /api/controller/v2/settings/jobs/ settings_jobs.json
9 Schedule /api/controller/v2/schedules/ schedules.json
10 Job Template /api/controller/v2/job_templates/ job_templates.json
11 Workflow Job Template /api/controller/v2/workflow_job_templates/ workflow_templates.json
12 Execution Environment /api/controller/v2/execution_environments/ execution_environments.json

手順

作業ディレクトリの準備

対象サーバーへログイン後、ansible ユーザーに切り替え、作業ディレクトリを作成します。

sudo su - ansible
cd /home/ansible
mkdir /home/ansible/config_backup

環境変数設定

  • AAP_HOST
export AAP_HOST=https://xx.xx.xx.xx

AAPサーバー内部から実行する場合、inventory の controller node を指定

  • AAP_USER
export AAP_USER=admin
  • AAP_PASSWORD
read -s -p "AAP Password: " AAP_PASSWORD; echo

-> admin パスワードを入力


ここから情報取得のコマンドです。

Organization

curl -sk -u "${AAP_USER}:${AAP_PASSWORD}" ${AAP_HOST}/api/controller/v2/organizations/  > /home/ansible/config_backup/organizations.json
取得ログ抜粋
$ cat organizations.json | jq 
{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 1,
      "type": "organization",
      "url": "/api/controller/v2/organizations/1/",
      "related": {
        "created_by": "/api/controller/v2/users/1/",
        "modified_by": "/api/controller/v2/users/1/",
        "execution_environments": "/api/controller/v2/organizations/1/execution_environments/",
        "projects": "/api/controller/v2/organizations/1/projects/",
        "inventories": "/api/controller/v2/organizations/1/inventories/",
        "job_templates": "/api/controller/v2/organizations/1/job_templates/",
        "workflow_job_templates": "/api/controller/v2/organizations/1/workflow_job_templates/",
        "users": "/api/controller/v2/organizations/1/users/",
        "admins": "/api/controller/v2/organizations/1/admins/",
        "teams": "/api/controller/v2/organizations/1/teams/",
        "credentials": "/api/controller/v2/organizations/1/credentials/",
        "applications": "/api/controller/v2/organizations/1/applications/",
        "activity_stream": "/api/controller/v2/organizations/1/activity_stream/",
        "notification_templates": "/api/controller/v2/organizations/1/notification_templates/",
        "notification_templates_started": "/api/controller/v2/organizations/1/notification_templates
_started/",
        "notification_templates_success": "/api/controller/v2/organizations/1/notification_templates
_success/",
        "notification_templates_error": "/api/controller/v2/organizations/1/notification_templates_e
rror/",
        "notification_templates_approvals": "/api/controller/v2/organizations/1/notification_templat
es_approvals/",
        "object_roles": "/api/controller/v2/organizations/1/object_roles/",
        "access_list": "/api/controller/v2/organizations/1/access_list/",
        "instance_groups": "/api/controller/v2/organizations/1/instance_groups/",
        "galaxy_credentials": "/api/controller/v2/organizations/1/galaxy_credentials/"
      },
      "summary_fields": {
        "resource": {
          "ansible_id": "58c13557-0cc8-4737-ad6c-5d1b7830daad",
          "resource_type": "shared.organization"
        },
        "created_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "modified_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "object_roles": {
          "admin_role": {
            "description": "Can manage all aspects of the organization",
            "name": "Admin",
            "id": 9,
            "user_only": true
          },
          "execute_role": {
            "description": "May run any executable resources in the organization",
            "name": "Execute",
            "id": 10
          },
          "project_admin_role": {
            "description": "Can manage all projects of the organization",
            "name": "Project Admin",
            "id": 11
          },
          "inventory_admin_role": {
            "description": "Can manage all inventories of the organization",
            "name": "Inventory Admin",
            "id": 12
          },
          "credential_admin_role": {
            "description": "Can manage all credentials of the organization",
            "name": "Credential Admin",
            "id": 13
          },
          "workflow_admin_role": {
            "description": "Can manage all workflows of the organization",
            "name": "Workflow Admin",
            "id": 14
          },
          "notification_admin_role": {
            "description": "Can manage all notifications of the organization",
            "name": "Notification Admin",
            "id": 15
          },
          "job_template_admin_role": {
            "description": "Can manage all job templates of the organization",
            "name": "Job Template Admin",
            "id": 16
          },
          "execution_environment_admin_role": {
            "description": "Can manage all execution environments of the organization",
            "name": "Execution Environment Admin",
            "id": 17
          },
          "auditor_role": {
            "description": "Can view all aspects of the organization",
            "name": "Auditor",
            "id": 18
          },
          "member_role": {
            "description": "User is a member of the organization",
            "name": "Member",
            "id": 19,
            "user_only": true
          },
          "read_role": {
            "description": "May view settings for the organization",
            "name": "Read",
            "id": 20
          },
          "approval_role": {
            "description": "Can approve or deny a workflow approval node",
            "name": "Approve",
            "id": 21
          }
        },
        "user_capabilities": {
          "edit": true,
          "delete": true
        },
        "related_field_counts": {
          "inventories": 6,
          "teams": 0,
          "users": 0,
          "job_templates": 54,
          "admins": 0,
          "projects": 9
        }
      },
      "created": "2026-04-06T02:33:32.318026Z",
      "modified": "2026-04-06T02:44:06.690001Z",
      "name": "Default",
      "description": "The default organization for Ansible Automation Platform",
      "max_hosts": 0,
      "custom_virtualenv": null,
      "default_environment": null,
      "opa_query_path": null
    }
  ]
}


User

curl -sk -u "${AAP_USER}:${AAP_PASSWORD}" ${AAP_HOST}/api/controller/v2/users/   > /home/ansible/config_backup/users.json
取得ログ抜粋
$ cat users.json | jq
{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 1,
      "type": "user",
      "url": "/api/controller/v2/users/1/",
      "related": {
        "teams": "/api/controller/v2/users/1/teams/",
        "organizations": "/api/controller/v2/users/1/organizations/",
        "admin_of_organizations": "/api/controller/v2/users/1/admin_of_organizations/",
        "projects": "/api/controller/v2/users/1/projects/",
        "credentials": "/api/controller/v2/users/1/credentials/",
        "roles": "/api/controller/v2/users/1/roles/",
        "activity_stream": "/api/controller/v2/users/1/activity_stream/",
        "access_list": "/api/controller/v2/users/1/access_list/",
        "tokens": "/api/controller/v2/users/1/tokens/",
        "authorized_tokens": "/api/controller/v2/users/1/authorized_tokens/",
        "personal_tokens": "/api/controller/v2/users/1/personal_tokens/"
      },
      "summary_fields": {
        "resource": {
          "ansible_id": "73dab394-e544-46c5-8d41-e30dd8435454",
          "resource_type": "shared.user"
        },
        "user_capabilities": {
          "edit": true,
          "delete": false
        }
      },
      "created": "2026-04-06T02:33:20.859654Z",
      "modified": null,
      "username": "adminXX",
      "first_name": "",
      "last_name": "",
      "email": "admin@example.com",
      "is_superuser": true,
      "is_system_auditor": false,
      "password": "$encrypted$",
      "ldap_dn": "",
      "last_login": null,
      "external_account": null,
      "auth": []
    }
  ]
}

Project

curl -sk -u "${AAP_USER}:${AAP_PASSWORD}" ${AAP_HOST}/api/controller/v2/projects/  > /home/ansible/config_backup/projects.json
取得ログ抜粋
$ cat projects.json | jq | more
{
  "count": 9,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 6,
      "type": "project",
      "url": "/api/controller/v2/projects/6/",
      "related": {
        "created_by": "/api/controller/v2/users/1/",
        "modified_by": "/api/controller/v2/users/1/",
        "teams": "/api/controller/v2/projects/6/teams/",
        "playbooks": "/api/controller/v2/projects/6/playbooks/",
        "inventory_files": "/api/controller/v2/projects/6/inventories/",
        "update": "/api/controller/v2/projects/6/update/",
        "project_updates": "/api/controller/v2/projects/6/project_updates/",
        "scm_inventory_sources": "/api/controller/v2/projects/6/scm_inventory_sources/",
        "schedules": "/api/controller/v2/projects/6/schedules/",
        "activity_stream": "/api/controller/v2/projects/6/activity_stream/",
        "notification_templates_started": "/api/controller/v2/projects/6/notification_templates_star
ted/",
        "notification_templates_success": "/api/controller/v2/projects/6/notification_templates_succ
ess/",
        "notification_templates_error": "/api/controller/v2/projects/6/notification_templates_error/
",
        "access_list": "/api/controller/v2/projects/6/access_list/",
        "object_roles": "/api/controller/v2/projects/6/object_roles/",
        "copy": "/api/controller/v2/projects/6/copy/",
        "organization": "/api/controller/v2/organizations/1/"
      },
      "summary_fields": {
        "organization": {
          "id": 1,
          "name": "Default",
          "description": "The default organization for Ansible Automation Platform"
        },
        "created_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "modified_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "object_roles": {
          "admin_role": {
            "description": "Can manage all aspects of the project",
            "name": "Admin",
            "id": 22
          },
          "use_role": {
            "description": "Can use the project in a job template",
            "name": "Use",
            "id": 23
          },
          "update_role": {
            "description": "May update the project",
            "name": "Update",
            "id": 24
          },
          "read_role": {
            "description": "May view settings for the project",
            "name": "Read",
            "id": 25
          }
        },
        "user_capabilities": {
          "edit": true,
          "delete": true,
          "start": true,
          "schedule": true,
          "copy": true
        }
      },
      "created": "2026-04-06T02:33:32.748187Z",
      "modified": "2026-04-06T02:33:32.748199Z",
      "name": "Demo Project",
      "description": "",
      "local_path": "_6__demo_project",
      "scm_type": "git",
      "scm_url": "https://github.com/ansible/ansible-tower-samples",
      "scm_branch": "",
      "scm_refspec": "",
      "scm_clean": false,
      "scm_track_submodules": false,
      "scm_delete_on_update": false,
      "credential": null,
      "timeout": 0,
      "scm_revision": "347e44fea036c94d5f60e544de006453ee5c71ad",
      "last_job_run": null,
      "last_job_failed": false,
      "next_job_run": null,
      "status": "successful",
      "organization": 1,
      "scm_update_on_launch": false,
      "scm_update_cache_timeout": 0,
      "allow_override": false,
      "custom_virtualenv": null,
      "default_environment": null,
      "signature_validation_credential": null,
      "last_update_failed": false,
      "last_updated": null
    },

Inventory

curl -sk -u "${AAP_USER}:${AAP_PASSWORD}" ${AAP_HOST}/api/controller/v2/inventories/   > /home/ansible/config_backup/inventories.json
取得ログ抜粋
$ cat inventories.json | jq | more
{
  "count": 6,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 167,
      "type": "inventory",
      "url": "/api/controller/v2/inventories/167/",
      "related": {
        "created_by": "/api/controller/v2/users/1/",
        "modified_by": "/api/controller/v2/users/1/",
        "hosts": "/api/controller/v2/inventories/167/hosts/",
        "variable_data": "/api/controller/v2/inventories/167/variable_data/",
        "script": "/api/controller/v2/inventories/167/script/",
        "activity_stream": "/api/controller/v2/inventories/167/activity_stream/",
        "job_templates": "/api/controller/v2/inventories/167/job_templates/",
        "ad_hoc_commands": "/api/controller/v2/inventories/167/ad_hoc_commands/",
        "access_list": "/api/controller/v2/inventories/167/access_list/",
        "object_roles": "/api/controller/v2/inventories/167/object_roles/",
        "instance_groups": "/api/controller/v2/inventories/167/instance_groups/",
        "copy": "/api/controller/v2/inventories/167/copy/",
        "labels": "/api/controller/v2/inventories/167/labels/",
        "groups": "/api/controller/v2/inventories/167/groups/",
        "root_groups": "/api/controller/v2/inventories/167/root_groups/",
        "update_inventory_sources": "/api/controller/v2/inventories/167/update_inventory_sources/",
        "inventory_sources": "/api/controller/v2/inventories/167/inventory_sources/",
        "tree": "/api/controller/v2/inventories/167/tree/",
        "organization": "/api/controller/v2/organizations/1/"
      },
      "summary_fields": {
        "organization": {
          "id": 1,
          "name": "Default",
          "description": "The default organization for Ansible Automation Platform"
        },
        "created_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "modified_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "object_roles": {
          "admin_role": {
            "description": "Can manage all aspects of the inventory",
            "name": "Admin",
            "id": 804
          },
          "update_role": {
            "description": "May update the inventory",
            "name": "Update",
            "id": 805
          },
          "adhoc_role": {
            "description": "May run ad hoc commands on the inventory",
            "name": "Ad Hoc",
            "id": 806
          },
          "use_role": {
            "description": "Can use the inventory in a job template",
            "name": "Use",
            "id": 807
          },
          "read_role": {
            "description": "May view settings for the inventory",
            "name": "Read",
            "id": 808
          }
        },
        "user_capabilities": {
          "edit": true,
          "delete": true,
          "copy": true,
          "adhoc": true
        },
        "labels": {
          "count": 0,
          "results": []
        }
      },
      "created": "2026-06-28T09:15:57.695181Z",
      "modified": "2026-06-28T09:15:57.695191Z",
      "name": "aap-host",
      "description": "",
      "organization": 1,
      "kind": "",
      "host_filter": null,
      "variables": "",
      "has_active_failures": false,
      "total_hosts": 1,
      "hosts_with_active_failures": 0,
      "total_groups": 1,
      "has_inventory_sources": false,
      "total_inventory_sources": 0,
      "inventory_sources_with_failures": 0,
      "pending_deletion": false,
      "prevent_instance_group_fallback": false,
      "opa_query_path": ""
    },

Host

curl -sk -u "${AAP_USER}:${AAP_PASSWORD}" ${AAP_HOST}/api/controller/v2/hosts/  > /home/ansible/config_backup/hosts.json
取得ログ抜粋
$ cat hosts.json | jq | more
{
  "count": 6,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 167,
      "type": "host",
      "url": "/api/controller/v2/hosts/167/",
      "related": {
        "created_by": "/api/controller/v2/users/1/",
        "modified_by": "/api/controller/v2/users/1/",
        "variable_data": "/api/controller/v2/hosts/167/variable_data/",
        "groups": "/api/controller/v2/hosts/167/groups/",
        "all_groups": "/api/controller/v2/hosts/167/all_groups/",
        "job_events": "/api/controller/v2/hosts/167/job_events/",
        "job_host_summaries": "/api/controller/v2/hosts/167/job_host_summaries/",
        "activity_stream": "/api/controller/v2/hosts/167/activity_stream/",
        "inventory_sources": "/api/controller/v2/hosts/167/inventory_sources/",
        "smart_inventories": "/api/controller/v2/hosts/167/smart_inventories/",
        "ad_hoc_commands": "/api/controller/v2/hosts/167/ad_hoc_commands/",
        "ad_hoc_command_events": "/api/controller/v2/hosts/167/ad_hoc_command_events/",
        "ansible_facts": "/api/controller/v2/hosts/167/ansible_facts/",
        "inventory": "/api/controller/v2/inventories/167/",
        "last_job": "/api/controller/v2/jobs/1837/",
        "last_job_host_summary": "/api/controller/v2/job_host_summaries/1327/"
      },
      "summary_fields": {
        "inventory": {
          "id": 167,
          "name": "aap-host",
          "description": "",
          "has_active_failures": false,
          "total_hosts": 1,
          "hosts_with_active_failures": 0,
          "total_groups": 1,
          "has_inventory_sources": false,
          "total_inventory_sources": 0,
          "inventory_sources_with_failures": 0,
          "organization_id": 1,
          "kind": ""
        },
        "last_job": {
          "id": 1837,
          "name": "ACM接続確認",
          "description": "",
          "finished": "2026-06-28T09:23:20.571214Z",
          "status": "successful",
          "failed": false,
          "job_template_id": 324,
          "job_template_name": "ACM接続確認"
        },
        "last_job_host_summary": {
          "id": 1327,
          "failed": false
        },
        "created_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "modified_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "user_capabilities": {
          "edit": true,
          "delete": true
        },
        "groups": {
          "count": 1,
          "results": [
            {
              "id": 101,
              "name": "aap-host"
            }
          ]
        },
        "recent_jobs": [
          {
            "id": 1837,
            "name": "ACM接続確認",
            "type": "job",
            "status": "successful",
            "finished": "2026-06-28T09:23:20.571214Z"
          }
        ]
      },
      "created": "2026-06-28T09:16:54.022530Z",
      "modified": "2026-07-17T00:39:25.676617Z",
      "name": "aap-host1",
      "description": "",
      "inventory": 167,
      "enabled": true,
      "instance_id": "",
      "variables": "ansible_host: 54.64.125.59\nansible_user: ec2-user",
      "has_active_failures": false,
      "has_inventory_sources": false,
      "last_job": 1837,
      "last_job_host_summary": 1327,
      "ansible_facts_modified": null
    },

Credential

curl -sk -u "${AAP_USER}:${AAP_PASSWORD}" ${AAP_HOST}/api/controller/v2/credentials/  > /home/ansible/config_backup/credentials.json
取得ログ抜粋
$ cat credentials.json | jq | more
{
  "count": 13,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 232,
      "type": "credential",
      "url": "/api/controller/v2/credentials/232/",
      "related": {
        "created_by": "/api/controller/v2/users/1/",
        "modified_by": "/api/controller/v2/users/1/",
        "activity_stream": "/api/controller/v2/credentials/232/activity_stream/",
        "access_list": "/api/controller/v2/credentials/232/access_list/",
        "object_roles": "/api/controller/v2/credentials/232/object_roles/",
        "owner_users": "/api/controller/v2/credentials/232/owner_users/",
        "owner_teams": "/api/controller/v2/credentials/232/owner_teams/",
        "copy": "/api/controller/v2/credentials/232/copy/",
        "input_sources": "/api/controller/v2/credentials/232/input_sources/",
        "credential_type": "/api/controller/v2/credential_types/1/"
      },
      "summary_fields": {
        "credential_type": {
          "id": 1,
          "name": "Machine",
          "description": ""
        },
        "created_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "modified_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "object_roles": {
          "admin_role": {
            "description": "Can manage all aspects of the credential",
            "name": "Admin",
            "id": 809
          },
          "use_role": {
            "description": "Can use the credential in a job template",
            "name": "Use",
            "id": 810
          },
          "read_role": {
            "description": "May view settings for the credential",
            "name": "Read",
            "id": 811
          }
        },
        "user_capabilities": {
          "edit": true,
          "delete": true,
          "copy": true,
          "use": true
        },
        "owners": []
      },
      "created": "2026-06-28T09:18:41.479121Z",
      "modified": "2026-06-28T09:18:41.479132Z",
      "name": "aap-host",
      "description": "",
      "organization": null,
      "credential_type": 1,
      "managed": false,
      "inputs": {
        "username": "ec2-user",
        "ssh_key_data": "$encrypted$"
      },
      "kind": "ssh",
      "cloud": false,
      "kubernetes": false
    },

Credential Type

curl -sk -u "${AAP_USER}:${AAP_PASSWORD}" ${AAP_HOST}/api/controller/v2/credential_types/  > /home/ansible/config_backup/credential_types.json
取得ログ抜粋
$ cat credential_types.json | jq | more
    {
      "id": 69,
      "type": "credential_type",
      "url": "/api/controller/v2/credential_types/69/",
      "related": {
        "created_by": "/api/controller/v2/users/1/",
        "modified_by": "/api/controller/v2/users/1/",
        "credentials": "/api/controller/v2/credential_types/69/credentials/",
        "activity_stream": "/api/controller/v2/credential_types/69/activity_stream/"
      },
      "summary_fields": {
        "created_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "modified_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "user_capabilities": {
          "edit": true,
          "delete": true
        }
      },
      "created": "2026-05-15T02:36:31.932924Z",
      "modified": "2026-05-15T02:36:31.932935Z",
      "name": "custom_vault_cred",
      "description": "",
      "kind": "cloud",
      "namespace": null,
      "managed": false,
      "inputs": {
        "fields": [
          {
            "id": "vault_role_id",
            "type": "string",
            "label": "Vault Role ID",
            "secret": false
          },
          {
            "id": "vault_secret_id",
            "type": "string",
            "label": "Vault Secret ID",
            "secret": true
          }
        ],
        "required": [
          "vault_role_id",
          "vault_secret_id"
        ]
      },
      "injectors": {
        "extra_vars": {
          "vault_role_id": "{{ vault_role_id }}",
          "vault_secret_id": "{{ vault_secret_id }}"
        }
      }
    },

Settings - Jobs

curl -sk -u "${AAP_USER}:${AAP_PASSWORD}" ${AAP_HOST}/api/controller/v2/settings/jobs/  | jq . > /home/ansible/config_backup/settings_jobs.json
取得ログ抜粋
$ cat settings_jobs.json
{
  "AD_HOC_COMMANDS": [
    "command",
    "shell",
    "yum",
    "apt",
    "apt_key",
    "apt_repository",
    "apt_rpm",
    "service",
    "group",
    "user",
    "mount",
    "ping",
    "selinux",
    "setup",
    "win_ping",
    "win_service",
    "win_updates",
    "win_group",
    "win_user"
  ],
  "ALLOW_JINJA_IN_EXTRA_VARS": "template",
  "AWX_ISOLATION_BASE_PATH": "/home/ansible/aap/controller/data/job_execution",
  "AWX_ISOLATION_SHOW_PATHS": [
    "/etc/pki/ca-trust:/etc/pki/ca-trust:O",
    "/home/ansible/certbot:/mnt/certbot:rw",
    "/home/ansible/log:/mnt/logs:rw",
    "/usr/share/pki:/usr/share/pki:O"
  ],
  "AWX_TASK_ENV": {},
  "AWX_RUNNER_KEEPALIVE_SECONDS": 0,
  "GALAXY_TASK_ENV": {
    "GIT_SSH_COMMAND": "ssh -o StrictHostKeyChecking=no",
    "ANSIBLE_FORCE_COLOR": "false"
  },
  "PROJECT_UPDATE_VVV": false,
  "AWX_ROLES_ENABLED": true,
  "AWX_COLLECTIONS_ENABLED": true,
  "AWX_SHOW_PLAYBOOK_LINKS": false,
  "AWX_MOUNT_ISOLATED_PATHS_ON_K8S": false,
  "GALAXY_IGNORE_CERTS": false,
  "STDOUT_MAX_BYTES_DISPLAY": 1048576,
  "EVENT_STDOUT_MAX_BYTES_DISPLAY": 1024,
  "MAX_WEBSOCKET_EVENT_RATE": 30,
  "SCHEDULE_MAX_JOBS": 10,
  "AWX_ANSIBLE_CALLBACK_PLUGINS": [],
  "DEFAULT_JOB_TIMEOUT": 0,
  "DEFAULT_JOB_IDLE_TIMEOUT": 0,
  "DEFAULT_INVENTORY_UPDATE_TIMEOUT": 0,
  "DEFAULT_PROJECT_UPDATE_TIMEOUT": 0,
  "ANSIBLE_FACT_CACHE_TIMEOUT": 0,
  "MAX_FORKS": 200,
  "DEFAULT_CONTAINER_RUN_OPTIONS": [
    "--network",
    "slirp4netns:enable_ipv6=true",
    "--security-opt",
    "label=level:s0:c100,c200"
  ]
}

Schedule

curl -sk -u "${AAP_USER}:${AAP_PASSWORD}" ${AAP_HOST}/api/controller/v2/schedules/  | jq . > /home/ansible/config_backup/schedules.json
取得ログ抜粋
$ cat schedules.json | jq | more
{
  "count": 6,
  "next": null,
  "previous": null,
  "results": [
    {
      "rrule": "DTSTART:20260406T022923Z RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=SU",
      "id": 1,
      "type": "schedule",
      "url": "/api/controller/v2/schedules/1/",
      "related": {
        "labels": "/api/controller/v2/schedules/1/labels/",
        "credentials": "/api/controller/v2/schedules/1/credentials/",
        "instance_groups": "/api/controller/v2/schedules/1/instance_groups/",
        "unified_jobs": "/api/controller/v2/schedules/1/jobs/",
        "unified_job_template": "/api/controller/v2/system_job_templates/1/"
      },
      "summary_fields": {
        "unified_job_template": {
          "id": 1,
          "name": "Cleanup Job Details",
          "description": "Remove job history",
          "unified_job_type": "system_job",
          "job_type": "cleanup_jobs"
        },
        "user_capabilities": {
          "edit": true,
          "delete": true
        }
      },
      "created": "2026-04-06T02:29:23.339519Z",
      "modified": "2026-04-06T02:29:23.339519Z",
      "name": "Cleanup Job Schedule",
      "description": "Automatically Generated Schedule",
      "extra_data": {
        "days": "120"
      },
      "inventory": null,
      "scm_branch": null,
      "job_type": null,
      "job_tags": null,
      "skip_tags": null,
      "limit": null,
      "diff_mode": null,
      "verbosity": null,
      "execution_environment": null,
      "forks": null,
      "job_slice_count": null,
      "timeout": null,
      "unified_job_template": 1,
      "enabled": true,
      "dtstart": "2026-04-12T02:29:23Z",
      "dtend": null,
      "next_run": "2026-08-23T02:29:23Z",
      "timezone": "UTC",
      "until": ""
    },

Job Template

curl -sk -u "${AAP_USER}:${AAP_PASSWORD}" ${AAP_HOST}/api/controller/v2/job_templates/ > /home/ansible/config_backup/job_templates.json
取得ログ抜粋
$ cat job_templates.json | jq | more
{
  "count": 54,
  "next": "/api/controller/v2/job_templates/?page=2",
  "previous": null,
  "results": [
    {
      "id": 324,
      "type": "job_template",
      "url": "/api/controller/v2/job_templates/324/",
      "related": {
        "created_by": "/api/controller/v2/users/1/",
        "modified_by": "/api/controller/v2/users/1/",
        "labels": "/api/controller/v2/job_templates/324/labels/",
        "inventory": "/api/controller/v2/inventories/167/",
        "project": "/api/controller/v2/projects/309/",
        "organization": "/api/controller/v2/organizations/1/",
        "credentials": "/api/controller/v2/job_templates/324/credentials/",
        "last_job": "/api/controller/v2/jobs/1850/",
        "execution_environment": "/api/controller/v2/execution_environments/100/",
        "jobs": "/api/controller/v2/job_templates/324/jobs/",
        "schedules": "/api/controller/v2/job_templates/324/schedules/",
        "activity_stream": "/api/controller/v2/job_templates/324/activity_stream/",
        "launch": "/api/controller/v2/job_templates/324/launch/",
        "webhook_key": "/api/controller/v2/job_templates/324/webhook_key/",
        "webhook_receiver": "",
        "notification_templates_started": "/api/controller/v2/job_templates/324/notification_templat
es_started/",
        "notification_templates_success": "/api/controller/v2/job_templates/324/notification_templat
es_success/",
        "notification_templates_error": "/api/controller/v2/job_templates/324/notification_templates
_error/",
        "access_list": "/api/controller/v2/job_templates/324/access_list/",
        "survey_spec": "/api/controller/v2/job_templates/324/survey_spec/",
        "object_roles": "/api/controller/v2/job_templates/324/object_roles/",
        "instance_groups": "/api/controller/v2/job_templates/324/instance_groups/",
        "slice_workflow_jobs": "/api/controller/v2/job_templates/324/slice_workflow_jobs/",
        "copy": "/api/controller/v2/job_templates/324/copy/"
      },
      "summary_fields": {
        "organization": {
          "id": 1,
          "name": "Default",
          "description": "The default organization for Ansible Automation Platform"
        },
        "inventory": {
          "id": 167,
          "name": "aap-host",
          "description": "",
          "has_active_failures": false,
          "total_hosts": 1,
          "hosts_with_active_failures": 0,
          "total_groups": 1,
          "has_inventory_sources": false,
          "total_inventory_sources": 0,
          "inventory_sources_with_failures": 0,
          "organization_id": 1,
          "kind": ""
        },
        "execution_environment": {
          "id": 100,
          "name": "certbot-bigip",
          "description": "",
          "image": "xx-x-x-x/test/localhost/certbot-test:0.1"
        },
        "project": {
          "id": 309,
          "name": "AWS-ACM",
          "description": "",
          "status": "ok",
          "scm_type": "",
          "allow_override": false
        },
        "last_job": {
          "id": 1850,
          "name": "ACM接続確認",
          "description": "",
          "finished": "2026-07-02T07:28:19.451726Z",
          "status": "successful",
          "failed": false
        },
        "last_update": {
          "id": 1850,
          "name": "ACM接続確認",
          "description": "",
          "status": "successful",
          "failed": false
        },
        "created_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "modified_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "object_roles": {
          "admin_role": {
            "description": "Can manage all aspects of the job template",
            "name": "Admin",
            "id": 489
          },
          "execute_role": {
            "description": "May run the job template",
            "name": "Execute",
            "id": 490
          },
          "read_role": {
            "description": "May view settings for the job template",
            "name": "Read",
            "id": 491
          }
        },
        "user_capabilities": {
          "edit": true,
          "delete": true,
          "start": true,
          "schedule": true,
          "copy": true
        },
        "labels": {
          "count": 0,
          "results": []
        },
        "recent_jobs": [
          {
            "id": 1850,
            "status": "successful",
            "finished": "2026-07-02T07:28:19.451726Z",
            "canceled_on": null,
            "type": "job"
          },
          {
            "id": 1849,
            "status": "successful",
            "finished": "2026-07-02T05:31:56.214481Z",
            "canceled_on": null,
            "type": "job"
          },
          {
            "id": 1845,
            "status": "successful",
            "finished": "2026-06-29T02:46:07.689137Z",
            "canceled_on": null,
            "type": "job"
          },
          {
            "id": 1842,
            "status": "successful",
            "finished": "2026-06-29T02:16:15.835712Z",
            "canceled_on": null,
            "type": "job"
          },
          {
            "id": 1841,
            "status": "successful",
            "finished": "2026-06-29T02:15:37.660347Z",
            "canceled_on": null,
            "type": "job"
          },
          {
            "id": 1840,
            "status": "successful",
            "finished": "2026-06-29T02:15:14.123002Z",
            "canceled_on": null,
            "type": "job"
          },
          {
            "id": 1839,
            "status": "successful",
            "finished": "2026-06-29T02:14:40.520132Z",
            "canceled_on": null,
            "type": "job"
          },
          {
            "id": 1838,
            "status": "successful",
            "finished": "2026-06-29T02:13:32.407092Z",
            "canceled_on": null,
            "type": "job"
          },
          {
            "id": 1837,
            "status": "successful",
            "finished": "2026-06-28T09:23:20.571214Z",
            "canceled_on": null,
            "type": "job"
          },
          {
            "id": 1836,
            "status": "successful",
            "finished": "2026-06-28T09:22:21.154567Z",
            "canceled_on": null,
            "type": "job"
          }
        ],
        "credentials": [
          {
            "id": 232,
            "name": "aap-host",
            "description": "",
            "kind": "ssh",
            "cloud": false
          }
        ]
      },

Workflow Job Template

curl -sk -u "${AAP_USER}:${AAP_PASSWORD}" ${AAP_HOST}/api/controller/v2/workflow_job_templates/ > /home/ansible/config_backup/workflow_templates.json
取得ログ抜粋
$ cat workflow_templates.json | jq | more
{
  "count": 8,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 232,
      "type": "workflow_job_template",
      "url": "/api/controller/v2/workflow_job_templates/232/",
      "related": {
        "created_by": "/api/controller/v2/users/1/",
        "modified_by": "/api/controller/v2/users/1/",
        "last_job": "/api/controller/v2/workflow_jobs/959/",
        "workflow_jobs": "/api/controller/v2/workflow_job_templates/232/workflow_jobs/",
        "schedules": "/api/controller/v2/workflow_job_templates/232/schedules/",
        "launch": "/api/controller/v2/workflow_job_templates/232/launch/",
        "webhook_key": "/api/controller/v2/workflow_job_templates/232/webhook_key/",
        "webhook_receiver": "",
        "workflow_nodes": "/api/controller/v2/workflow_job_templates/232/workflow_nodes/",
        "labels": "/api/controller/v2/workflow_job_templates/232/labels/",
        "activity_stream": "/api/controller/v2/workflow_job_templates/232/activity_stream/",
        "notification_templates_started": "/api/controller/v2/workflow_job_templates/232/notificatio
n_templates_started/",
        "notification_templates_success": "/api/controller/v2/workflow_job_templates/232/notificatio
n_templates_success/",
        "notification_templates_error": "/api/controller/v2/workflow_job_templates/232/notification_
templates_error/",
        "notification_templates_approvals": "/api/controller/v2/workflow_job_templates/232/notificat
ion_templates_approvals/",
        "access_list": "/api/controller/v2/workflow_job_templates/232/access_list/",
        "object_roles": "/api/controller/v2/workflow_job_templates/232/object_roles/",
        "survey_spec": "/api/controller/v2/workflow_job_templates/232/survey_spec/",
        "copy": "/api/controller/v2/workflow_job_templates/232/copy/"
      },
      "summary_fields": {
        "last_job": {
          "id": 959,
          "name": "00_証明書更新_vault_certbotワークフロー",
          "description": "",
          "finished": "2026-05-01T07:35:24.677470Z",
          "status": "successful",
          "failed": false
        },
        "last_update": {
          "id": 959,
          "name": "00_証明書更新_vault_certbotワークフロー",
          "description": "",
          "status": "successful",
          "failed": false
        },
        "created_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "modified_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "object_roles": {
          "admin_role": {
            "description": "Can manage all aspects of the workflow job template",
            "name": "Admin",
            "id": 331
          },
          "execute_role": {
            "description": "May run the workflow job template",
            "name": "Execute",
            "id": 332
          },
          "read_role": {
            "description": "May view settings for the workflow job template",
            "name": "Read",
            "id": 333
          },
          "approval_role": {
            "description": "Can approve or deny a workflow approval node",
            "name": "Approve",
            "id": 334
          }
        },
        "user_capabilities": {
          "edit": true,
          "delete": true,
          "start": true,
          "schedule": true,
          "copy": true
        },
        "labels": {
          "count": 1,
          "results": [
            {
              "id": 5,
              "name": "PoC-letsencrypt"
            }
          ]
        },
        "recent_jobs": [
          {
            "id": 959,
            "status": "successful",
            "finished": "2026-05-01T07:35:24.677470Z",
            "canceled_on": null,
            "type": "workflow_job"
          },
          {
            "id": 931,
            "status": "successful",
            "finished": "2026-04-30T12:13:39.651050Z",
            "canceled_on": null,
            "type": "workflow_job"
          },
          {
            "id": 912,
            "status": "failed",
            "finished": "2026-04-30T11:21:12.901429Z",
            "canceled_on": null,
            "type": "workflow_job"
          },
          {
            "id": 893,
            "status": "successful",
            "finished": "2026-04-30T09:50:24.511860Z",
            "canceled_on": null,
            "type": "workflow_job"
          },
          {
            "id": 852,
            "status": "successful",
            "finished": "2026-04-27T10:19:30.022996Z",
            "canceled_on": null,
            "type": "workflow_job"
          },
          {
            "id": 840,
            "status": "successful",
            "finished": "2026-04-27T10:01:27.483282Z",
            "canceled_on": null,
            "type": "workflow_job"
          },
          {
            "id": 827,
            "status": "failed",
            "finished": "2026-04-27T09:24:09.969144Z",
            "canceled_on": null,
            "type": "workflow_job"
          },
          {
            "id": 778,
            "status": "successful",
            "finished": "2026-04-24T01:19:22.507238Z",
            "canceled_on": null,
            "type": "workflow_job"
          },
          {
            "id": 763,
            "status": "failed",
            "finished": "2026-04-24T00:21:19.964081Z",
            "canceled_on": null,
            "type": "workflow_job"
          },
          {
            "id": 760,
            "status": "successful",
            "finished": "2026-04-24T00:09:09.196112Z",
            "canceled_on": null,
            "type": "workflow_job"
          }
        ]
      },
      "created": "2026-04-24T00:04:45.074686Z",
      "modified": "2026-05-16T22:02:25.099795Z",
      "name": "00_証明書更新_vault_certbotワークフロー",
      "description": "",
      "last_job_run": "2026-05-01T07:35:24.677470Z",
      "last_job_failed": false,
      "next_job_run": null,
      "status": "successful",
      "extra_vars": "",
      "organization": null,
      "survey_enabled": false,
      "allow_simultaneous": false,
      "ask_variables_on_launch": false,
      "inventory": null,
      "limit": null,
      "scm_branch": null,
      "ask_inventory_on_launch": false,
      "ask_scm_branch_on_launch": false,
      "ask_limit_on_launch": false,
      "webhook_service": "",
      "webhook_credential": null,
      "ask_labels_on_launch": false,
      "ask_skip_tags_on_launch": false,
      "ask_tags_on_launch": false,
      "skip_tags": null,
      "job_tags": null
    },


Execution Environment

curl -sk -u "${AAP_USER}:${AAP_PASSWORD}" ${AAP_HOST}/api/controller/v2/execution_environments/ > /home/ansible/config_backup/execution_environments.json
取得ログ抜粋
$ cat execution_environments.json | jq | more
{
  "count": 6,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 100,
      "type": "execution_environment",
      "url": "/api/controller/v2/execution_environments/100/",
      "related": {
        "created_by": "/api/controller/v2/users/1/",
        "modified_by": "/api/controller/v2/users/1/",
        "activity_stream": "/api/controller/v2/execution_environments/100/activity_stream/",
        "unified_job_templates": "/api/controller/v2/execution_environments/100/unified_job_template
s/",
        "copy": "/api/controller/v2/execution_environments/100/copy/",
        "credential": "/api/controller/v2/credentials/67/"
      },
      "summary_fields": {
        "credential": {
          "id": 67,
          "name": "automation-hub",
          "description": "cert-exec-test",
          "kind": "registry",
          "cloud": false,
          "kubernetes": false,
          "credential_type_id": 18
        },
        "created_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "modified_by": {
          "id": 1,
          "username": "adminXX",
          "first_name": "",
          "last_name": ""
        },
        "user_capabilities": {
          "edit": true,
          "delete": true,
          "copy": true
        }
      },
      "created": "2026-05-15T04:08:24.905746Z",
      "modified": "2026-05-15T04:08:24.905757Z",
      "name": "certbot-bigip",
      "description": "",
      "organization": null,
      "image": "xx-xx-xx-xx/test/localhost/certbot-test:0.1",
      "managed": false,
      "credential": 67,
      "pull": "missing"
    },
    {
      "id": 5,
      "type": "execution_environment",
      "url": "/api/controller/v2/execution_environments/5/",
      "related": {
        "activity_stream": "/api/controller/v2/execution_environments/5/activity_stream/",
        "unified_job_templates": "/api/controller/v2/execution_environments/5/unified_job_templates/
",
        "copy": "/api/controller/v2/execution_environments/5/copy/"
      },
      "summary_fields": {
        "user_capabilities": {
          "edit": true,
          "delete": false,
          "copy": true
        }
      },
      "created": "2026-04-06T02:32:52.950548Z",
      "modified": "2026-04-06T02:32:52.978573Z",
      "name": "Control Plane Execution Environment",
      "description": "",
      "organization": null,
      "image": "registry.redhat.io/ansible-automation-platform-26/ee-supported-rhel9:latest",
      "managed": true,
      "credential": null,
      "pull": ""
    },
    {
      "id": 4,
      "type": "execution_environment",
      "url": "/api/controller/v2/execution_environments/4/",
      "related": {
        "activity_stream": "/api/controller/v2/execution_environments/4/activity_stream/",
        "unified_job_templates": "/api/controller/v2/execution_environments/4/unified_job_templates/
",
        "copy": "/api/controller/v2/execution_environments/4/copy/"
      },
      "summary_fields": {
        "user_capabilities": {
          "edit": true,
          "delete": true,
          "copy": true
        }
      },
      "created": "2026-04-06T02:32:52.901174Z",
      "modified": "2026-04-06T02:32:52.929381Z",
      "name": "Default execution environment",
      "description": "",
      "organization": null,
      "image": "registry.redhat.io/ansible-automation-platform-26/ee-supported-rhel9:latest",
      "managed": false,
      "credential": null,
      "pull": ""
    },
    {
      "id": 3,
      "type": "execution_environment",
      "url": "/api/controller/v2/execution_environments/3/",
      "related": {
        "activity_stream": "/api/controller/v2/execution_environments/3/activity_stream/",
        "unified_job_templates": "/api/controller/v2/execution_environments/3/unified_job_templates/
",
        "copy": "/api/controller/v2/execution_environments/3/copy/"
      },
      "summary_fields": {
        "user_capabilities": {
          "edit": true,
          "delete": true,
          "copy": true
        }
      },
      "created": "2026-04-06T02:32:52.847725Z",
      "modified": "2026-04-06T02:32:52.881198Z",
      "name": "Minimal execution environment",
      "description": "",
      "organization": null,
      "image": "registry.redhat.io/ansible-automation-platform-26/ee-minimal-rhel9:latest",
      "managed": false,
      "credential": null,
      "pull": ""
    },


(参考)別環境への再投入

バックアップした JSON を元に別環境へ設定を再投入する場合の手順です。

投入前に除去すべきフィールド

取得した JSON からシステム生成フィールドを除去する必要があります。

cat projects.json | jq '.results[] | del(.id, .type, .url, .related,
  .summary_fields, .created, .modified, .status, .scm_revision,
  .last_job_run, .last_job_failed, .next_job_run, .last_update_failed,
  .last_updated, .local_path)' > project_import.json

投入コマンド例

curl -sk -X POST -u "${AAP_USER}:${AAP_PASSWORD}" \
  -H "Content-Type: application/json" \
  -d @project_import.json \
  ${AAP_HOST}/api/controller/v2/projects/

投入順序(依存関係に注意)

  1. Organization
  2. Credential Type → Credential
  3. Project
  4. Inventory → Host / Group
  5. Execution Environment
  6. Job Template
  7. Workflow Job Template → Workflow Node

※ まだ環境が整わず試しておりませんが、別の機会で確認したいと思います。

一括バックアップスクリプト

上記の手順をまとめたスクリプトです。

#!/bin/bash
set -euo pipefail

AAP_HOST="https://xx.xx.xx.xx"
AAP_USER="admin"
read -s -p "AAP Password: " AAP_PASSWORD; echo

BACKUP_DIR="/home/ansible/config_backup/$(date +%Y%m%d_%H%M%S)"
mkdir -p "$BACKUP_DIR"

ENDPOINTS=(
  "organizations"
  "users"
  "projects"
  "inventories"
  "hosts"
  "credentials"
  "credential_types"
  "job_templates"
  "workflow_job_templates"
  "execution_environments"
  "schedules"
  "settings/jobs"
)

for ep in "${ENDPOINTS[@]}"; do
  FILENAME=$(echo "$ep" | tr '/' '_')
  echo "取得中: ${ep} -> ${FILENAME}.json"
  curl -sk -u "${AAP_USER}:${AAP_PASSWORD}" \
    "${AAP_HOST}/api/controller/v2/${ep}/?page_size=200" \
    | jq . > "${BACKUP_DIR}/${FILENAME}.json"
done

echo "バックアップ完了: ${BACKUP_DIR}"

まとめ

  • curl コマンドで Ansible Automation Platform の構成情報の取得コマンドを確認しました。
  • 取得した情報は、別環境への同様の構成を展開する際に利用できるように検討したいと思います。
    (curl コマンドでの post または configuration as code など)

Configuration As Code については、下記の記事をご参考ください。

1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?