| - name: Ensure Local Repository Settings |
| dest: /etc/apt/sources.list |
| when: ubuntu_apt_repo is defined |
| - name: Capture Existing Respositories |
| command: find /etc/apt/sources.list.d \! -type d -name '*.list' |
| register: existing_repo_lists |
| when: ubuntu_apt_repo is defined |
| - name: Capture Timestamp |
| timestamp: "{{ lookup('pipe', 'date +%Y-%m-%d@%H:%M:%S') }}" |
| when: ubuntu_apt_repo is defined |
| - name: Backup Existing Respositories |
| dest: "{{ item }}.{{ timestamp }}~" |
| with_items: "{{ existing_repo_lists['stdout_lines'] | default([]) }}" |
| when: ubuntu_apt_repo is defined |
| - name: Remove Existing Repositories |
| with_items: "{{ existing_repo_lists['stdout_lines'] | default([]) }}" |
| when: ubuntu_apt_repo is defined |
| - name: Ensure Update Repository List |
| when: ubuntu_apt_repo is defined |