Documentation

2. 升级至 Ansible Automation Platform

从 Ansible Tower 3.8 开始, Automation Hub 将充当 Ansible Tower 的内容供应商,这需要一个 Ansible Tower 部署和一个 Automation Hub 部署一起运行。Ansible Automation Platform 安装程序包含这两个部分。本节涵盖了升级过程中的每个部分:

注解

所有升级的系统版本不能比您当前要升级到的版本低两个主要版本。例如,要升级到 Ansible Tower 3.7.x,您必须首先是在使用版本 3.5.x,没有从版本 3.4.x 或更早版本直接升级的路径。请参阅红帽客户门户网站的 recommended upgrade path article

为了运行 Ansible Tower 3.8,还必须有 Ansible 2.9。

2.1. 升级计划

本节论述了当您试图升级 Ansible Tower 实例时应注意的更改

  • 即使您已经拥有之前版本的有效许可证,您仍需要在在升级到 Ansible Tower 3.8 时提供您的凭证或一个订阅清单。详情请参阅 Ansible Tower User Guide 中的 导入订阅

  • 如果需要升级 Red Hat Enterprise Linux 和 Ansible Tower,则需要备份和恢复 Tower 数据。如需更多详情,请参阅 Ansible Automation Platform Installation and Reference Guide 中的 Upgrading an Existing Tower Installation

  • 在开始升级前,集群升级需要特别注意实例和实例组。详情请参阅 设置清单(Inventory)文件集群

  • Ansible Tower 的早期版本使用变量名称 rabbitmq_host。如果您是从以前的 Tower 版本进行升级,而您在清单中指定了 rabbitmq_host,请在升级前将 rabbitmq_host 重命名为 routable_hostname。请参阅 集群

2.2. 获取安装程序

详情请参阅 Ansible Automation Platform Installation and Reference Guide 中的 获取 Ansible Automation Platform 安装程序

2.3. 设置清单(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 中使用特殊字符, 因为它可能导致设置失败。

2.3.1. 清单文件示例

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

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

2.3.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

2.3.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

2.3.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 中使用特殊字符, 因为它可能导致设置失败。

2.3.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 中使用特殊字符, 因为它可能导致设置失败。

2.3.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 中使用特殊字符, 因为它可能导致设置失败。

2.3.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

2.4. 运行 Setup 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