Fix ansible scripts for running in container
[yardstick.git] / ansible / roles / add_repos_jumphost / tasks / Debian.yml
1 # Copyright (c) 2018 Intel Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 ---
15 # Arguments needed: arch_arm64, arch_amd64, ubuntu_archive
16
17 - name: Set the repositories architecture name
18   set_fact:
19     arch: "{{ arch_arm64 if ansible_architecture == 'aarch64' else arch_amd64 }}"
20     extra_arch: "{{ arch_amd64 if ansible_architecture == 'aarch64' else arch_arm64 }}"
21
22 - name: Define the repositories names
23   set_fact:
24     repo: "{{ ubuntu_archive[arch] }}"
25     extra_repo: "{{ ubuntu_archive[extra_arch] }}"
26
27 - name: Add architecture to the default repository list
28   replace:
29     path: "{{ sources_list_file }}"
30     regexp: '(^deb\s+)([^\[].*)$'
31     replace: 'deb [arch={{ arch }}] \2'
32
33 - name: Remove support for source repositories
34   replace:
35     path: "{{ sources_list_file }}"
36     regexp: "^deb-src "
37     replace: "# deb-src "
38
39 - name: Add extra architecture
40   command: "dpkg --add-architecture {{ extra_arch }}"
41
42 - name: Define the default release version
43   copy:
44     dest: "{{ default_distro_file }}"
45     content: 'APT::Default-Release "{{ ansible_distribution_release }}";'
46
47 - name: Remove extra repository file
48   file:
49     path: "{{ repo_file }}"
50     state: absent
51   ignore_errors: yes
52
53 - name: Add extra repository file
54   file:
55     path: "{{ repo_file }}"
56     state: touch
57
58 - name: Add the repository for qemu_static_user/xenial
59   blockinfile:
60     path: "{{ repo_file }}"
61     marker: "MARKER"
62     content: |
63       deb [arch={{ arch }}] {{ repo }} xenial-updates universe
64   when: ansible_distribution_release != "xenial"
65
66 - name: Add extra architecture repositories if installing in container
67   blockinfile:
68     path: "{{ repo_file }}"
69     marker: "MARKER"
70     content: |
71       deb [arch={{ extra_arch }}] {{ extra_repo }} {{ ansible_distribution_release }} main universe multiverse restricted
72       deb [arch={{ extra_arch }}] {{ extra_repo }} {{ ansible_distribution_release }}-updates main universe multiverse restricted
73       deb [arch={{ extra_arch }}] {{ extra_repo }} {{ ansible_distribution_release }}-security main universe multiverse restricted
74       deb [arch={{ extra_arch }}] {{ extra_repo }} {{ ansible_distribution_release }}-proposed main universe multiverse restricted
75   when: installation_mode == "container"
76
77 - name: Remove the marker
78   lineinfile:
79     dest: "{{ repo_file }}"
80     state: absent
81     regexp: "MARKER"