Documentation

3. 安装 Ansible Automation Platform

通过选择适合具体环境的模式并对清单文件进行修改,可以使用不同的方式安装 Ansible Automation Platform。对于基于 OpenShift 的部署,您只能在 OpenShift 上部署 Tower。在 OpenShift 上部署 Automation Hub 不被支持。但是,您可以在一个指向 OpenShift 的虚拟环境中部署 Automation Hub。如需更多详情,请参阅 OpenShift Deployment and Configuration

3.1. Ansible Automation Platform 安装场景

Ansible Automation Platform 可使用以下场景之一安装:

单机

  • 带有数据库的独立的 Tower,作为 Tower 管理的或非安装程序管理的数据库位于同一个节点上 。这是 Tower 的单一机器安装 - web 前端、REST API 后端和数据库都位于一台机器上。这是 Tower 的标准安装。它还从 OS 厂商仓库安装 PostgreSQL,并将 Tower 服务配置为将其用作数据库。

    [tower]
    host
    
  • 带有一个外部数据库的独立 Tower:这会在一台机器上安装 Tower 服务器,并将它配置为使用一个远程的 PostgreSQL 10 实例作为它的数据库。这个远程 PostgreSQL 可以是您自己管理的服务器,也可由 云服务商(如 Amazon RDS)提供。

    [tower]
    host
    
    [database]
    host2
    
  • 带有一个位于同一个节点上的数据库的 Automation Hub,这个数据库可以是 Automation Hub 或非安装程序管理的数据库:

    [automationhub]
    host
    
  • 带有一个外部数据库的独立的 Automation Hub。这会在一台机器上安装 Automation Hub 服务器,并通过 playbook 安装程序(由 Automation Platform 安装程序管理)安装一个远程 PostgreSQL 数据库。

    [automationhub]
    host
    
    [database]
    host2
    

平台安装

平台安装涉及 Tower 和 Automation Hub。平台安装程序允许您每个清单部署 1 个且只能部署 1 个 Automation Hub。安装程序可以作为 Automation Hub 独立安装程序使用,如果您要部署多个 Automation Hub 节点,则可多次使用不同的清单运行安装程序。平台安装支持的 2 个选项是:

  • 带有一个位于同一个节点上的数据库的平台(Tower 和 Automation Hub),这个数据库可以是 Tower 或非安装程序管理的数据库:

    [tower]
    host1
    
    [automationhub]
    host2
    
  • 带有一个外部管理的数据库的平台(Tower 和 Automation Hub):

    [tower]
    host1
    
    [automationhub]
    host2
    
    [database]
    host3
    

多机器集群

这个场景包括使用外部管理的数据库的平台(集群的 Tower 和 Automation Hub)安装。在这个模式下,会安装并激活多个 Tower 节点。任何节点都可以接收 HTTP 请求,所有节点都可以执行作业。这会在一台机器上安装平台服务器,并将它配置为与远程 PostgreSQL 实例进行对话。这个远程 PostgreSQL 可以是您自己管理的服务器,也可以由云服务(如 Amazon RDS)提供:

[tower]
host1
host11
host12

[automationhub]
host2

[database]
host3

注解

在集群设置中运行需要 Tower 使用外部的数据库,PostgreSQL 必须在一个不是主(primary)或(secondary)tower 节点的机器上安装。在一个冗余设置中,远程 PostgreSQL 版本要求是 PostgreSQL 10

有关配置集群设置的详情,请参考 集群

注解

1). Tower 将不会为它使用的数据库配置复制或故障转移功能,但 Tower 应该可以和已有的复制机制一起工作。2). 为获得更好的性能,数据库服务器应该和 Tower 服务器位于同一个网络或同一个数据中心。3)Tower 和 Automation Hub 不能在同一节点上运行,这种场景不被支持。这意味着,任何平台的部署都会是至少 2 个节点部署的拓扑。

