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

"command: yum clean all" warns and recommends using "warn: false" which generates an error #70746

Closed
justme3 opened this issue Jul 20, 2020 · 5 comments
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. commands Commands category module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@justme3
Copy link

justme3 commented Jul 20, 2020

SUMMARY

When executing "command: yum clean all" Ansible generates an warning stating that the warning can be removed by using "warn: false" in the stanza. Another solution is to remove all warning by updating ansible.cfg.

When I add "warn: false" to the stanza I get the following error:

ERROR! unexpected parameter type in action: <type 'bool'>

The error appears to be in '/<path>/ansible/roles/install_test/tasks/main.yml': line 12, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Clean up the yum cache
  ^ here

The code that is being operated on is:

name: Clean up the yum cache
  command: /bin/yum clean all
  become_user: root
  become: yes
  become_flags: '-i'
  warn: false
ISSUE TYPE
  • Bug Report
COMPONENT NAME

command

ANSIBLE VERSION

2.9.9

CONFIGURATION

""

No output from command

OS / ENVIRONMENT

Ansible running on RHEL 7.8.

Client is also RHEL 7.8

STEPS TO REPRODUCE

Use stanza to perform a "yum clean all" and examine the warning that is generated.

[WARNING]: Consider using the yum module rather than running 'yum'.  If you need to use command because
yum is insufficient you can add 'warn: false' to this command task or set 'command_warnings=False' in
ansible.cfg to get rid of this message.

Then implement "warn: false" in the stanza and see that it errors out immediately

  command: /bin/yum clean all
  become_user: root
  become: yes
  become_flags: '-i'
  warn: false
EXPECTED RESULTS

I would expect that the warning would be suppressed

ACTUAL RESULTS

An immediate error before running any actions. This appears to be a linting error

ERROR! unexpected parameter type in action: <type 'bool'>

The error appears to be in '/h/1142352/keystone/scm/ansible/roles/install_test/tasks/main.yml': line 12, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Clean up the yum cache
  ^ here

@ansibot
Copy link
Contributor

ansibot commented Jul 20, 2020

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

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. commands Commands category module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jul 20, 2020
@rukman7
Copy link
Contributor

rukman7 commented Jul 20, 2020

@justme3 the warning flag is a part of the command module. Try like this:

  command: /bin/yum clean all 
  args:
    warn: false 
  become_user: root
  become: yes
  become_flags: '-i' 

Documentation: https://docs.ansible.com/ansible/latest/modules/command_module.html

@justme3
Copy link
Author

justme3 commented Jul 21, 2020

@rukman7 Many thanks. Putting the warn line in as an arg works.
The Ansible documentation page for command does not distinguish between parameters to a module or args.
https://docs.ansible.com/ansible/latest/modules/command_module.html
Is there any way I can avoid this mistake in the future?

@rukman7
Copy link
Contributor

rukman7 commented Jul 21, 2020

@justme3 As the documentation says:

  1. The command module takes the command name followed by a list of space-delimited arguments.
    if you do like like the following, you need args.
  2. To create command tasks that are easier to read than the ones using space-delimited arguments, pass parameters using the args task keyword or use cmd parameter.
  command: /bin/yum clean all 
  args:
    warn: false 
  become_user: root
  become: yes
  become_flags: '-i' 

if you do like this, you don't need args.

  command: 
    cmd: /bin/yum clean all
    warn: false 
  become_user: root
  become: yes
  become_flags: '-i' 

please correct me if I am wrong.

@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Jul 21, 2020
@relrod
Copy link
Member

relrod commented Jul 21, 2020

Fixed by the fact that we're deprecating the command warning feature entirely in 2.11+, #70504, and removing it in 2.14.

@relrod relrod closed this as completed Jul 21, 2020
@ansible ansible locked and limited conversation to collaborators Aug 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. commands Commands category module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

5 participants