oasis_roles.ocp_client_install
ocp_client_install
下载并安装 oc
和 kubectl
二进制文件到指定目录。
此工具用于安装 OpenShift Container Platform (OCP) 4.x 中所用的 oc
和 kubectl
客户端,具体参考官方 Red Hat OCP 4 安装文档。
要求
Ansible 2.9 或更高版本
红帽企业 Linux 7 或同等系统
有效的红帽订阅
角色变量
当前支持以下变量:
一般
ocp_client_install_url
- 必填,OCP 客户端归档文件的 http(s) URL。下面的示例中包含了自动设置此项的示例。ocp_client_install_path
- 默认值:/usr/local/bin/
。安装oc
和kubectl
二进制文件的目标目录。该位置应在系统PATH
中。ocp_client_install_tmpdir
- 默认值:/tmp/ocp_client_install
。下载 OCP 客户端归档文件的目录。ocp_client_install_cleanup
- 默认值:false
。为了保证幂等性,默认情况下该角色不会删除ocp_client_install_tmpdir
目录。将其设置为true
可使该角色清理ocp_client_install_tmpdir
。
权限提升
ocp_client_install_become
- 默认值:true
。如果该角色需要管理权限,则使用 Ansible 的权限提升功能(基于 sudo)。ocp_client_install_become_user
- 默认值:root
。如果角色使用权限提升功能,则此项为目标用户的名称。
依赖
无
示例剧本
使用绝对 URL 直接下载归档文件
- hosts: ocp_client_install
roles:
- role: oasis_roles.ocp_client_install
ocp_client_install_url: 'https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux-4.2.4.tar.gz'
使用 index_href
角色
自动获取最新的 OCP 客户端归档文件 URL:
- hosts: ocp_client_install
vars:
# 尾部斜杠非常重要
ocp_installers_index_url: https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/
ocp_installers_index: "{{ query('url', ocp_installers_index_url) }}"
ocp_client_install_url: >-
{{ query('index_href', ocp_installers_index, 'client-linux',
base_url=ocp_installers_index_url) }}
roles:
- oasis_roles.ocp_client_install
- oasis_roles.index_href
请注意,如果 OCP 客户端下载索引中使用的文件命名方案发生变化,此示例可能会有所更改。
许可证
GPLv3
作者信息
Sean Myers semyers@redhat.com