Automation Platform 安装的可用设置:

  • automationhub_importer_settings:传递给 galaxy-importer 的设置/配置字典,它最终会位于 /etc/galaxy-importer/galaxy-importer.cfg

  • automationhub_require_content_approval:在集合可用前,Automation Hub 是否强制实施批准机制

  • automationhub_disable_https:Automation Hub 是否应该被部署为启用 TLS

  • automationhub_disable_hsts:Automation Hub 是否应该被部署为启用 HTTP Strict Transport Security(HSTS)Web-security 策略机制

  • automationhub_ssl_validate_certs:在请求自身时 Automation Hub 是否应该验证证书(默认为 False)。默认情况下,平台被部署为带有自签名证书

  • automationhub_ssl_cert:与 web_server_ssl_cert 相同,但用于 Automation Hub UI 和 API

  • automationhub_ssl_key:与 web_server_ssl_key 相同,但用于 Automation Hub UI 和 API

  • automationhub_backup_collections:Automation Hub 在 /var/lib/pulp 中提供工件。默认情况下,它会被设置为 true,因此 Tower 会默认自动备份工件。如果在此挂载了一个分区(如 LVM、NFS、CephFS 等),企业级的机构会确保它始终被备份。因此,您可以设置 automationhub_backup_collections = false,从而使备份/恢复过程不对 /var/lib/pulp 进行备份和恢复。

对于基于 OpenShift 的部署,请参考 OpenShift Deployment and Configuration

3.2. 设置清单(Inventory)文件

在编辑清单(inventory)文件时,您必须记住以下几点:

  • 清单文件的内容应该在 ./inventory 中定义,并由 ./setup.sh 安装程序 playbook 引用。

  • 安装和升级:如果需要使用外部数据库,您必须确保清单文件中的数据库部分被正确设置。在运行设置脚本前,编辑此文件以添加外部数据库信息。

  • Ansible Automation PlatformAutomation Hub:确保在 [automationhub] 组中添加了一个 Automation hub 主机(Tower 和 Automation Hub 不能安装在同一个节点上)。

  • Tower 不会为它使用的数据库配置复制或故障转移功能,但 Tower 应该可以和已有的复制机制一起工作。

  • 出于性能的原因,数据库服务器应该位于同一个网络或与 Tower 服务器相同的数据中心。

  • 升级现有集群:当升级集群时,您可能需要重新配置集群以忽略现有的实例或实例组。从清单文件中删除这些实例或实例组不足以从集群中删除它们。除了在清单文件中删除它们以外,在开始升级前,请参阅 deprovision instances or instance groups 的内容进行需要的操作。否则,忽略的实例或实例组将继续与集群通信,这可能会导致 tower 服务在升级过程中出现问题。

  • 集群安装:如果您要创建集群设置,则必须使用所有实例的主机名或 IP 地址替换 localhost。所有节点/实例都必须能够使用这个主机名或 IP 地址访问其他节点。换句话说,您不能在其中一个节点上使用``localhost ansible_connection=local`` *并且*所有节点都应该使用相同的主机名格式。

    因此,这将*不能*工作:

    [tower]
    localhost ansible_connection=local
    hostA
    hostB.example.com
    172.27.0.4
    

    需要使用以下格式:

    [tower]
    hostA
    hostB
    hostC
    

    或者

    [tower]
    hostA.example.com
    hostB.example.com
    hostC.example.com
    

    或者

    [tower]
    172.27.0.2
    172.27.0.3
    172.27.0.4
    
  • 所有标准安装:当执行安装时,您必须在清单文件中提供所需的密码。

注解

对安装过程所做的更改现在需要填写清单文件中的所有密码字段。它们应该和以下类似:。它们应该和以下类似:

admin_password='' <-- Tower 本地 admin 密码

pg_password='' <---- 在 /etc/tower/conf.d/postgres.py 中

警告

不要在 pg_password 中使用特殊字符, 因为它可能导致设置失败。

3.2.1. 清单文件示例

  • 置备新节点:当置备新节点时,将节点添加到清单文件,确保所有密码都包含在清单文件中。

  • 升级一个节点:当升级时,将清单文件与当前版本进行比较。推荐即使在升级时,也在清单文件中保存密码。

3.2.1.1. 独立 Automation Hub 清单文件示例

[automationhub]
automationhub.acme.org
[all:vars]
automationhub_admin_password='<password>'
automationhub_pg_host=''
automationhub_pg_port=''
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

3.2.1.2. 平台清单文件示例

[tower]
tower.acme.org
[automationhub]
automationhub.acme.org
[database]
database-01.acme.org
[all:vars]
admin_password='<password>'
pg_host='database-01.acme.org'
pg_port='5432'
pg_database='awx'
pg_username='awx'
pg_password='<password>'
pg_sslmode='prefer'  # set to 'verify-full' for client-side enforced SSL
# Automation Hub Configuration
#
automationhub_admin_password='<password>'
automationhub_pg_host='database-01.acme.org'
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
# Isolated Tower nodes automatically generate an RSA key for authentication;
# To disable this behavior, set this value to false
# isolated_key_generation=true
# 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
# Certificate and key to install in Automation Hub node
# automationhub_ssl_cert=/path/to/automationhub.cert
# automationhub_ssl_key=/path/to/automationhub.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.3. 单一节点清单文件示例

