ansible.builtin.yarn (v2.9.27) — module

Manage node.js packages with Yarn

| "added in version" 2.6 of ansible.builtin"

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

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

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.
  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
  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.
  yarn:
    name: imagemin
    global: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove the globally-installed package "imagemin".
  yarn:
    name: imagemin
    global: yes
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install "imagemin" node.js package from custom registry.
  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.
  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.
  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.
    required: false

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

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

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

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

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

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 with emojis removed.
  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