- name: "apt-key add {{ item.key }} (key url)" apt_key: id: "{{ item.value.key_id }}" url: "{{ item.value.key_url }}" state: "{{ state }}" when: item.value.key_url is defined and item.value.key_id is defined - name: "apt-key add {{ item.key }} (keyserver)" apt_key: id: "{{ item.value.key_id }}" keyserver: "{{ item.value.keyserver }}" state: "{{ state }}" when: item.value.keyserver is defined and item.value.key_id is defined - name: "add repo {{ item.key }}" when: item.value.url is defined and state == "present" vars: filename: "{{ item.filename | default(item.key) }}" # filename: "{{ item.filename if item.filename is defined else item.key }}" copy: dest: "/etc/apt/sources.list.d/{{ item.key }}.list" content: | deb {{ item.value.url }} {{ item.value.distro }} {{ item.value.sections }} notify: apt update - name: "remove repo {{ item.key }}" when: state == "absent" file: path: "/etc/apt/sources.list.d/{{ item.key }}.list" state: absent notify: apt update