[tower]
localhost ansible_connection=local

[database]

[all:vars]
admin_password='password'

pg_host=''
pg_port=''

pg_database='awx'
pg_username='awx'
pg_password='password'

警告

不要在 pg_password 中使用特殊字符, 因为它可能导致设置失败。

3.2.1.4. 多节点集群清单文件示例

[tower]
clusternode1.example.com
clusternode2.example.com
clusternode3.example.com

[database]
dbnode.example.com

[all:vars]
ansible_become=true

admin_password='password'

pg_host='dbnode.example.com'
pg_port='5432'

pg_database='tower'
pg_username='tower'
pg_password='password'

警告

不要在 pg_password 中使用特殊字符, 因为它可能导致设置失败。

3.2.1.5. 外部数据库的清单文件示例

[tower]
node.example.com ansible_connection=local

[database]

[all:vars]
admin_password='password'
pg_password='password'


pg_host='database.example.com'
pg_port='5432'

pg_database='awx'
pg_username='awx'

警告

不要在 pg_password 中使用特殊字符, 因为它可能导致设置失败。

3.2.1.6. 需要安装外部数据库的清单文件示例

[tower]
node.example.com ansible_connection=local


[database]
database.example.com

[all:vars]
admin_password='password'
pg_password='password'

pg_host='database.example.com'
pg_port='5432'

pg_database='awx'
pg_username='awx'

警告

不要在 pg_password 中使用特殊字符, 因为它可能导致设置失败。

一旦进行了必要的修改,就可以运行 ./setup.sh

注解

需要对远程机器的 root 访问权限。在 Ansible 中,可以通过以下不同方式实现:

  • ansible_user=root ansible_ssh_pass="your_password_here" inventory host or group variables

  • ansible_user=root ansible_ssh_private_key_file="path_to_your_keyfile.pem" inventory host or group variables

  • ANSIBLE_BECOME_METHOD='sudo' ANSIBLE_BECOME=True ./setup.sh

  • ANSIBLE_SUDO=True ./setup.sh(只适用于 Ansible 2.7)

DEFAULT_SUDO Ansible 配置参数在 Ansible 2.8 中被删除,这会导致使用 ANSIBLE_SUDO=True ./setup.sh 进行权限升级的方法无法正常工作。如需了解关于 become 插件的更多信息,请参考 Understanding Privilege Escalationlist of become plugins

3.3. Playbook 设置

Tower 的设置(setup)playbook 脚本使用 inventory 文件,它通过 Tower 安装程序 tarball 被解包到的目录中的 ./setup.sh 运行。

root@localhost:~$ ./setup.sh

设置脚本使用以下参数:

  • -h -- 显示帮助信息并退出

  • -i INVENTORY_FILE -- 到 Ansible 清单文件的路径(默认: inventory

  • -e EXTRA_VARS -- 使用 key=value 或 YAML/JSON 设置额外的 Ansible 变量(例如, -e bundle_install=false 强制在线安装)

  • -b -- 在安装时执行数据库备份

  • -r -- 在安装时执行数据库恢复(除非通过 EXTRA_VARS 提供了一个非默认的路径,使用默认的恢复路径。如下所示)

./setup.sh -e 'restore_backup_file=/path/to/nondefault/location' -r

在使用适当参数调用 ./setup.sh 后,Tower 会按照配置在适当的机器上进行安装。设置脚本使用 ansible.com 中的软件仓库提供的 RPM 安装 Tower。

当设置完成后,使用网页浏览器访问 Tower 服务器并出现 Tower 登录界面。您的 Tower 服务器可从端口 80(https://<TOWER_SERVER_NAME>)访问,但会被重定向到端口 443,因此端口 443 需要可以被访问。

Login form

如果 Tower 安装失败,且您购买了有效的 Ansible Tower 许可证,请通过红帽客户门户网站 https://access.redhat.com/ 联络 Ansible。

3.4. 更改密码

安装完成后,如果需要通过 SSH 登录到 Tower 实例,默认的 admin 密码会在提示符后提供。您可以使用以下命令(以 root 用户或 AWX 用户)更改该密码:

awx-manage changepassword admin

之后,您输入的新密码将作为 Web UI 中的 admin 密码使用。