---
- name: Install crawler apt package dependencies.
  become: yes
  apt:
    name: "{{ item }}"
    state: latest
  with_items: "{{ crawler_apt_packages }}"

- name: Download universe sources for tor.
  become: yes
  lineinfile:
    dest: /etc/apt/sources.list
    line: "deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe"
    regexp: "# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe"

- name: Install Tor build dependencies.
  become: yes
  apt:
    name: tor
    state: build-dep
    update_cache: yes
  # Ansible is always reporting changed for this task, so let's
  # inspect the output to determine changed status.
  register: tor_build_dep_result
  changed_when: "'0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' not in tor_build_dep_result.stdout_lines"

---
- name: Install crawler apt package dependencies.
  become: yes
  apt:
    name: "{{ item }}"
    state: latest
  with_items: "{{ crawler_apt_packages }}"

- name: Download universe sources for tor.
  become: yes
  apt_repository:
    filename: "xenial-universe-sources"
    repo: "deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe"
    mode: "0644"

- name: Install Tor build dependencies.
  become: yes
  apt:
    name: tor
    state: build-dep
    update_cache: yes
  # Ansible is always reporting changed for this task, so let's
  # inspect the output to determine changed status.
  register: tor_build_dep_result
  changed_when: "'0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' not in tor_build_dep_result.stdout_lines"

Use apt_repository, not lineinfile, to handle apt sources
Use apt_repository, not lineinfile, to handle apt sources
