3.2. 基于安装场景的清单文件示例
红帽支持多种 Ansible Automation Platform 安装场景。您可以使用示例文件作为基础开发自己的清单文件,也可以使用最接近您首选安装场景的示例。
3.2.1. 基于安装场景的清单文件建议 复制链接链接已复制到粘贴板!
在为 Ansible Automation Platform 选择安装方法前,请查看以下建议。熟悉这些建议可简化安装过程。
-
Red Hat Ansible Automation Platform 或 Automation hub:在
[automationhub]组中添加一个 Automation hub 主机。 - 对于生产环境或客户环境中的 Ansible Automation Platform 版本,不要在同一节点上安装自动化控制器和自动化中心。这可能导致争用问题和大量资源的使用。
为
[automationhub]和[automationcontroller]主机提供可访问 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.2.1.1. 带有外部(安装程序管理的)数据库的单一自动化控制器 复制链接链接已复制到粘贴板!
使用本示例填充清单文件来安装 Red Hat Ansible Automation Platform。此安装清单文件包含单一自动化控制器节点,单独节点上具有外部数据库。
[automationcontroller]
controller.example.com
[database]
data.example.com
[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>'
# 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.2.1.2. 单个自动化控制器和带有外部(安装程序管理的)数据库的单一自动化中心 复制链接链接已复制到粘贴板!
使用本示例填充清单文件,以使用外部(安装程序管理)数据库部署单一自动化控制器和自动化中心实例。
[automationcontroller]
controller.example.com
[automationhub]
automationhub.example.com
[database]
data.example.com
[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>'
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
# 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.2.1.2.1. 将自动化中心连接到 Red Hat Single Sign-On 环境 复制链接链接已复制到粘贴板!
您可以进一步配置清单文件,将自动化中心连接到 Red Hat Single Sign-On 安装。
在连接到由 Ansible Automation Platform 管理的 Red Hat Single Sign-On 安装时,您必须配置不同的变量集合,而不是连接到外部 Red Hat Single Sign-On 安装。
如需有关这些清单变量的更多信息,请参阅为 Ansible Automation Platform 安装和配置中央身份验证。
3.2.1.3. 高可用性自动化中心 复制链接链接已复制到粘贴板!
使用以下示例填充清单文件来安装高度可用的自动化中心。此清单文件包含一个具有集群设置的高可用性自动化中心。
您可以进一步配置 HA 部署来实现 Red Hat Single Sign-On,并在 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 ansible_host=192.0.2.18
automationhub2.testing.ansible.com ansible_user=cloud-user ansible_host=192.0.2.20
automationhub3.testing.ansible.com ansible_user=cloud-user ansible_host=192.0.2.22
USE_X_FORWARDED_PORT = True
USE_X_FORWARDED_HOST = True
如果没有指定 Automationhub_main_url,则默认使用 [automationhub] 组中的第一个节点。
3.2.1.4. 在 SELinux 中启用自动化中心的高可用性(HA)部署 复制链接链接已复制到粘贴板!
您可以配置清单文件,以便在 SELinux 中启用自动化中心的高可用性部署。您必须为 /var/lib/pulp 和 /var/lib/pulp/pulpcore_static 创建两个挂载点,然后为每个上下文分配适当的 SELinux 上下文。
您需要为 /var/lib/pulp 添加上下文,并在为 /var/lib/pulp 添加上下文前运行 Ansible Automation Platform 安装程序。
先决条件
- 您已在服务器上配置了 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.2.1.4.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.2.1.4.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.2.1.5. 在私有自动化 hub 中配置内容签名 复制链接链接已复制到粘贴板!
要成功签名并发布 Ansible 认证的内容集合,您必须配置私有自动化中心进行签名。
前提条件
- 您的 TIPC 密钥对已安全设置并管理您的机构。
- 您的公钥-私钥对有权在私有自动化中心上配置内容签名。
流程
创建只接受文件名的签名脚本。
注意此脚本充当签名服务,必须使用通过
PULP_SIGNING_KEY_FINGERPRINT环境变量指定的密钥为该文件生成 ascii-armored 分离gpg签名。该脚本打印一个 JSON 结构,其格式如下:
{"file": "filename", "signature": "filename.asc"}所有文件名都是当前工作目录中的相对路径。对于分离的签名,文件名必须保持相同。
Example:
以下脚本为内容生成签名:
#!/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.2.1.6. 私有自动化中心上的 LDAP 配置 复制链接链接已复制到粘贴板!
您必须在 Red Hat Ansible Automation Platform 安装程序清单文件中设置以下六个变量,以配置用于 LDAP 身份验证的私有自动化中心:
-
automationhub_authentication_backend -
automationhub_ldap_server_uri -
automationhub_ldap_bind_dn -
automationhub_ldap_bind_password -
automationhub_ldap_user_search_base_dn -
automationhub_ldap_group_search_base_dn
如果缺少其中任何这些变量,Ansible Automation 安装程序将无法完成安装。
3.2.1.6.1. 设置清单文件变量 复制链接链接已复制到粘贴板!
当使用 LDAP 身份验证配置私有自动化中心时,您必须在安装过程中在清单文件中设置正确的变量。
流程
- 根据 编辑 Red Hat Ansible Automation Platform 安装程序清单文件 中的步骤访问您的清单文件。
使用以下示例来设置 Ansible Automation Platform 清单文件:
automationhub_authentication_backend = "ldap" automationhub_ldap_server_uri = "ldap://ldap:389" (for LDAPs use automationhub_ldap_server_uri = "ldaps://ldap-server-fqdn") automationhub_ldap_bind_dn = "cn=admin,dc=ansible,dc=com" automationhub_ldap_bind_password = "GoodNewsEveryone" automationhub_ldap_user_search_base_dn = "ou=people,dc=ansible,dc=com" automationhub_ldap_group_search_base_dn = "ou=people,dc=ansible,dc=com"注意以下变量将使用默认值设置,除非您使用其他选项进行了设置。
auth_ldap_user_search_scope= 'SUBTREE' auth_ldap_user_search_filter= '(uid=%(user)s)' auth_ldap_group_search_scope= 'SUBTREE' auth_ldap_group_search_filter= '(objectClass=Group)' auth_ldap_group_type_class= 'django_auth_ldap.config:GroupOfNamesType'- 可选:在私有自动化中心中设置额外的参数,如用户组、超级用户访问或镜像。前往 配置额外的 LDAP 参数 以完成此可选步骤。
3.2.1.6.2. 配置额外的 LDAP 参数 复制链接链接已复制到粘贴板!
如果您计划设置超级用户访问权限、用户组、镜像或其他额外参数,您可以创建一个在 ldap_extra_settings 字典中组成它们的 YAML 文件。
流程
创建一个包含
ldap_extra_settings的 YAML 文件。Example:
#ldapextras.yml --- ldap_extra_settings: <LDAP_parameter>: <Values> ...
添加设置所需的任何参数。以下示例描述了您可以在
ldap_extra_settings中设置的 LDAP 参数:使用本示例根据 LDAP 组中的成员资格设置超级用户标志。
#ldapextras.yml --- ldap_extra_settings: AUTH_LDAP_USER_FLAGS_BY_GROUP: {"is_superuser": "cn=pah-admins,ou=groups,dc=example,dc=com",} ...使用本示例设置超级用户访问权限。
#ldapextras.yml --- ldap_extra_settings: AUTH_LDAP_USER_FLAGS_BY_GROUP: {"is_superuser": "cn=pah-admins,ou=groups,dc=example,dc=com",} ...使用本示例来镜像(mirror)您属于的所有 LDAP 组。
#ldapextras.yml --- ldap_extra_settings: AUTH_LDAP_MIRROR_GROUPS: True ...使用本示例映射 LDAP 用户属性(如用户名、姓氏和电子邮件地址)。
#ldapextras.yml --- ldap_extra_settings: AUTH_LDAP_USER_ATTR_MAP: {"first_name": "givenName", "last_name": "sn", "email": "mail",} ...使用以下示例根据 LDAP 组成员资格授予或拒绝访问权限:
要授予私有自动化中心访问权限(例如,
cn=pah-nosoupforyou,ou=groups,dc=example,dc=com组的成员):#ldapextras.yml --- ldap_extra_settings: AUTH_LDAP_REQUIRE_GROUP: 'cn=pah-nosoupforyou,ou=groups,dc=example,dc=com' ...拒绝私有自动化中心访问(例如,
cn=pah-nosoupforyou,ou=groups,dc=example,dc=com组的成员):#ldapextras.yml --- ldap_extra_settings: AUTH_LDAP_DENY_GROUP: 'cn=pah-nosoupforyou,ou=groups,dc=example,dc=com' ...
使用本示例启用 LDAP 调试日志记录。
#ldapextras.yml --- ldap_extra_settings: GALAXY_LDAP_LOGGING: True ...注意如果重新运行
setup.sh或在短时间内启用了调试日志,则可以将包含GALAXY_LDAP_LOGGING: True的行手动添加到私有自动化中心上的/etc/pulp/settings.py文件。重启pulpcore-api.service和nginx.service以使更改生效。为了避免因为人为错误而失败,请仅在需要时使用此方法。通过设置变量
AUTH_LDAP_CACHE_TIMEOUT,使用本示例配置 LDAP 缓存。#ldapextras.yml --- ldap_extra_settings: AUTH_LDAP_CACHE_TIMEOUT: 3600 ...
-
在私有自动化中心安装过程中运行
setup.sh -e @ldapextras.yml。验证您已正确设置,请确认您可以在私有自动化中心上的/etc/pulp/settings.py文件中查看所有设置。
3.2.1.6.3. LDAP 引用 复制链接链接已复制到粘贴板!
如果您的 LDAP 服务器返回引用,您可能需要禁用引用才能在私有自动化中心中使用 LDAP 成功进行身份验证。
如果没有,则返回以下信息:
Operation unavailable without authentication
要禁用 LDAP REFERRALS 查找,请设置:
GALAXY_LDAP_DISABLE_REFERRALS = true
这会将 AUTH_LDAP_CONNECTIONS_OPTIONS 设置为正确的选项。
使用本示例填充清单文件,以使用外部(安装程序管理)数据库部署单一自动化控制器、自动化中心和 Event-Driven Ansible 控制器实例。
- 此场景至少需要自动化控制器 2.4 才能成功部署 Event-Driven Ansible 控制器。
- event-Driven Ansible 控制器必须安装在单独的服务器上,且不能安装到与自动化中心和自动化控制器相同的主机上。
-
事件驱动的 Ansible 控制器不能安装在高可用性或集群的配置中。确保清单的
automationedacontroller部分中只有一个主机条目。 -
当在标准条件下激活 Event-Driven Ansible rulebook 时,它使用大约 250 MB 内存。但是,实际内存消耗可能会因规则的复杂性以及处理的事件的大小和大小有很大不同。在预计大量事件或规则手册复杂性很高的情况下,对暂存环境中的资源使用情况进行初步评估。这样可确保最大激活数量基于资源容量。在以下示例中,默认的
automationedacontroller_max_running_activations设置为 12,但可以根据容量进行调整。
[automationcontroller]
controller.example.com
[automationhub]
automationhub.example.com
[automationedacontroller]
automationedacontroller.example.com
[database]
data.example.com
[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>'
# 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
# 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
3.2.1.8. 在 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_safe_plugins变量添加到 文件中,以启用 Event-Driven Ansible 控制器。例如:automationedacontroller_safe_plugins: “ansible.eda.webhook, ansible.eda.alertmanager”