nfs_node_configure.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. # Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Include
  16. include_tasks: "{{ pv_ports_file }}"
  17. - name: Refresh ssh keys
  18. command: ssh-keygen -R {{ groups['powervault_me4'][0] }}
  19. changed_when: false
  20. tags: install
  21. failed_when: false
  22. - name: Validate authentication of username and password
  23. command: ping -c1 {{ groups['powervault_me4'][0] }}
  24. register: validate_login
  25. changed_when: false
  26. failed_when: false
  27. - name: Install packages
  28. package:
  29. name: iscsi-initiator-utils
  30. state: present
  31. tags: install
  32. - name: Install packages
  33. package:
  34. name: sg3_utils
  35. state: present
  36. tags: install
  37. - name: Set bootproto value
  38. lineinfile:
  39. path: "{{ nic_path }}"
  40. regexp: '^BOOTPROTO='
  41. line: 'BOOTPROTO=none'
  42. register: result
  43. - name: Set onboot value
  44. lineinfile:
  45. path: "{{ nic_path }}"
  46. regexp: '^ONBOOT='
  47. line: 'ONBOOT=yes'
  48. - name: Add ip address
  49. lineinfile:
  50. path: "{{ nic_path }}"
  51. insertafter: '^ONBOOT=yes'
  52. line: 'IPADDR={{ pv_nic_ip }}'
  53. - name: Add netmask address
  54. lineinfile:
  55. path: "{{ nic_path }}"
  56. insertafter: '^IPADDR={{ pv_nic_ip }}'
  57. line: NETMASK=255.255.255.0
  58. - name: Down the nic
  59. command: ifdown {{ pv_nic }}
  60. changed_when: true
  61. failed_when: false
  62. tags: install
  63. - name: Up the nic
  64. command: ifup {{ pv_nic }}
  65. changed_when: true
  66. tags: install
  67. - name: Show ip
  68. shell: >
  69. set -o pipefail && \
  70. ifconfig {{ pv_nic }} | grep 'inet' |cut -d: -f2 | awk '{ print $2}'
  71. changed_when: false
  72. - name: Discover nodes
  73. command: iscsiadm -m discovery -t sendtargets -p {{ item }}
  74. with_items: "{{ set_port_ip }}"
  75. register: ports_available
  76. failed_when: false
  77. changed_when: false
  78. tags: install
  79. - name: Pv port ip
  80. add_host:
  81. name: pv
  82. map_ip: "{{ item.item }}"
  83. with_items: "{{ ports_available.results }}"
  84. when: item.rc == 0
  85. - name: Pv port ip
  86. set_fact:
  87. map_ip_output: "{{ item.stdout_lines }}"
  88. with_items: "{{ ports_available.results }}"
  89. when: item.rc == 0
  90. - name: Find feasible port ip
  91. set_fact:
  92. discover: "{{ item }}"
  93. with_items: "{{ map_ip_output }}"
  94. when: hostvars['pv']['map_ip'] in item
  95. - name: Split on comma
  96. set_fact:
  97. ip_port: "{{ discover.split(',')[0] }}"
  98. - name: Pv name
  99. set_fact:
  100. pv_name: "{{ discover.split(',')[1].split()[1] }}"
  101. - name: IQDN id
  102. shell: >
  103. set -o pipefail && \
  104. cat /etc/iscsi/initiatorname.iscsi | cut -f2 -d"="
  105. register: iqdn_id
  106. changed_when: false
  107. tags: install
  108. - name: Add ME4 volume data to dummy host
  109. add_host:
  110. name: "server_iqdn_id"
  111. server_iqdn: "{{ iqdn_id.stdout }}"
  112. - name: Login to the powervault
  113. command: iscsiadm -m node --login {{ pv_name }} -p {{ ip_port }}
  114. changed_when: true
  115. failed_when: false
  116. tags: install