Ubuntu – Beginner: Ansible The offending line appears to be

ansibleUbuntu

I'm learning how to use ansible and am writing a playbook for my local desktop.
I'm using the atom editor and have linter installed. I'm not getting any error whilst writing, but then when I execute the playbook I get the error "The offending line appears to be"

    Here's my current Playbook:


---
- hosts: localhost
  tasks:

        - name: Install .deb packages from the internet.
          apt:
          deb:
          - https://packagecloud.io/AtomEditor/atom/any/
          - https://updates.signal.org/desktop/apt
          - http://ppa.launchpad.net/webupd8team/brackets/ubuntu
          - http://ppa.launchpad.net/nextcloud-devs/client/ubuntu
          - http://repository.spotify.com stable non-free
          - http://download.xnview.com/XnConvert-linux-x64.deb
          - https://updates.signal.org/desktop/apt xenial main




        - name: Install a list of packages
          update_cache: yes
          apt:
            pkg:
            - AtomEditor
            - brackets
            - calibre
            - chromium-browser
            - filezilla
            - firefox-locale-de
            - gimp
            - gparted
            - gscan2pdf
            - gstreamer1.0-pulseaudio
            - keepassxc
            - nextcloud-client
            - nextcloud-client-nautilus
            - pdfshuffler
            - python-nautilus
            - spotify
            - tipp10
            - vlc
            - XnConvert



        - name: no tracking
          become: true
          vars:
            packages_absent:
              - apport
              - gnome-intial-setup
              - ubuntu-web-launchers


        - name: Remove useless packages from the cache
          apt:
          autoclean: yes


        - name: Remove dependencies that are no longer required
          apt:
          autoremove: yes

Then my terminal tells me:

The offending line appears to be:

  tasks:
    - name: no tracking
      ^ here

I know it's a beginners question and probably there are many more problems in my playbook. But I'm happy for any help.

Best Answer

Pay attention to indentation for parameters:

Looks like the deb: parameter (and the rest of its section) needs greater indentation. Thus instead of,

    - name: Install .deb packages from the internet.
      apt:
      deb:
      - https://packagecloud.io/AtomEditor/atom/any/
      - ...

add some indentation to deb: to make it a parameter,

    - name: Install .deb packages from the internet.
      apt:
        deb:
        - https://packagecloud.io/AtomEditor/atom/any/
        - ...

Without indentation Ansible won't understand deb: to be a parameter of the apt: module; rather it will try to make sense of it as a directive affecting how apt: is used (so like notify:, become:, ignore_errors: etc)

the same for update_cache: so instead of,

    - name: Install a list of packages
      update_cache: yes
      apt:
        pkg:
        - AtomEditor
        - ...

move update_cache: within apt: and indent it,

    - name: Install a list of packages
      apt:
        update_cache: yes
        pkg:
        - AtomEditor
        - ...

similarly,

    - name: Remove useless packages from the cache
      apt:
        autoclean: yes

and finally I don't understand what you're trying to do with the 'no tracking' part; I'm not aware of a vars: module. Maybe you want to remove those packages if present, in which case see the documentation for the apt: module, esp. the 'Remove "foo" package' example.