community.general.yarn module – Manage node.js packages with Yarn
Note
This module is part of the community.general collection (version 10.1.0).
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
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.yarn
.
Synopsis
Manage node.js packages with the Yarn package manager (https://yarnpkg.com/)
Requirements
The below requirements are needed on the host that executes this module.
Yarn installed in bin path (typically /usr/local/bin)
Parameters
Parameter |
Comments |
---|---|
The executable location for yarn. |
|
Install the node.js library globally Choices:
|
|
Use the –ignore-scripts flag when installing. Choices:
|
|
The name of a node.js library to install If omitted all packages in package.json are installed. To globally install from local node.js library. Prepend “file:” to the path of the node.js library. |
|
The base path where Node.js libraries will be installed. This is where the node_modules folder lives. |
|
Install dependencies in production mode. Yarn will ignore any dependencies under devDependencies in package.json Choices:
|
|
The registry to install modules from. |
|
Installation state of the named node.js library If absent is selected, a name option must be provided Choices:
|
|
The version of the library to be installed. Must be in semver format. If “latest” is desired, use “state” arg instead |
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Examples
- name: Install "imagemin" node.js package.
community.general.yarn:
name: imagemin
path: /app/location
- name: Install "imagemin" node.js package on version 5.3.1
community.general.yarn:
name: imagemin
version: '5.3.1'
path: /app/location
- name: Install "imagemin" node.js package globally.
community.general.yarn:
name: imagemin
global: true
- name: Remove the globally-installed package "imagemin".
community.general.yarn:
name: imagemin
global: true
state: absent
- name: Install "imagemin" node.js package from custom registry.
community.general.yarn:
name: imagemin
registry: 'http://registry.mysite.com'
- name: Install packages based on package.json.
community.general.yarn:
path: /app/location
- name: Update all packages in package.json to their latest version.
community.general.yarn:
path: /app/location
state: latest
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Whether Yarn changed any package data Returned: always Sample: |
|
Parameters and values used during execution Returned: success Sample: |
|
Provides an error message if Yarn syntax was incorrect Returned: failure Sample: |
|
Output generated from Yarn. Returned: always Sample: |