community.general.cpanm – Manages Perl library dependencies.

Note

This plugin is part of the community.general collection (version 3.8.1).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.cpanm.

Synopsis

  • Manage Perl library dependencies using cpanminus.

Parameters

Parameter Choices/Defaults Comments
executable
path
Override the path to the cpanm executable.
from_path
path
The local directory or tar.gz file to install from.
installdeps
boolean
    Choices:
  • no
  • yes
Only install dependencies.
locallib
path
Specify the install base to install modules.
mirror
string
Specifies the base URL for the CPAN mirror to use.
mirror_only
boolean
    Choices:
  • no
  • yes
Use the mirror's index file instead of the CPAN Meta DB.
mode
string
added in 3.0.0 of community.general
    Choices:
  • compatibility
  • new
Controls the module behavior. See notes below for more details.
name
string
The Perl library to install. Valid values change according to the mode, see notes for more details.
Note that for installing from a local path the parameter from_path should be used.

aliases: pkg
name_check
string
added in 3.0.0 of community.general
When in new mode, this parameter can be used to check if there is a module name installed (at version, when specified).
notest
boolean
    Choices:
  • no
  • yes
Do not run unit tests.
system_lib
boolean
    Choices:
  • no
  • yes
Use this if you want to install modules to the system perl include path. You must be root or have "passwordless" sudo for this to work.
This uses the cpanm commandline option --sudo, which has nothing to do with ansible privilege escalation.
This option is not recommended for use and it will be deprecated in the future. If you need to escalate privileges please consider using any of the multiple mechanisms available in Ansible.

aliases: use_sudo
version
string
Version specification for the perl module. When mode is new, cpanm version operators are accepted.

Notes

Note

  • Please note that http://search.cpan.org/dist/App-cpanminus/bin/cpanm, cpanm must be installed on the remote host.
  • This module now comes with a choice of execution mode: compatibility or new.
  • compatibility mode:
  • When using compatibility mode, the module will keep backward compatibility. This is the default mode.
  • name must be either a module name or a distribution file.
  • If the perl module given by name is installed (at the exact version when specified), then nothing happens. Otherwise, it will be installed using the cpanm executable.
  • name cannot be an URL, or a git URL.
  • cpanm version specifiers do not work in this mode.
  • new mode:
  • When using new mode, the module will behave differently
  • The name parameter may refer to a module name, a distribution file, a HTTP URL or a git repository URL as described in cpanminus documentation.
  • cpanm version specifiers are recognized.

Examples

- 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: yes
  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'

Authors

  • Franck Cuny (@fcuny)
  • Alexei Znamensky (@russoz)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/cpanm_module.html