main.yml 5.51 KB
Newer Older
Adam Robinson's avatar
Adam Robinson committed
1
2
---
# tasks file for pure_storage_vmware_best_practices
Adam Robinson's avatar
Adam Robinson committed
3
4
5
6
7
8
9
10
11
- name: Get the current state of all services
  vmware_host_service_facts:
    hostname: '{{ vcenter_hostname }}'
    esxi_hostname: '{{ inventory_hostname }}'
    username: '{{ vmware_user }}'
    password: '{{ vmware_password }}'
  delegate_to: localhost
  register: host_service_facts

12
13
14
15
16
17
18
19
20
21
22
23
- name: Start SSH Temporarily
  vmware_host_service_manager:
    hostname: '{{ vcenter_hostname }}'
    esxi_hostname: '{{ inventory_hostname }}'
    username: '{{ vmware_user }}'
    password: '{{ vmware_password }}'
    service_name: TSM-SSH
    state: start
  delegate_to: localhost
  when: not host_service_facts['host_service_facts'][inventory_hostname] | selectattr('key', 'equalto', 'TSM-SSH') | map(attribute='running') | list | first | bool
  notify: Stop SSH

24
- name: DataMover.HardwareAcceleratedInit
Adam Robinson's avatar
Adam Robinson committed
25
26
27
28
29
30
31
  vmware_host_config_manager:
    hostname: '{{ vcenter_hostname }}'
    esxi_hostname: '{{ inventory_hostname }}'
    username: '{{ vmware_user }}'
    password: '{{ vmware_password }}'
    options:
        'DataMover.HardwareAcceleratedInit': 1
32
33
34
35
36
37
38
39
40
  delegate_to: localhost

- name: DataMover.HardwareAcceleratedMove
  vmware_host_config_manager:
    hostname: '{{ vcenter_hostname }}'
    esxi_hostname: '{{ inventory_hostname }}'
    username: '{{ vmware_user }}'
    password: '{{ vmware_password }}'
    options:
Adam Robinson's avatar
Adam Robinson committed
41
        'DataMover.HardwareAcceleratedMove': 1
42
43
44
45
46
47
48
49
50
  delegate_to: localhost

- name: VMFS3.HardwareAcceleratedLocking
  vmware_host_config_manager:
    hostname: '{{ vcenter_hostname }}'
    esxi_hostname: '{{ inventory_hostname }}'
    username: '{{ vmware_user }}'
    password: '{{ vmware_password }}'
    options:
Adam Robinson's avatar
Adam Robinson committed
51
        'VMFS3.HardwareAcceleratedLocking': 1
52
53
54
55
56
57
58
59
60
  delegate_to: localhost

- name: Disk.DiskMaxIOSize
  vmware_host_config_manager:
    hostname: '{{ vcenter_hostname }}'
    esxi_hostname: '{{ inventory_hostname }}'
    username: '{{ vmware_user }}'
    password: '{{ vmware_password }}'
    options:
Adam Robinson's avatar
Adam Robinson committed
61
        'Disk.DiskMaxIOSize': 4096
62
63
64
65
66
67
68
69
70
  delegate_to: localhost

- name: VMFS3.UseATSForHBOnVMFS5
  vmware_host_config_manager:
    hostname: '{{ vcenter_hostname }}'
    esxi_hostname: '{{ inventory_hostname }}'
    username: '{{ vmware_user }}'
    password: '{{ vmware_password }}'
    options:
Adam Robinson's avatar
Adam Robinson committed
71
        'VMFS3.UseATSForHBOnVMFS5': '{{ 0 if Third_Party_Array_Not_Support_ATS_HB|bool else 1 }}'
72
73
  delegate_to: localhost

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
- name: Get value of DataMover.MaxHWTransferSize
  shell: esxcfg-advcfg -g /DataMover/MaxHWTransferSize
  vars:
    ansible_user: '{{ vmware_user }}@{{ ad_domain|upper }}'
    ansible_password: '{{ vmware_password }}'
    ansible_connection: paramiko
    ansible_python_interpreter: /bin/python
  register: MaxHWTransferSizeCMD
  changed_when: False

- name: Set CurrentMaxHWTransferSize fact
  set_fact:
    CurrentMaxHWTransferSize: '{{ MaxHWTransferSizeCMD.stdout | regex_replace(regexp,"\1") }}'
  vars:
    regexp: 'Value of MaxHWTransferSize is (\d*)'

- debug: var=CurrentMaxHWTransferSize

- name: DataMover.MaxHWTransferSize
Adam Robinson's avatar
Adam Robinson committed
93
  shell: esxcfg-advcfg -s {{ MaxHWTransferSize }} /DataMover/MaxHWTransferSize
94
95
96
97
98
99
  vars:
    ansible_user: '{{ vmware_user }}@{{ ad_domain|upper }}'
    ansible_password: '{{ vmware_password }}'
    ansible_connection: paramiko
    ansible_python_interpreter: /bin/python
  when: CurrentMaxHWTransferSize != MaxHWTransferSize
100
101
102
103
104
105
106
107
108

- name: VMFS3.EnableBlockDelete
  vmware_host_config_manager:
    hostname: '{{ vcenter_hostname }}'
    esxi_hostname: '{{ inventory_hostname }}'
    username: '{{ vmware_user }}'
    password: '{{ vmware_password }}'
    options:
        'VMFS3.EnableBlockDelete': 1
Adam Robinson's avatar
Adam Robinson committed
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
  delegate_to: localhost

# vSphere keeps trying to read SMART data from Pure volumes
# https://www.jacobhopkinson.com/2019/08/09/vmware-and-scsi-why-do-my-pure-storage-datastores-report-scsi-0x85-errors-every-30-minutes/
- when: DisableSmartd
  block:
    - name: Get status of smartd
      shell: /etc/init.d/smartd status
      vars:
        ansible_user: '{{ vmware_user }}@{{ ad_domain|upper }}'
        ansible_password: '{{ vmware_password }}'
        ansible_connection: paramiko
        ansible_python_interpreter: /bin/python
      register: SmartdStatusCMD
      failed_when: ( SmartdStatusCMD.rc not in [ 0, 3 ] ) # When smart is stopped the return code is 3
      changed_when: False


    - name: Set SmartdStatus fact
      set_fact:
        SmartdRunning: '{{ true if SmartdStatusCMD.rc == 0 else false }}'

    - name: Stop smartd
      shell: /etc/init.d/smartd stop
      vars:
        ansible_user: '{{ vmware_user }}@{{ ad_domain|upper }}'
        ansible_password: '{{ vmware_password }}'
        ansible_connection: paramiko
        ansible_python_interpreter: /bin/python
      when: SmartdRunning

    - name: Check if smartd is enabled at boot
      shell: chkconfig --list smartd
      vars:
        ansible_user: '{{ vmware_user }}@{{ ad_domain|upper }}'
        ansible_password: '{{ vmware_password }}'
        ansible_connection: paramiko
        ansible_python_interpreter: /bin/python
      register: SmartdEnabledCMD
      failed_when: ( SmartdEnabledCMD.rc not in [ 0, 1 ] ) # When smart is disabled the return code is 1
      changed_when: False

    - name: Set SmartdEnabled fact
      set_fact:
        SmartdEnabled: '{{ true if SmartdEnabledCMD.rc == 0 else false }}'

    - name: Disable smartd at boot
      shell: chkconfig smartd off
      vars:
        ansible_user: '{{ vmware_user }}@{{ ad_domain|upper }}'
        ansible_password: '{{ vmware_password }}'
        ansible_connection: paramiko
        ansible_python_interpreter: /bin/python
      when: SmartdEnabled