blob: 394e4470d6acebed51cbff37c5c36a0b7b26d6a0 [file] [log] [blame]
Jonathan Hart93956f52017-08-22 13:12:42 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
David K. Bainbridgeca68f062016-10-27 11:04:33 -070017---
18- name: Ensure Local Repository Settings
19 become: yes
20 template:
21 backup: yes
22 dest: /etc/apt/sources.list
David K. Bainbridgedbf9f692016-11-04 11:51:32 +010023 src: sources.list.j2
David K. Bainbridgeca68f062016-10-27 11:04:33 -070024 group: root
25 owner: root
David K. Bainbridge8b179042016-11-30 15:38:42 -080026 mode: "0644"
David K. Bainbridgeca68f062016-10-27 11:04:33 -070027 when: ubuntu_apt_repo is defined
28
29- name: Capture Existing Respositories
30 command: find /etc/apt/sources.list.d \! -type d -name '*.list'
31 changed_when: false
32 register: existing_repo_lists
33 when: ubuntu_apt_repo is defined
34
35- name: Capture Timestamp
36 set_fact:
37 timestamp: "{{ lookup('pipe', 'date +%Y-%m-%d@%H:%M:%S') }}"
38 changed_when: false
39 when: ubuntu_apt_repo is defined
40
David K. Bainbridgedbf9f692016-11-04 11:51:32 +010041- name: Backup Existing Respositories
42 become: yes
43 copy:
44 remote_src: True
45 src: "{{ item }}"
46 dest: "{{ item }}.{{ timestamp }}~"
47 with_items: "{{ existing_repo_lists['stdout_lines'] | default([]) }}"
48 when: ubuntu_apt_repo is defined
David K. Bainbridgeca68f062016-10-27 11:04:33 -070049
David K. Bainbridgedbf9f692016-11-04 11:51:32 +010050- name: Remove Existing Repositories
51 become: yes
52 file:
53 state: absent
54 path: "{{ item }}"
55 with_items: "{{ existing_repo_lists['stdout_lines'] | default([]) }}"
56 when: ubuntu_apt_repo is defined
David K. Bainbridgeca68f062016-10-27 11:04:33 -070057
David K. Bainbridgedbf9f692016-11-04 11:51:32 +010058- name: Ensure Update Repository List
59 become: yes
60 apt:
61 update_cache: yes
62 when: ubuntu_apt_repo is defined