blob: dd9be2beed7a089555823c3c9078e8d2eef8f7b3 [file] [log] [blame]
David K. Bainbridgeca68f062016-10-27 11:04:33 -07001---
2- name: Ensure Local Repository Settings
3 become: yes
4 template:
5 backup: yes
6 dest: /etc/apt/sources.list
David K. Bainbridgedbf9f692016-11-04 11:51:32 +01007 src: sources.list.j2
David K. Bainbridgeca68f062016-10-27 11:04:33 -07008 group: root
9 owner: root
10 mode: 0644
11 when: ubuntu_apt_repo is defined
12
13- name: Capture Existing Respositories
14 command: find /etc/apt/sources.list.d \! -type d -name '*.list'
15 changed_when: false
16 register: existing_repo_lists
17 when: ubuntu_apt_repo is defined
18
19- name: Capture Timestamp
20 set_fact:
21 timestamp: "{{ lookup('pipe', 'date +%Y-%m-%d@%H:%M:%S') }}"
22 changed_when: false
23 when: ubuntu_apt_repo is defined
24
David K. Bainbridgedbf9f692016-11-04 11:51:32 +010025- name: Backup Existing Respositories
26 become: yes
27 copy:
28 remote_src: True
29 src: "{{ item }}"
30 dest: "{{ item }}.{{ timestamp }}~"
31 with_items: "{{ existing_repo_lists['stdout_lines'] | default([]) }}"
32 when: ubuntu_apt_repo is defined
David K. Bainbridgeca68f062016-10-27 11:04:33 -070033
David K. Bainbridgedbf9f692016-11-04 11:51:32 +010034- name: Remove Existing Repositories
35 become: yes
36 file:
37 state: absent
38 path: "{{ item }}"
39 with_items: "{{ existing_repo_lists['stdout_lines'] | default([]) }}"
40 when: ubuntu_apt_repo is defined
David K. Bainbridgeca68f062016-10-27 11:04:33 -070041
David K. Bainbridgedbf9f692016-11-04 11:51:32 +010042- name: Ensure Update Repository List
43 become: yes
44 apt:
45 update_cache: yes
46 when: ubuntu_apt_repo is defined