main.yml 4.02 KB
Newer Older
1
---
2
3
- include_vars: mellanoxVars.yml

4
5
6
7
- name: yum install dependencies
  yum:  name=perl,pciutils,gtk2,atk,cairo,gcc-gfortran,libxml2-python,tcsh,libnl,lsof,tcl,tk
  sudo: true
  ignore_errors: true
8
  when: ansible_os_family == "RedHat"
9
  
10
11
12
13
14
15
- name: test for existing installation of drivers
  command: ibv_devinfo
  sudo: true
  register: drivers_installed
  ignore_errors: true

16
17
18
19
20
21
22

# This is NASTY. Don't upgrade production systems without taking them out of the queue first.
#- name: yum update to upgrade kernel
#  shell: "yum update -y"
#  sudo: true
#  ignore_errors: true
#  when: ansible_os_family == "RedHat" and  drivers_installed|failed
23
24
25
26
  
#
# A REBOOT IS NEEDED AFTER a KERNEL UPDATE
#
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#- name: restart machine
#  shell: sleep 5; sudo shutdown -r now "Ansible updates triggered"
#  async: 2
#  poll: 0
#  ignore_errors: true
#  sudo: true
#  when: ansible_os_family == "RedHat" and  drivers_installed|failed
#
#- name: waiting for server to come back
#  local_action: wait_for host={{ ansible_ssh_host }} state=started port=22 delay=10 search_regex=OpenSSH
#  sudo: false
#
#- name: waiting for server to come back number 2
#  local_action: wait_for host={{ ansible_ssh_host }} state=started port=22 delay=10 search_regex=OpenSSH
#  sudo: false
42
43
44


- name: copy driver source
45
46
  #make this a variable
  unarchive: copy=yes src="files/{{ MELLANOX_DRIVER_SRC }}.tgz" dest=/tmp 
47
  sudo: true
48
49
  #when: drivers_installed|failed and ansible_os_family=="RedHat" and ansible_distribution_major_version == "7"
  when: drivers_installed|failed 
50
51

- name: install drivers
52
  shell: ./mlnxofedinstall -q
53
  args:
54
55
    #more changes
    chdir: "/tmp/{{ MELLANOX_DRIVER_SRC }}"
56
  sudo: true
57
  when: drivers_installed|failed 
58

59
#
60
61
62
63
64
65
# get IP address before reboot
#
- name: get IP address
  local_action: command ./scripts/map_ib_ip.pl {{ inventory_hostname }}
  register: ip_address
  sudo: false
66
  #when: drivers_installed|failed
67
68
69
70
71

  
- name: template IP address
  template: dest=/etc/sysconfig/network-scripts/ifcfg-ens6 src=ifcfg-ens6.j2 owner=root group=root
  sudo: true
72
73
  when:  ansible_os_family=="RedHat" and  ansible_distribution_major_version == "7" and  drivers_installed|failed

74
75
76
77
78
79
80
81
#ubuntu equivalent of previous command
- name: Ubuntu network interfaces - line 1
  lineinfile:
  args: 
      dest: /etc/network/interfaces
      line: auto {{ MELLANOX_DEVICE_NAME }}
      state: present
  sudo: true
82
83
  when: ansible_os_family=="Debian" and  drivers_installed|failed

84
85
86
87
88
89
90
91
- name: Ubuntu network interfaces - line 2
  lineinfile:
  args: 
      dest: /etc/network/interfaces
      line: iface {{ MELLANOX_DEVICE_NAME }} inet static
      state: present
      insertafter: "auto {{ MELLANOX_DEVICE_NAME }}"
  sudo: true
92
  when: ansible_os_family=="Debian" and  drivers_installed|failed
93

94
95
96
97
98
99
100
101
- name: Ubuntu network interfaces - line 3
  lineinfile:
  args: 
      dest: /etc/network/interfaces
      line: address {{ ip_address.stdout }}
      state: present
      insertafter: "iface {{ MELLANOX_DEVICE_NAME }} inet static"
  sudo: true
102
  when: ansible_os_family=="Debian" and  drivers_installed|failed
103
#
104
105
106
# A REBOOT IS NEEDED AFTER SUCCESSFUL INSTALL
#
- name: restart machine
107
  shell: "sleep 5; sudo shutdown -r now"
108
  async: 2
109
  poll: 1
110
111
  ignore_errors: true
  sudo: true
112
  when: ansible_os_family=="RedHat" and  drivers_installed|failed
113
114

- name: restart machine for Ubuntu -cos it is 'special'
115
  shell: "sleep 5; sudo shutdown -r now"
116
  async: 2
117
  poll: 1
118
119
  ignore_errors: true
  sudo: true
120
  when: ansible_os_family=="Debian" and  drivers_installed|failed
121
122
123
124

- name: waiting for server to come back
  local_action: wait_for host={{ ansible_ssh_host }} state=started port=22 delay=10 search_regex=OpenSSH
  sudo: false
125
  when: drivers_installed|failed
126
127
128

- name: waiting for server to come back 2
  local_action: wait_for host={{ ansible_ssh_host }} state=started port=22 delay=10 search_regex=OpenSSH
129
  when: drivers_installed|failed
130
131

- name: bring up interface
132
133
  #variable=eth0 or ens6
  command: ifup {{ MELLANOX_DEVICE_NAME }} 
134
  sudo: true
135
  when: ansible_os_family=="RedHat" and ansible_distribution_major_version == "7"
136
137