错误!这个任务'apt_repository'有额外的参数

时间:2016-04-30 12:19:57

标签: ansible ansible-playbook ansible-2.x

我第一次尝试使用Ansible。当我试图运行剧本时,我收到了这个错误:

ERROR! this task 'apt_repository' has extra params, which is only allowed in the following modules: command, shell, script, include, include_vars, add_host, group_by, set_fact, raw, meta

The error appears to have been in '/home/prism/Desktop/ansible/basic_package/main.yml': line 9, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


  - name: "Add Webupd8 ppa for youtube-dl"
    ^ here

main.yml:

---
- hosts: all
  remote_user: root

  tasks:
  - name: "Upgrade the whole system"
    apt: upgrade=dist update_cache=yes

  - name: "Add Webupd8 ppa for youtube-dl"
    apt_repository: repo ='ppa:nilarimogard/webupd8'

  - name: "Install basic package"
    apt: name={{ item }} state=installed
    with_items:
      - libffi-dev
      - vnstat
      - youtube-dl
      - finger
      - htop
      - python3-dev
      - axel
      - curl
      - fail2ban
      - python-dev
      - sendmail
      - git
      - python-software-properties
      - software-properties-common
      - python-pip
      - nethogs
      - unzip
      - nmap

1 个答案:

答案 0 :(得分:6)

apt_repository 任务中,在repo参数之后看起来有一个额外的空格。使用以下代码:

apt_repository: repo='ppa:nilarimogard/webupd8'