在ansible中使用远程文件服务器作为数据源

Use remote file server as data source in ansible

我正在尝试使用本地网络中的文件服务器作为 rpm 包的源,我稍后想在 playbook 的远程机器上安装它。

为此,我使用了一个简单的 Apache Web 服务器,我将我的包存储在 /var/www/httml/packages/list-of-packages

我认为可以在文件中的某处使用等效主机名声明文件服务器的 ip,然后在 playbook 中使用它,但我不记得具体是怎么做的 喜欢

最后应该是这样的:

src: {file-server}/packages/airtame/airtame.rpm

我猜你正在看一个事实,即 ansible yum module 的包 name 允许你:

  • 使用包名
  • 对包使用 URL
  • 使用本地路径将文件归档到程序包

name: A package name or package specifier with version, like name-1.0.
If a previous version is specified, the task also needs to turn allow_downgrade on. See the allow_downgrade documentation for caveats with downgrading packages.
When using state=latest, this can be '*' which means run yum -y update.
You can also pass a url or a local path to a rpm file (using state=present). To operate on several packages this can accept a comma separated string of packages or (as of 2.0) a list of packages.

来源: https://docs.ansible.com/ansible/latest/modules/yum_module.html#parameters,强调我的。

来自示例:

- name: install the nginx rpm from a remote repo
  yum:
    name: http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
    state: present

- name: install nginx rpm from a local file
  yum:
    name: /usr/local/src/nginx-release-centos-6-0.el6.ngx.noarch.rpm
    state: present

来源: https://docs.ansible.com/ansible/latest/modules/yum_module.html#examples