3.3. 基于安装场景的清单文件示例
红帽支持多种 Ansible Automation Platform 安装场景。您可以使用示例文件作为基础来开发自己的清单文件,或者您可以使用最接近您的首选安装场景的示例。
3.3.1. 根据安装场景的清单文件建议 复制链接链接已复制到粘贴板!
在为 Ansible Automation Platform 选择安装方法前,请查看以下建议。熟悉这些建议可简化安装过程。
为主机提供可访问的 IP 地址或完全限定域名(FQDN),以确保用户可以从不同节点的自动化中心同步和安装内容。
FQDN 不得包含
-或_符号,因为它不能正确处理。不要使用
localhost。-
admin是初始登录 Ansible Automation Platform 的默认用户 ID,无法在清单文件中更改。 -
在
pg_password中使用特殊字符是有限的。支持!,#,0和@字符。使用其他特殊字符可能会导致设置失败。 -
在
registry_username和registry_password中输入 Red Hat Registry Service account 凭证以链接到 Red Hat 容器 registry。 -
只有在使用非捆绑包安装程序时,才需要清单文件变量
registry_username和registry_password。
3.3.1.1. 带有外部(安装程序管理的)数据库的单一平台网关和自动化控制器 复制链接链接已复制到粘贴板!
使用本示例查看清单文件中的最少需要什么,使用外部(安装程序管理)数据库部署单一平台网关和自动化控制器实例。
[automationcontroller]
controller.example.com
[automationgateway]
gateway.example.com
[database]
data.example.com
[all:vars]
admin_password='<password>'
redis_mode=standalone
pg_host='data.example.com'
pg_port=5432
pg_database='awx'
pg_username='awx'
pg_password='<password>'
pg_sslmode='prefer' # set to 'verify-full' for client-side enforced SSL
registry_url='registry.redhat.io'
registry_username='<registry username>'
registry_password='<registry password>'
# Automation Gateway configuration
automationgateway_admin_password=''
automationgateway_pg_host='data.example.com'
automationgateway_pg_port=5432
automationgateway_pg_database='automationgateway'
automationgateway_pg_username='automationgateway'
automationgateway_pg_password=''
automationgateway_pg_sslmode='prefer'
# The main automation gateway URL that clients will connect to (e.g. https://<load balancer host>).
# If not specified, the first node in the [automationgateway] group will be used when needed.
# automationgateway_main_url = ''
# Certificate and key to install in Automation Gateway
# automationgateway_ssl_cert=/path/to/automationgateway.cert
# automationgateway_ssl_key=/path/to/automationgateway.key
# SSL-related variables
# If set, this will install a custom CA certificate to the system trust store.
# custom_ca_cert=/path/to/ca.crt
# Certificate and key to install in nginx for the web UI and API
# web_server_ssl_cert=/path/to/tower.cert
# web_server_ssl_key=/path/to/tower.key
# Server-side SSL settings for PostgreSQL (when we are installing it).
# postgres_use_ssl=False
# postgres_ssl_cert=/path/to/pgsql.crt
# postgres_ssl_key=/path/to/pgsql.key
3.3.1.2. 带有外部(安装程序管理的)数据库的单一平台网关、自动化控制器和自动化中心 复制链接链接已复制到粘贴板!
使用本示例填充清单文件,以使用外部(安装程序管理)数据库部署单一平台网关、自动化控制器和自动化中心实例。
[automationcontroller]
controller.example.com
[automationhub]
automationhub.example.com
[automationgateway]
gateway.example.com
[database]
data.example.com
[all:vars]
admin_password='<password>'
redis_mode=standalone
pg_host='data.example.com'
pg_port='5432'
pg_database='awx'
pg_username='awx'
pg_password='<password>'
pg_sslmode='prefer' # set to 'verify-full' for client-side enforced SSL
registry_url='registry.redhat.io'
registry_username='<registry username>'
registry_password='<registry password>'
automationhub_admin_password= <PASSWORD>
automationhub_pg_host='data.example.com'
automationhub_pg_port=5432
automationhub_pg_database='automationhub'
automationhub_pg_username='automationhub'
automationhub_pg_password=<PASSWORD>
automationhub_pg_sslmode='prefer'
# The default install will deploy a TLS enabled Automation Hub.
# If for some reason this is not the behavior wanted one can
# disable TLS enabled deployment.
#
# automationhub_disable_https = False
# The default install will generate self-signed certificates for the Automation
# Hub service. If you are providing valid certificate via automationhub_ssl_cert
# and automationhub_ssl_key, one should toggle that value to True.
#
# automationhub_ssl_validate_certs = False
# SSL-related variables
# If set, this will install a custom CA certificate to the system trust store.
# custom_ca_cert=/path/to/ca.crt
# Certificate and key to install in Automation Hub node
# automationhub_ssl_cert=/path/to/automationhub.cert
# automationhub_ssl_key=/path/to/automationhub.key
# Automation Gateway configuration
automationgateway_admin_password=''
automationgateway_pg_host=''
automationgateway_pg_port=5432
automationgateway_pg_database='automationgateway'
automationgateway_pg_username='automationgateway'
automationgateway_pg_password=''
automationgateway_pg_sslmode='prefer'
# The main automation gateway URL that clients will connect to (e.g. https://<load balancer host>).
# If not specified, the first node in the [automationgateway] group will be used when needed.
# automationgateway_main_url = ''
# Certificate and key to install in Automation Gateway
# automationgateway_ssl_cert=/path/to/automationgateway.cert
# automationgateway_ssl_key=/path/to/automationgateway.key
# Certificate and key to install in nginx for the web UI and API
# web_server_ssl_cert=/path/to/tower.cert
# web_server_ssl_key=/path/to/tower.key
# Server-side SSL settings for PostgreSQL (when we are installing it).
# postgres_use_ssl=False
# postgres_ssl_cert=/path/to/pgsql.crt
# postgres_ssl_key=/path/to/pgsql.key
使用本示例填充清单文件,以使用外部(安装程序管理)数据库部署单一平台网关、自动化控制器、自动化中心和 Event-Driven Ansible 控制器。
- 此场景至少需要自动化控制器 2.4 才能成功部署 Event-Driven Ansible 控制器。
- event-Driven Ansible 控制器必须安装在单独的服务器上,且不能安装到与自动化中心和自动化控制器相同的主机上。
-
当在标准条件下激活 Event-Driven Ansible rulebook 时,它使用大约 250 MB 内存。但是,实际内存消耗可能会因规则的复杂性以及处理的事件的大小和大小有很大不同。在预计大量事件或规则手册复杂性很高的情况下,对暂存环境中的资源使用量进行初始评估。这样可确保最大激活数量基于资源容量。在以下示例中,默认的
automationedacontroller_max_running_activations设置为 12,但可以根据容量进行调整。
[automationcontroller]
controller.example.com
[automationhub]
automationhub.example.com
[automationedacontroller]
automationedacontroller.example.com
[automationgateway]
gateway.example.com
[database]
data.example.com
[all:vars]
admin_password='<password>'
redis_mode=standalone
pg_host='data.example.com'
pg_port='5432'
pg_database='awx'
pg_username='awx'
pg_password='<password>'
pg_sslmode='prefer' # set to 'verify-full' for client-side enforced SSL
registry_url='registry.redhat.io'
registry_username='<registry username>'
registry_password='<registry password>'
# Automation hub configuration
automationhub_admin_password= <PASSWORD>
automationhub_pg_host='data.example.com'
automationhub_pg_port=5432
automationhub_pg_database='automationhub'
automationhub_pg_username='automationhub'
automationhub_pg_password=<PASSWORD>
automationhub_pg_sslmode='prefer'
# Automation Event-Driven Ansible controller configuration
automationedacontroller_admin_password='<eda-password>'
automationedacontroller_pg_host='data.example.com'
automationedacontroller_pg_port=5432
automationedacontroller_pg_database='automationedacontroller'
automationedacontroller_pg_username='automationedacontroller'
automationedacontroller_pg_password='<password>'
# Keystore file to install in SSO node
# sso_custom_keystore_file='/path/to/sso.jks'
# This install will deploy SSO with sso_use_https=True
# Keystore password is required for https enabled SSO
sso_keystore_password=''
# This install will deploy a TLS enabled Automation Hub.
# If for some reason this is not the behavior wanted one can
# disable TLS enabled deployment.
#
# automationhub_disable_https = False
# The default install will generate self-signed certificates for the Automation
# Hub service. If you are providing valid certificate via automationhub_ssl_cert
# and automationhub_ssl_key, one should toggle that value to True.
#
# automationhub_ssl_validate_certs = False
# SSL-related variables
# If set, this will install a custom CA certificate to the system trust store.
# custom_ca_cert=/path/to/ca.crt
# Certificate and key to install in Automation Hub node
# automationhub_ssl_cert=/path/to/automationhub.cert
# automationhub_ssl_key=/path/to/automationhub.key
# Automation Gateway configuration
automationgateway_admin_password=''
automationgateway_pg_host=''
automationgateway_pg_port=5432
automationgateway_pg_database='automationgateway'
automationgateway_pg_username='automationgateway'
automationgateway_pg_password=''
automationgateway_pg_sslmode='prefer'
# The main automation gateway URL that clients will connect to (e.g. https://<load balancer host>).
# If not specified, the first node in the [automationgateway] group will be used when needed.
# automationgateway_main_url = ''
# Certificate and key to install in Automation Gateway
# automationgateway_ssl_cert=/path/to/automationgateway.cert
# automationgateway_ssl_key=/path/to/automationgateway.key
# Certificate and key to install in nginx for the web UI and API
# web_server_ssl_cert=/path/to/tower.cert
# web_server_ssl_key=/path/to/tower.key
# Server-side SSL settings for PostgreSQL (when we are installing it).
# postgres_use_ssl=False
# postgres_ssl_cert=/path/to/pgsql.crt
# postgres_ssl_key=/path/to/pgsql.key
# Boolean flag used to verify Automation Controller's
# web certificates when making calls from Automation Event-Driven Ansible controller.
# automationedacontroller_controller_verify_ssl = true
#
# Certificate and key to install in Automation Event-Driven Ansible controller node
# automationedacontroller_ssl_cert=/path/to/automationeda.crt
# automationedacontroller_ssl_key=/path/to/automationeda.key
其他资源
有关这些清单变量的更多信息,请参阅 Red Hat Ansible Automation Platform 安装指南中的 Ansible Automation hub 变量。
3.3.1.4. 高可用性自动化中心 复制链接链接已复制到粘贴板!
使用以下示例填充清单文件来安装高度可用的自动化中心。此清单文件包含一个具有集群设置的高可用性自动化中心。
您可以进一步配置 HA 部署,以便在 SELinux 中启用自动化中心的高可用性部署。
指定数据库主机 IP
-
使用
automation_pg_host和automation_pg_port清单变量指定数据库主机的 IP 地址。例如:
automationhub_pg_host='192.0.2.10'
automationhub_pg_port=5432
-
另外,使用
automationhub_pg_host清单变量中的值,在 [database] 部分中指定数据库主机的 IP 地址:
[database]
192.0.2.10
列出集群设置中的所有实例
-
如果安装集群设置,请将 [automationhub] 部分中的
localhost ansible_connection=local替换为所有实例的主机名或 IP。例如:
[automationhub]
automationhub1.testing.ansible.com ansible_user=cloud-user
automationhub2.testing.ansible.com ansible_user=cloud-user
automationhub3.testing.ansible.com ansible_user=cloud-user
USE_X_FORWARDED_PORT = True
USE_X_FORWARDED_HOST = True
如果使用负载均衡器,请将 automationgateway_main_url 配置为指向您的负载均衡器。如果没有指定 automationgateway_main_url,则 [automationgateway] 组中的第一个节点将默认用作。
3.3.1.5. 在 SELinux 中启用自动化中心的高可用性(HA)部署 复制链接链接已复制到粘贴板!
您可以配置清单文件,以便在 SELinux 中启用自动化中心的高可用性部署。您必须为 /var/lib/pulp 和 /var/lib/pulp/pulpcore_static 创建两个挂载点,然后为每个分配适当的 SELinux 上下文。
您需要为 /var/lib/pulp 添加上下文,并在为 /var/lib/pulp 添加上下文前运行 Ansible Automation Platform 安装程序。
先决条件
您已在服务器上配置了 NFS 导出。
注意NFS 共享托管在外部服务器上,不是高可用性自动化中心部署的一部分。
流程
在
/var/lib/pulp中创建挂载点:$ mkdir /var/lib/pulp/使用文本编辑器打开
/etc/fstab,然后添加以下值:srv_rhel8:/data /var/lib/pulp nfs defaults,_netdev,nosharecache,context="system_u:object_r:var_lib_t:s0" 0 0 srv_rhel8:/data/pulpcore_static /var/lib/pulp/pulpcore_static nfs defaults,_netdev,nosharecache,context="system_u:object_r:httpd_sys_content_rw_t:s0" 0 0运行 reload systemd manager configuration 命令:
$ systemctl daemon-reload为
/var/lib/pulp运行 mount 命令:$ mount /var/lib/pulp在
/var/lib/pulp/pulpcore_static处创建一个挂载点:$ mkdir /var/lib/pulp/pulpcore_static运行 mount 命令:
$ mount -a设置挂载点后,运行 Ansible Automation Platform 安装程序:
$ setup.sh -- -b --become-user root-
安装完成后,卸载
/var/lib/pulp/挂载点。
3.3.1.5.1. 配置 pulpcore.service 复制链接链接已复制到粘贴板!
配置清单文件并应用 SELinux 上下文后,现在您需要配置 pulp 服务。
流程
设置了两个挂载点,关闭 Pulp 服务以配置
pulpcore.service:$ systemctl stop pulpcore.service使用
systemctl编辑pulpcore.service:$ systemctl edit pulpcore.service将以下条目添加到
pulpcore.service中,以确保自动化中心服务仅在启动网络并挂载远程挂载点后启动:[Unit] After=network.target var-lib-pulp.mount启用
remote-fs.target:$ systemctl enable remote-fs.target重启系统:
$ systemctl reboot
故障排除
pulpcore SELinux 策略中存在一个错误,可能会导致 etc/pulp/certs/ 中的令牌身份验证的公钥/私钥没有正确的 SELinux 标签,从而导致 pulp 进程失败。当发生这种情况时,运行以下命令临时附加正确的标签:
$ chcon system_u:object_r:pulpcore_etc_t:s0 /etc/pulp/certs/token_{private,public}_key.pem
重复此命令,以便在重新标记系统时重新附加正确的 SELinux 标签。
3.3.1.5.2. 应用 SELinux 上下文 复制链接链接已复制到粘贴板!
配置清单文件后,您必须应用上下文,以便在 SELinux 中启用自动化中心的高可用性(HA)部署。
流程
关闭 Pulp 服务:
$ systemctl stop pulpcore.service卸载
/var/lib/pulp/pulpcore_static:$ umount /var/lib/pulp/pulpcore_static卸载
/var/lib/pulp/:$ umount /var/lib/pulp/使用文本编辑器打开
/etc/fstab,然后使用以下内容替换/var/lib/pulp的现有值:srv_rhel8:/data /var/lib/pulp nfs defaults,_netdev,nosharecache,context="system_u:object_r:pulpcore_var_lib_t:s0" 0 0运行 mount 命令:
$ mount -a
3.3.1.6. 在私有自动化 hub 中配置内容签名 复制链接链接已复制到粘贴板!
要成功签名并发布 Ansible 认证的内容集合,您必须配置私有自动化中心进行签名。
前提条件
- 您的 TIPC 密钥对已安全设置并管理您的机构。
- 您的公钥-私钥对有权在私有自动化中心上配置内容签名。
流程
创建只接受文件名的签名脚本。
注意此脚本充当签名服务,必须使用通过
PULP_SIGNING_KEY_FINGERPRINT环境变量指定的密钥为该文件生成 ascii-armored 分离gpg签名。该脚本打印一个 JSON 结构,其格式如下:
{"file": "filename", "signature": "filename.asc"}所有文件名都是当前工作目录中的相对路径。对于分离的签名,文件名必须保持相同。
示例: 以下脚本为内容生成签名:
#!/usr/bin/env bash FILE_PATH=$1 SIGNATURE_PATH="$1.asc" ADMIN_ID="$PULP_SIGNING_KEY_FINGERPRINT" PASSWORD="password" # Create a detached signature gpg --quiet --batch --pinentry-mode loopback --yes --passphrase \ $PASSWORD --homedir ~/.gnupg/ --detach-sign --default-key $ADMIN_ID \ --armor --output $SIGNATURE_PATH $FILE_PATH # Check the exit status STATUS=$? if [ $STATUS -eq 0 ]; then echo {\"file\": \"$FILE_PATH\", \"signature\": \"$SIGNATURE_PATH\"} else exit $STATUS fi部署私有自动化中心后,为 Ansible Automation Platform 集群启用了签名后,会在集合中会显示新的 UI。
查看 Ansible Automation Platform 安装程序清单文件中的以
automationhub_*开头的选项。[all:vars] . . . automationhub_create_default_collection_signing_service = True automationhub_auto_sign_collections = True automationhub_require_content_approval = True automationhub_collection_signing_service_key = /abs/path/to/galaxy_signing_service.gpg automationhub_collection_signing_service_script = /abs/path/to/collection_signing.sh两个新密钥(automationhub_auto_sign_collections 和 automationhub_require_content_approval)表示必须签名集合,并在上传到私有自动化中心后需要批准。
3.3.1.7. 在 Event-Driven Ansible 控制器中添加安全插件变量 复制链接链接已复制到粘贴板!
当使用 redhat.insights_eda 或类似的插件在 Event-Driven Ansible 控制器中运行规则激活时,您必须将安全插件变量添加到 Ansible Automation Platform 中的目录中。这样可确保 Event-Driven Ansible 控制器和源插件之间的连接,并正确显示端口映射。
流程
-
为 secure 插件变量创建一个目录:
mkdir -p ./group_vars/automationedacontroller -
在该目录中为您的新设置创建一个文件(例如,
touch ./group_vars/automationedacontroller/custom.yml) 添加变量
automationedacontroller_additional_settings,以扩展 Event-Driven Ansible 控制器的默认settings.yaml模板,并使用要启用的插件列表添加SAFE_PLUGINS字段。例如:automationedacontroller_additional_settings: SAFE_PLUGINS: - ansible.eda.webhook - ansible.eda.alertmanager注意您还可以在 Django 配置文件
/etc/ansible-automation-platform/eda/settings.yaml之外,将automationedacontroller_additional_settings变量扩展到SAFE_PLUGINS。
3.3.2. 设置 registry_username 和 registry_password 复制链接链接已复制到粘贴板!
将 registry_username 和 registry_password 变量用于在线非捆绑包安装时,您需要创建新的 registry 服务帐户。
registry 服务帐户名为 token,您可以在共享凭证的环境中使用,如部署系统。
流程
- 进入 https://access.redhat.com/terms-based-registry/accounts。
- 在 Registry Service Accounts 页面中,单击 。
- 仅使用允许的字符为帐户输入一个名称。
- (可选)输入帐户的描述。
- 点 。
- 通过在搜索字段中搜索您的名称,在列表中找到创建的帐户。
- 点您创建的帐户的名称。
或者,如果您知道令牌的名称,可以通过输入 URL 来直接进入页面:
https://access.redhat.com/terms-based-registry/token/<name-of-your-token>此时会打开 令牌 页面,显示生成的用户名(与帐户名称不同)和令牌。
- 如果没有令牌,点 。您还可以单击它以生成新的用户名和令牌。
-
复制用户名(如"1234567|testuser")并使用它来设置变量
registry_username。 -
复制令牌,并使用它来设置变量
registry_password。
3.3.2.1. 配置 Redis 复制链接链接已复制到粘贴板!
Ansible Automation Platform 在独立 和集群拓扑中提供集中的 Redis 实例。
在 RPM 部署中,Red Hat Redis 模式默认设置为 cluster。您可以在清单文件 [all:vars] 部分中更改此设置,如下例所示:
[all:vars]
admin_password='<password>'
pg_host='data.example.com'
pg_port='5432'
pg_database='awx'
pg_username='awx'
pg_password='<password>'
pg_sslmode='prefer' # set to 'verify-full' for client-side enforced SSL
registry_url='registry.redhat.io'
registry_username='<registry username>'
registry_password='<registry password>'
redis_mode=cluster
有关 Redis 的更多信息,请参阅 规划安装 中的 缓存和队列系统。