Support Ubuntu 18.04 and 20.04 LTS as target OS
[kuberef.git] / playbooks / roles / pre-install / tasks / main.yml
1 ---
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2020 Samsung Electronics
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 - name: Ensure Python3 is installed for CentOS (Equinix Metal)
12   raw: yum install -y python3
13   ignore_errors: true
14   failed_when: false
15   when: lookup('env', 'VENDOR') == 'equinix-metal'
16
17 - name: Gather facts
18   setup:
19
20 - name: Load distro variables
21   include_vars:
22     file: "{{ ansible_os_family }}.yml"
23
24 - name: Update cache (RedHat)
25   yum:
26     update_cache: yes
27   when: ansible_os_family == "RedHat"
28
29 - name: Update cache (Debian)
30   apt:
31     update_cache: yes
32   when: ansible_os_family == "Debian"
33
34 - name: Install BRMA requirements
35   become: true
36   package:
37     name: "{{ item }}"
38     state: present
39   with_items: "{{ bmra_pkgs }}"
40
41 - name: Check if Python is present in PATH
42   shell: "which python"
43   register: pypath
44   failed_when: false
45
46 - name: Check if /usr/bin/python exists
47   stat:
48     path: /usr/bin/python
49   register: pybin
50
51 - name: Create symlink for Python
52   file:
53     src: /usr/bin/python3
54     dest: /usr/bin/python
55     state: link
56   when:
57     - not pybin.stat.exists
58     - pypath.rc != 0
59
60 - name: Fix /etc/default/grub (1/2)
61   replace:
62     path: /etc/default/grub
63     regexp: ''''
64     replace: '"'
65
66 - name: Fix /etc/default/grub (2/2)
67   replace:
68     path: /etc/default/grub
69     regexp: 'export '
70     replace: ''