Jonathan Hart | 93956f5 | 2017-08-22 13:12:42 -0700 | [diff] [blame] | 1 | |
| 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. Bainbridge | ca68f06 | 2016-10-27 11:04:33 -0700 | [diff] [blame] | 17 | --- |
| 18 | - name: Ensure Local Repository Settings |
| 19 | become: yes |
| 20 | template: |
| 21 | backup: yes |
| 22 | dest: /etc/apt/sources.list |
David K. Bainbridge | dbf9f69 | 2016-11-04 11:51:32 +0100 | [diff] [blame] | 23 | src: sources.list.j2 |
David K. Bainbridge | ca68f06 | 2016-10-27 11:04:33 -0700 | [diff] [blame] | 24 | group: root |
| 25 | owner: root |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 26 | mode: "0644" |
David K. Bainbridge | ca68f06 | 2016-10-27 11:04:33 -0700 | [diff] [blame] | 27 | 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. Bainbridge | dbf9f69 | 2016-11-04 11:51:32 +0100 | [diff] [blame] | 41 | - 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. Bainbridge | ca68f06 | 2016-10-27 11:04:33 -0700 | [diff] [blame] | 49 | |
David K. Bainbridge | dbf9f69 | 2016-11-04 11:51:32 +0100 | [diff] [blame] | 50 | - 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. Bainbridge | ca68f06 | 2016-10-27 11:04:33 -0700 | [diff] [blame] | 57 | |
David K. Bainbridge | dbf9f69 | 2016-11-04 11:51:32 +0100 | [diff] [blame] | 58 | - name: Ensure Update Repository List |
| 59 | become: yes |
| 60 | apt: |
| 61 | update_cache: yes |
| 62 | when: ubuntu_apt_repo is defined |