Ansible试用循环-apache2、sqlite3、git安装

Ansible试用循环-apache2、sqlite3、git安装,ansible,Ansible,以下错误: --- - name: install apache2, sqlite3, git hosts: localhost become: yes tasks: - name: Install list of packages action: apt pkg={{item}} state=installed with_items: - apache2 - sqlite3 - git user@wo

以下错误:

---
- name: install apache2, sqlite3, git
  hosts: localhost
  become: yes
  tasks:
    - name: Install list of packages
      action: apt pkg={{item}} state=installed
      with_items:
        - apache2
        - sqlite3
        - git
user@workspacexhnc27ngrq5uvvr3:/projects/challenge$ansible playbook mainplaybook.yml
错误!作用中的意外参数类型:
错误出现在“/projects/challenge/fresco_loops/tasks/main.yml”中:第2行第3列,但可能是
根据确切的语法问题,在文件中的其他位置。
令人不快的一行似乎是:
---
-名称:安装apache2、sqlite3、git
^这里
user@workspacexhnc27ngrq5uvvr3:/projects/challenge$ansible playbook mainplaybook.yml
错误!作用中的意外参数类型:
错误出现在“/projects/challenge/fresco_loops/tasks/main.yml”中:第2行第3列,但可能是
根据确切的语法问题,在文件中的其他位置。
令人不快的一行似乎是:
---
-名称:安装apache2、sqlite3、git
^这里

使用apt模块而不是操作。只需确保您的Ansibe用户有权在目标系统上安装apt软件包

user@workspacexhnc27ngrq5uvvr3:/projects/challenge$ ansible-playbook mainplaybook.yml 
ERROR! unexpected parameter type in action: <class 'ansible.parsing.yaml.objects.AnsibleSequence'>

The error appears to be in '/projects/challenge/fresco_loops/tasks/main.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---
- name: install apache2, sqlite3, git
  ^ here
user@workspacexhnc27ngrq5uvvr3:/projects/challenge$ ansible-playbook mainplaybook.yml 
ERROR! unexpected parameter type in action: <class 'ansible.parsing.yaml.objects.AnsibleSequence'>

The error appears to be in '/projects/challenge/fresco_loops/tasks/main.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---
- name: install apache2, sqlite3, git
  ^ here

看起来您可能正在使用一些过时的文档(剧本不再使用
操作
关键字)。也许从你的文档开始?
---
- name: install apache2, sqlite3, git
  hosts: localhost
  become: yes
  tasks:
    - name: Install list of packages
      apt: 
        name: "{{item}}" 
        state: present
      with_items:
        - apache2
        - sqlite3
        - git