community.general.cpanm 模块 – 管理 Perl 库依赖项

注意

此模块是 community.general 集合(版本 10.1.0)的一部分。

如果您使用的是 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.general

要在 playbook 中使用它,请指定:community.general.cpanm

概要

  • 使用 cpanminus 管理 Perl 库依赖项。

参数

参数

注释

executable

路径

覆盖 cpanm 可执行文件的路径。

from_path

路径

要从中安装的本地目录或 tar.gz 文件。

installdeps

布尔值

仅安装依赖项。

选项

  • false ←(默认)

  • true

locallib

路径

指定要安装模块的安装基础。

mirror

字符串

指定要使用的 CPAN 镜像的基本 URL。

mirror_only

布尔值

使用镜像的索引文件,而不是 CPAN Meta DB。

选项

  • false ←(默认)

  • true

mode

字符串

在 community.general 3.0.0 中添加

控制模块行为。有关更多详细信息,请参见下面的注释。

默认值在 community.general 9.0.0 中从 compatibility 更改为 new

选项

  • "compatibility"

  • "new" ←(默认)

name

别名:pkg

字符串

要安装的 Perl 库。有效值根据 mode 而变化,有关更多详细信息,请参见注释。

请注意,对于从本地路径安装,应使用参数 from_path

name_check

字符串

在 community.general 3.0.0 中添加

mode=new 时,可以使用此参数来检查是否已安装了模块 name(在指定 version 时)。

notest

布尔值

不运行单元测试。

选项

  • false ←(默认)

  • true

version

字符串

Perl 模块的版本规范。当 modenew 时,接受 cpanm 版本运算符。

属性

属性

支持

描述

check_mode

支持:

可以在 check_mode 中运行,并在不修改目标的情况下返回更改状态预测。

diff_mode

支持:

在 diff 模式下,当在 check_mode 时,将返回有关已更改(或可能需要更改)的详细信息。

注释

注意

  • 请注意,必须在远程主机上安装 http://search.cpan.org/dist/App-cpanminus/bin/cpanm, cpanm

  • 此模块现在提供执行 mode 的选择:compatibilitynew

  • mode=compatibility: 当使用 compatibility 模式时,该模块将保持向后兼容性。 这是 community.general 9.0.0 之前的默认模式。 name 必须是模块名称或发行版文件。 如果由 name 给出的 Perl 模块已安装(当指定 version 时,版本必须完全一致),则不执行任何操作。 否则,它将使用 cpanm 可执行文件进行安装。name 不能是 URL 或 git URL。 cpanm 版本说明符在此模式下不起作用。

  • mode=new: 当使用 new 模式时,该模块的行为将有所不同。 name 参数可以引用模块名称、发行版文件、HTTP URL 或 git 仓库 URL,如 cpanminus 文档中所述。 cpanm 版本说明符可以被识别。 这是从 community.general 9.0.0 开始的默认模式。

参见

另请参阅

C(cpanm) 命令手册页

此命令的手册页。

示例

---
- name: Install Dancer perl package
  community.general.cpanm:
    name: Dancer

- name: Install version 0.99_05 of the Plack perl package
  community.general.cpanm:
    name: MIYAGAWA/Plack-0.99_05.tar.gz

- name: Install Dancer into the specified locallib
  community.general.cpanm:
    name: Dancer
    locallib: /srv/webapps/my_app/extlib

- name: Install perl dependencies from local directory
  community.general.cpanm:
    from_path: /srv/webapps/my_app/src/

- name: Install Dancer perl package without running the unit tests in indicated locallib
  community.general.cpanm:
    name: Dancer
    notest: true
    locallib: /srv/webapps/my_app/extlib

- name: Install Dancer perl package from a specific mirror
  community.general.cpanm:
    name: Dancer
    mirror: 'http://cpan.cpantesters.org/'

- name: Install Dancer perl package into the system root path
  become: true
  community.general.cpanm:
    name: Dancer

- name: Install Dancer if it is not already installed OR the installed version is older than version 1.0
  community.general.cpanm:
    name: Dancer
    version: '1.0'

返回值

常见返回值已在此处记录,以下是此模块独有的字段

描述

cpanm_version

字符串

在 community.general 10.0.0 中添加

CPANMinus 的版本。

返回: 总是

示例: "1.7047"

作者

  • Franck Cuny (@fcuny)

  • Alexei Znamensky (@russoz)