Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

community.general.yarn module fails when provided state:latest and global:true #5712

Closed
1 task done
sargunv opened this issue Dec 19, 2022 · 3 comments · Fixed by #5829
Closed
1 task done

community.general.yarn module fails when provided state:latest and global:true #5712

sargunv opened this issue Dec 19, 2022 · 3 comments · Fixed by #5829
Labels
bug This issue/PR relates to a bug language module module packaging plugins plugin (any type)

Comments

@sargunv
Copy link
Contributor

sargunv commented Dec 19, 2022

Summary

The docs state I can pass a state: latest parameter, but when I try it I get an error "Invalid subcommand" if global is also set.

Issue Type

Bug Report

Component Name

yarn

Ansible Version

$ ansible --version
ansible [core 2.13.6]
  config file = None
  configured module search path = ['/Users/sargunv/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/6.6.0/libexec/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/sargunv/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/Cellar/ansible/6.6.0/libexec/bin/ansible
  python version = 3.10.9 (main, Dec 15 2022, 17:11:09) [Clang 14.0.0 (clang-1400.0.29.202)]
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

# /opt/homebrew/Cellar/ansible/6.6.0/libexec/lib/python3.10/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 5.8.0  

Configuration

$ ansible-config dump --only-changed

OS / Environment

macOS 13
yarn 1.22.19

Steps to Reproduce

- community.general.yarn:
    name: "{{ item.name }}"
    global: true
    state: latest
  with_items:
    - { name: "node-gyp" }

Expected Results

I expected node-gyp to be installed or upgraded via yarn global.

Actual Results

failed: [localhost] (item={'name': 'node-gyp'}) =>
    ansible_loop_var: item
    changed: false
    item:
        name: node-gyp
    msg: |-
        {"type":"error","data":"Invalid subcommand. Try \"add, bin, dir, ls, list, remove, upgrade, upgrade-interactive\""}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug language module module packaging plugins plugin (any type) labels Dec 19, 2022
@sargunv
Copy link
Contributor Author

sargunv commented Dec 19, 2022

Upon investigation, it appears that the issue is because yarn global outdated is not a valid command, as called here. The fix would be to perform the equivalent of cd $(yarn global dir); yarn outdated instead.

Might make sense to update the below code to set the working directory of the executed command instead of adding global to the args.

if self.globally:
# Yarn global arg is inserted before the command (e.g. `yarn global {some-command}`)
args.insert(0, 'global')

@sargunv sargunv changed the title community.general.yarn module fails when provided state:latest community.general.yarn module fails when provided state:latest and global:true Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug language module module packaging plugins plugin (any type)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants