0
votes

I'm getting this below error while running my ansible playbook

my yaml file :

---
- hosts: ubuntu
  become: yes
  remote_user: ansible
  tasks:
  - name: update the cache
    apt:
      name: update
      update_cache: yes
  - name: This will install apache
    apt:
     name:apache2
     state:present

Error: exception type: exception: this task 'apt' has extra params, which is only allowed in the following modules: command, win_command, shell, win_shell, script, include, include_vars, include_tasks, include_role, import_tasks, import_role, add_host, group_by, set_fact, raw, meta

The error appears to have been in '/home/ansible/playbooks/apache.yml': line 10, column 5, but may be elsewhere in the file depending on the exact syntax problem.

1
If you don't properly format your question the code you're asking about becomes almost unreadable. I've fixed the playbook for you. - larsks

1 Answers

0
votes

You have an error in your YAML syntax. The syntax for a dictionary is:

key: value

Note the space after the :. You have:

- name: This will install apache
  apt:
   name:apache2
   state:present

You need:

- name: This will install apache
  apt:
   name: apache2
   state: present