通过Ansible获取yum更新列表失败

时间:2019-03-19 11:13:12

标签: linux ansible yum

- hosts: all
  gather_facts: false
  become: yes
  user: username

  tasks:
  - name: List Available Patches (Non-Kernel)
    yum:
     list: updates
     update_cache: true
     exclude: kernel*
     register: yumoutput

  - debug: msg="{{ inventory_hostname}} {{ yumoutput.results }}"

味精:

Unsupported parameters for (yum) module: register Supported parameters 
include: allow_downgrade, bugfix, conf_file, disable_gpg_check, 
disable_plugin, disablerepo, enable_plugin, enablerepo, exclude, 
install_repoquery, installroot, list, name, security, skip_broken, state, 
update_cache, update_only, validate_certs

to retry, use:
ansible --version
ansible 2.6.5

2.7.5版本相同。

1 个答案:

答案 0 :(得分:0)

这似乎是缩进错误。 register必须与yum放在同一列。

- hosts: all
  gather_facts: false
  become: yes
  user: username

  tasks:
  - name: List Available Patches (Non-Kernel)
    yum:
      list: updates
      update_cache: true
      exclude: kernel*
    register: yumoutput

  - debug: msg="{{ inventory_hostname}} {{ yumoutput.results }}"