Share Feedback to help us keep improving.
1.3. 将 Automation Dashboard 与 Ansible Automation Platform 集成
将 Ansible Automation Platform 实例集成到 Automation Dashboard 配置中,以收集和可视化数据,并深入了解您的自动化。
流程
验证 Automation Dashboard 是否在 Red Hat Enterprise Linux 主机上的 https 端口 8447 上运行。
注意- 此验证需要您的 Ansible Automation Platform 登录详情。
- 端口 8447 默认启用,但这可配置。
使用以下信息将 Ansible Automation Platform 实例添加到
cluster.yaml中:- 您的 Ansible Automation Platform URL/端口用于前端访问
- 预配置的 Ansible Automation Platform OAuth 访问令牌并刷新以 进行读 访问
OAuth2 客户端凭证
注意如果您无法访问 Ansible Automation Platform,请咨询您的管理员。
- 配置个人访问令牌。如需更多信息,请参阅使用 基于令牌的身份验证配置对外部应用程序的访问。
配置访问令牌后,运行以下命令:
cp clusters.example.yaml clusters.yaml vi clusters.yaml您可以使用以下方法,将一个或多个 Ansible Automation Platform 实例(同一 Ansible Automation Platform 版本)添加到 Automation Dashboard 配置中,以便拉取和组合数据:
注意如果您只有一个 Ansible Automation Platform 实例,则删除第二个条目。
--- clusters: - protocol: https <--- Normally https address: my-aap.example.com <--- Can use IP or FQDN without http(s):// port: 443 <--- Normally 443 access_token: sampleToken <--- Your preconfigured Ansible Automation Platform read access token Platform read access token refresh_token: myRefreshToken client_id: myClientID client_secret: myClientSecret verify_ssl: false <--- Can be used when using self signed certs sync_schedules: - name: Every 5 minutes sync rrule: DTSTART;TZID=Europe/Ljubljana:20250630T070000 FREQ=MINUTELY;INTERVAL=5 enabled: true - protocol: https address: aap2.example.com port: 443 access_token: WRn2swiqg5spEwUndDkrJoCeg4Qwuw verify_ssl: true sync_schedules: - name: Every 5 minutes sync rrule: DTSTART;TZID=Europe/Ljubljana:20250630T070000 FREQ=MINUTELY;INTERVAL=5 enabled: true注意access_token,refresh_token, 和client_secret存储在 Automation Dashboard 数据库中。这些值是安全的加密。运行以下命令来加载和激活 Automation Dashboard 配置:
podman cp clusters.yaml automation-dashboard-web:/ podman exec automation-dashboard-web /venv/bin/python ./manage.py setclusters /clusters.yaml注意Automation Dashboard 使用
、refresh_tokenclient_id和client_secret在当前令牌过期时自动获取一个新的access_token和 refresh_token。实用程序使用 ping 端点来检测 Ansible Automation Platform 版本,并找到正确的令牌刷新端点。示例
podman exec automation-dashboard-web /venv/bin/python ./manage.py setclusters /clusters.yaml Check if table exists. Reading YML file. Adding cluster: address=my-aap.example.com INFO 2025-05-20 09:55:00,926 connector 187 140208297051968 Checking if is AAP 2.4 at https://my-aap.example.com:443 INFO 2025-05-20 09:55:00,926 connector 187 140208297051968 Pinging api https://my-aap.example.com:443/api/v2/ping/ INFO 2025-05-20 09:55:00,926 connector 187 140208297051968 Executing GET request to https://my-aap.example.com:443/api/v2/ping/ ERROR 2025-05-20 09:55:00,032 connector 301 140025281152832 GET request failed with status 404 Successfully set up AAP clusters注意Automation Dashboard 检查 Ansible Automation Platform 2.4、2.5 和 2.6 实例。如示例输出所示,这可能导致 404 错误。有关错误的更多信息,请参阅本章的验证部分。
使用以下命令手动获取数据来测试自动化仪表板配置:
podman exec -it automation-dashboard-web /venv/bin/python ./manage.py syncdata --since=2025-04-01 --until=2025-06-01 Successfully created Sync task for Cluster https://my-aap.example.com:443.注意考虑使用简短日期间隔来减少测试时间。格式为 YYYY-MM-DD。
然后,您可以使用
journalctl检查进度:sudo journalctl -fn10- 刷新浏览器以在 Automation Dashboard 中查看检索的数据。
1.3.1. 验证集群访问令牌 复制链接链接已复制到粘贴板!
配置并载入集群数据后,验证存储的访问令牌用于调试目的。
流程
-
使用
getclusters管理命令和--decrypt选项,以纯文本形式显示存储的access_token和refresh_token。 在
automation-dashboard-web容器中运行以下命令:podman exec -it automation-dashboard-web /venv/bin/python ./manage.py getclusters --decrypt- 检查输出,以确认存储的令牌正确且最新。
Example
clusters:
- protocol: https
address: my-aap.example.com
port: 443
access_token: sampleToken
refresh_token: myRefreshToken
client_id: myClientID
client_secret: myClientSecret
verify_ssl: false
sync_schedules:
- name: Every 5 minutes sync
rrule: DTSTART;TZID=Europe/Ljubljana:20250630T070000 FREQ=MINUTELY;INTERVAL=5
enabled: true
为调试显示加密的 access_token 和 refresh_token 需要-- decrypt 标志。不要在不安全的系统上使用此命令。
您可以将 ./manage.py getclusters --decrypt 生成的输出写入文件 cluster.yaml,并将它用作 ./manage.py setclusters 的输入。
clusters.yaml
验证
如果在安装过程中出现错误消息,请查看下表:
| 问题 | 可能的根源 | 解决方案 |
| 401 错误 | 这是一个未授权的访问消息,代表身份验证错误,如错误的凭证或令牌。 |
在 cluster |
| 401 错误 | 当令牌过期时,会出现临时 401 错误,然后尝试刷新。 |
如果自动令牌刷新失败(例如,由于无效的 |
| 404 错误 | 这是一个"未找到"消息,表示某些内容没有正确配置或指向正确的端点。 |
验证 cluster |
安装成功应运行以下三个容器服务:
podman ps --all --format "{{.Names}}"
postgresql
automation-dashboard-task
automation-dashboard-web
您可以运行以下命令来检查容器日志:
journalctl CONTAINER_NAME=container (where container equals one of postgresql automation-dashboard-task or automation-dashboard-web)
For example:
journalctl CONTAINER_NAME=automation-dashboard-task
May 22 13:02:07 automation-dashboard automation-dashboard-task[1607]: [wait-for-migrations-dashboard.sh] Waiting for database migrations...
May 22 13:02:07 automation-dashboard automation-dashboard-task[1607]: [wait-for-migrations-dashboard.sh] Attempt 1
May 22 13:02:10 automation-dashboard automation-dashboard-task[1607]: INFO 2025-05-22 13:02:10,636 periodic 2 140568371550016 Starting sync task.
May 22 13:02:10 automation-dashboard automation-dashboard-task[1607]: INFO 2025-05-22 13:02:10,636 periodic 2 140568371550016 Retrieving clusters inform>
May 22 13:02:10 automation-dashboard automation-dashboard-task[1607]: INFO 2025-05-22 13:02:10,747 periodic 2 140568371550016 Retrieved 1 clusters.
May 22 13:02:10 automation-dashboard automation-dashboard-task[1607]: INFO 2025-05-22 13:02:10,761 periodic 2 140568371550016 Retrieving data from clust>
May 22 13:02:10 automation-dashboard automation-dashboard-task[1607]: INFO 2025-05-22 13:02:10,761 connector 2 140568371550016 Checking Ansible Automation Platform version at h>
May 22 13:02:10 automation-dashboard automation-dashboard-task[1607]: INFO 2025-05-22 13:02:10,761 connector 2 140568371550016 Checking if is Ansible Automation Platform 2.5 at>
May 22 13:02:10 automation-dashboard automation-dashboard-task[1607]: INFO 2025-05-22 13:02:10,761 connector 2 140568371550016 Pinging api https://ec2-3>
May 22 13:02:10 automation-dashboard automation-dashboard-task[1607]: INFO 2025-05-22 13:02:10,761 connector 2 140568371550016 Executing GET request to >
May 22 13:02:13 automation-dashboard automation-dashboard-task[1607]: ERROR 2025-05-22 13:02:13,820 connector 2 140568371550016 GET request failed with >
May 22 13:02:13 automation-dashboard automation-dashboard-task[1607]: INFO 2025-05-22 13:02:13,821 connector 2 140568371550016 Checking if is Ansible Automation Platform 2.4 at>
May 22 13:02:13 automation-dashboard automation-dashboard-task[1607]: INFO 2025-05-22 13:02:13,821 connector 2 140568371550016 Pinging api https://ec2-3>
May 22 13:02:13 automation-dashboard automation-dashboard-task[1607]: INFO 2025-05-22 13:02:13,821 connector 2 140568371550016 Executing GET request to >
May 22 13:02:16 automation-dashboard automation-dashboard-task[1607]: ERROR 2025-05-22 13:02:16,892 connector 2 140568371550016 GET request failed with ...
以下日志片段显示令牌成功刷新:
此日志片断省略了 brevity 的时间戳和主机名。
示例
journalctl CONTAINER_NAME=automation-dashboard-task
INFO Checking if is AAP 2.5 ... 2.6 at https://app.example.com:443
INFO Pinging api https://app.example.com:443/api/gateway/v1/ping/
INFO Detected AAP version AAP 2.6 at https://app.example.com:443
INFO Executing GET request to https://app.example.com:443/api/controller/v2/organizations/?page_size=100&page=1
ERROR GET request failed with status 401
INFO Token refresh POST request succedded with status 201
ERROR GET after reauth response.status_code=200
INFO Executing GET request to https://app.example.com:443/api/controller/v2/job_templates/?page_size=200&page=1
Executing GET request to https://app.example.com:443/api/controller/v2/jobs/?page_size=100&page=1&order_by=finished&finished__gt=2025-10-23T13:01:09.768681Z
使用 systemd 检查服务如何运行:
systemctl status --user
● automation-dashboard
State: running
Units: 76 loaded (incl. loaded aliases)
Jobs: 0 queued
Failed: 0 units
Since: Thu 2025-05-22 13:02:07 UTC; 22min ago
systemd: 252-51.el9
CGroup: /user.slice/user-1000.slice/user@1000.service
├─app.slice
│ ├─automation-dashboard-task.service
│ │ └─1607 /usr/bin/conmon --api-version 1 -c 84e46532e8ca31b0cadb037479289d030103aa01b7a1591e62b83b17f031e47d -u 84e46532e8ca31b0cadb037479>
│ ├─automation-dashboard-web.service
│ │ └─1608 /usr/bin/conmon --api-version 1 -c d060f3e3fb2b4c4c5c588149253beed83c78ccc9c9a8c1bf4c96157142a210dc -u d060f3e3fb2b4c4c5c58814925>
│ ├─dbus-broker.service
│ │ ├─1621 /usr/bin/dbus-broker-launch --scope user
│ │ └─1624 dbus-broker --log 4 --controller 9 --machine-id 612db98503014199bfd8c788c8d3da58 --max-bytes 100000000000000 --max-fds 2500000000>
│ └─postgresql.service
│ └─1614 /usr/bin/conmon --api-version 1 -c eec61745cb6fc3a89a4f7475d7ef63b5899699157d943c2f16a3243311927bef -u eec61745cb6fc3a89a4f7475d7>
├─init.scope
│ ├─1093 /usr/lib/systemd/systemd --user
│ └─1128 "(sd-pam)"
└─user.slice
├─libpod-84e46532e8ca31b0cadb037479289d030103aa01b7a1591e62b83b17f031e47d.scope
│ └─container
│ ├─1619 /usr/bin/dumb-init -- /usr/bin/launch_dashboard_task.sh
│ └─1681 /venv/bin/python periodic.py
├─libpod-d060f3e3fb2b4c4c5c588149253beed83c78ccc9c9a8c1bf4c96157142a210dc.scope
│ └─container
│ ├─1617 /usr/bin/dumb-init -- /usr/bin/launch_dashboard_web.sh
│ ├─1646 /usr/bin/python3.9 /usr/local/bin/supervisord -c /etc/supervisord_dashboard_web.conf
│ ├─1877 /bin/bash /usr/local/bin/stop-supervisor
│ ├─1878 "nginx: master process nginx -g daemon off;"
│ ├─1879 /venv/bin/uwsgi /etc/tower/uwsgi.ini
│ ├─1880 "nginx: worker process"
│ ├─1881 "nginx: worker process"
│ ├─1882 "nginx: worker process"
│ ├─1883 "nginx: worker process"
│ ├─1884 /venv/bin/uwsgi /etc/tower/uwsgi.ini
│ ├─1885 /venv/bin/uwsgi /etc/tower/uwsgi.ini
│ ├─1886 /venv/bin/uwsgi /etc/tower/uwsgi.ini
│ ├─1887 /venv/bin/uwsgi /etc/tower/uwsgi.ini
│ └─1888 /venv/bin/uwsgi /etc/tower/uwsgi.ini
├─libpod-eec61745cb6fc3a89a4f7475d7ef63b5899699157d943c2f16a3243311927bef.scope
│ └─container
│ ├─1623 postgres
│ ├─1869 "postgres: logger "
│ ├─1871 "postgres: checkpointer "
│ ├─1872 "postgres: background writer "
│ ├─1873 "postgres: walwriter "
│ ├─1874 "postgres: autovacuum launcher "
│ ├─1875 "postgres: stats collector "
│ ├─1876 "postgres: logical replication launcher "
│ └─1889 "postgres: aapdashboard aapdashboard 172.31.28.99(39338) idle"
└─podman-pause-b6c4e853.scope
└─1359 catatonit -P