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

4
5
6
7
8

- 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
9
  when: ansible_os_family == "RedHat"
10
  
11
12
13
14
15
16
- name: test for existing installation of drivers
  command: ibv_devinfo
  sudo: true
  register: drivers_installed
  ignore_errors: true

17
18
19
- name: yum update to upgrade kernel
  shell: "yum update -y"
  sudo: true
20
  ignore_errors: true
21
  when: ansible_os_family == "RedHat" and  drivers_installed|failed
22
23
24
25
  
#
# A REBOOT IS NEEDED AFTER a KERNEL UPDATE
#
26
- name: restart machine
27
28
  shell: sleep 5; sudo shutdown -r now "Ansible updates triggered"
  async: 2
29
30
  poll: 0
  ignore_errors: true
31
  sudo: true
32
  when: ansible_os_family == "RedHat" and  drivers_installed|failed
33
34

- name: waiting for server to come back
35
36
37
38
39
  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
40
41
42
43
  sudo: false


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

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

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

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

73
74
75
76
77
78
79
80
#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
81
82
  when: ansible_os_family=="Debian" and  drivers_installed|failed

83
84
85
86
87
88
89
90
- 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
91
  when: ansible_os_family=="Debian" and  drivers_installed|failed
92
93
94
95
96
97
98
99
- 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
100
  when: ansible_os_family=="Debian" and  drivers_installed|failed
101
#
102
103
104
# A REBOOT IS NEEDED AFTER SUCCESSFUL INSTALL
#
- name: restart machine
105
  command: "sleep 5; sudo shutdown -r now"
106
107
108
109
  async: 2
  poll: 0
  ignore_errors: true
  sudo: true
110
  when: ansible_os_family=="Centos" and  drivers_installed|failed
111
112

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

- 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 2
  local_action: wait_for host={{ ansible_ssh_host }} state=started port=22 delay=10 search_regex=OpenSSH
126
127

- name: bring up interface
128
129
  #variable=eth0 or ens6
  command: ifup {{ MELLANOX_DEVICE_NAME }} 
130
131
132
133
  sudo: true
  when: ansible_distribution_major_version == "7"