Ansible error: The tasks/main.yml file for role ‘common’ must contain a list of tasks

ansibleyaml

I inherited this ansible git from my predecessor. I can't get it to work though and I guess it's something basic that I'm missing. It keeps giving me this lovely error: ERROR! The tasks/main.yml file for role 'common' must contain a list of tasks

Ansible then proceeds to point to the very first char of the first line of my common/tasks/main.yml (By the way I have env vars to point to the right Ansible dir and the config, no idea if this be a cause)

ERROR! The tasks/main.yml file for role 'common' must contain a list of tasks

The error appears to have been in 
'/root/git/Ansible/playbooks/roles/common/tasks/main.yml': line 1, column 1, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Installing Samba and etc...
^ here

Structure:

+-Vault
+-playbooks/
  --basic.yml
  +-roles/
    +-common/
      +-handlers/main.yml
      +-tasks/main.yml
      +-templates/
        --krb5.conf.jinja2
        --realmd.conf.jinja2
        --smb.conf.jinja2
        --sssd.conf.jinja2
    +-join/tasks/main.yml
    +-prereq/tasks/main.yml

I guess that the important files are playbooks/basic.yml and playbooks/roles/common/tasks/main.yml

playbooks/basic.yml

-  name: Install basic AD stuff
   hosts: all
   become: yes
   become_user: root
   gather_facts: no   
   vars_prompt:
      - name: "ad_admin_name"
        prompt: "username for AD join"
        private: no
      - name: "ad_admin_password"
        prompt: "password for AD"
        private: yes
        confirm: yes
   roles:
     - prereq
     - common
     - join
   #The End

playbooks/roles/common/tasks/main.yml

---
- name: Installing Samba and etc...
  apt: 
     name: "{{ packages }}"
     state: present
  vars:
     packages:
        - adcli
        - libnss-sss
        - libpam-sss
        - libwbclient-sssd
        - realmd
        - sssd
        - sssd-tools
        - samba
        - krb5-config
        - krb5-user
        - winbind
        - libpam-winbind
        - libnss-winbind
        - cifs-utils
- name: "template krb5.conf"
  template:
    src: "krb5.conf.jinja2"
    dest: "/etc/krb5.conf"
    owner: "root"
    group: "root"
    mode: "0644"
    backup: yes
- name: "template realmd.conf"
  template:
    src: "realmd.conf.jinja2"
    dest: "/etc/realmd.conf"
    owner: "root"
    group: "root"
    mode: "0644"
    backup: yes
- name: "template sssd.conf"
  template:
    src: "sssd.conf.jinja2"
    dest: "/etc/sssd/sssd.conf"
    owner: "root"
    group: "root"
    mode: "0600"
    backup: yes
  notify: "sssd needs restart"
- name: "template smb.conf"
  template:
    src: "smb.conf.jinja2"
    dest: "/etc/samba/smb.conf"
    owner: "root"
    group: "root"
    mode: "0644"
    backup: yes

Best Answer

Syntax of roles/common/tasks/main.yml is OK. You can try

# ansible-lint roles/common/tasks/main.yml

Test the playbook

# ansible-lint basic.yml

To be sure I'd recommend to remove the sequence of 3 dots "..." from the name of the task.

- name: Installing Samba and etc
  apt: 

Quoting from YAML Basics

YAML files can optionally begin with --- and end with ... . This is part of the YAML format and indicates the start and end of a document.