community.general.yarn (8.5.0) — module

Manage node.js packages with Yarn

Authors: David Gunter (@verkaufer), Chris Hoffman (@chrishoffman), creator of NPM Ansible module)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Manage node.js packages with the Yarn package manager (https://yarnpkg.com/)


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install "imagemin" node.js package.
  community.general.yarn:
    name: imagemin
    path: /app/location
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install "imagemin" node.js package on version 5.3.1
  community.general.yarn:
    name: imagemin
    version: '5.3.1'
    path: /app/location
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install "imagemin" node.js package globally.
  community.general.yarn:
    name: imagemin
    global: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove the globally-installed package "imagemin".
  community.general.yarn:
    name: imagemin
    global: true
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install "imagemin" node.js package from custom registry.
  community.general.yarn:
    name: imagemin
    registry: 'http://registry.mysite.com'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install packages based on package.json.
  community.general.yarn:
    path: /app/location
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update all packages in package.json to their latest version.
  community.general.yarn:
    path: /app/location
    state: latest

Inputs

    
name:
    description:
    - 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.
    required: false
    type: str

path:
    description:
    - The base path where Node.js libraries will be installed.
    - This is where the node_modules folder lives.
    required: false
    type: path

state:
    choices:
    - present
    - absent
    - latest
    default: present
    description:
    - Installation state of the named node.js library
    - If absent is selected, a name option must be provided
    required: false
    type: str

global:
    default: false
    description:
    - Install the node.js library globally
    required: false
    type: bool

version:
    description:
    - The version of the library to be installed.
    - Must be in semver format. If "latest" is desired, use "state" arg instead
    required: false
    type: str

registry:
    description:
    - The registry to install modules from.
    required: false
    type: str

executable:
    description:
    - The executable location for yarn.
    required: false
    type: path

production:
    default: false
    description:
    - Install dependencies in production mode.
    - Yarn will ignore any dependencies under devDependencies in package.json
    required: false
    type: bool

ignore_scripts:
    default: false
    description:
    - Use the --ignore-scripts flag when installing.
    required: false
    type: bool

Outputs

changed:
  description: Whether Yarn changed any package data
  returned: always
  sample: true
  type: bool
invocation:
  description: Parameters and values used during execution
  returned: success
  sample:
    module_args:
      executable: null
      globally: false
      ignore_scripts: false
      name: null
      path: /some/path/folder
      production: false
      registry: null
      state: present
      version: null
  type: dict
msg:
  description: Provides an error message if Yarn syntax was incorrect
  returned: failure
  sample: Package must be explicitly named when uninstalling.
  type: str
out:
  description: Output generated from Yarn.
  returned: always
  sample: yarn add v0.16.1[1/4] Resolving packages...[2/4] Fetching packages...[3/4]
    Linking dependencies...[4/4] Building fresh packages...success Saved lockfile.success
    Saved 1 new dependency..left-pad@1.1.3 Done in 0.59s.
  type: str