summaryrefslogtreecommitdiffstats
path: root/playbooks/roles/pre-install/tasks/main.yml
blob: ba3e1c08026f0bd8f549fd0e99dfa2e42a06bb6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2020 Samsung Electronics
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

- name: Ensure Python3 is installed for CentOS (Equinix Metal)
  raw: yum install -y python3
  ignore_errors: true
  failed_when: false
  when: lookup('env', 'VENDOR') == 'equinix-metal'

- name: Gather facts
  setup:

- name: Load distro variables
  include_vars:
    file: "{{ ansible_os_family }}.yml"

- name: Update cache (RedHat)
  yum:
    update_cache: yes
  when: ansible_os_family == "RedHat"

- name: Update cache (Debian)
  apt:
    update_cache: yes
  when: ansible_os_family == "Debian"

- name: Install BRMA requirements
  become: true
  package:
    name: "{{ item }}"
    state: present
  with_items: "{{ bmra_pkgs }}"

- name: Check if Python is present in PATH
  shell: "which python"
  register: pypath
  failed_when: false

- name: Check if /usr/bin/python exists
  stat:
    path: /usr/bin/python
  register: pybin

- name: Create symlink for Python
  file:
    src: /usr/bin/python3
    dest: /usr/bin/python
    state: link
  when:
    - not pybin.stat.exists
    - pypath.rc != 0

- name: Fix /etc/default/grub (1/2)
  replace:
    path: /etc/default/grub
    regexp: ''''
    replace: '"'

- name: Fix /etc/default/grub (2/2)
  replace:
    path: /etc/default/grub
    regexp: 'export '
    replace: ''