# Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. --- - name: Include include_tasks: "{{ pv_ports_file }}" - name: Refresh ssh keys command: ssh-keygen -R {{ groups['powervault_me4'][0] }} changed_when: false tags: install failed_when: false - name: Validate authentication of username and password command: ping -c1 {{ groups['powervault_me4'][0] }} register: validate_login changed_when: false failed_when: false - name: NFS node configuration on leap block: - name: Install open-iscsi zypper: name: open-iscsi state: present tags: install - name: Install sg3_utils zypper: name: sg3_utils state: present tags: install - name: Start the iSCSI deamon systemd: name: iscsid state: started - block: - name: Configure nic command: ip a add {{ pv_nic_ip }}/255.255.255.0 dev {{ pv_nic }} register: nic_status changed_when: false rescue: - name: Check if nic configured or not fail: msg: "{{ nic_conf_failed_msg }}" when: nic_status_search not in nic_status.stderr - name: Up the nic command: ip link set dev {{ pv_nic }} up changed_when: false when: os_supported_leap in ansible_distribution | lower - name: NFS node configuration on rocky block: - name: Install packages package: name: iscsi-initiator-utils state: present tags: install - name: Install packages package: name: sg3_utils state: present tags: install - name: Set bootproto value lineinfile: path: "{{ nic_path }}" regexp: '^BOOTPROTO=' line: 'BOOTPROTO=none' register: result - name: Set onboot value lineinfile: path: "{{ nic_path }}" regexp: '^ONBOOT=' line: 'ONBOOT=yes' - name: Add ip address lineinfile: path: "{{ nic_path }}" insertafter: '^ONBOOT=yes' line: 'IPADDR={{ pv_nic_ip }}' - name: Add netmask address lineinfile: path: "{{ nic_path }}" insertafter: '^IPADDR={{ pv_nic_ip }}' line: NETMASK=255.255.255.0 - name: Down the nic command: ifdown {{ pv_nic }} changed_when: true failed_when: false tags: install - name: Up the nic command: ifup {{ pv_nic }} changed_when: true tags: install - name: Show ip shell: > set -o pipefail && \ ifconfig {{ pv_nic }} | grep 'inet' |cut -d: -f2 | awk '{ print $2}' changed_when: false when: os_supported_leap not in ansible_distribution | lower - name: Discover nodes command: iscsiadm -m discovery -t sendtargets -p {{ item }} with_items: "{{ set_port_ip }}" register: ports_available failed_when: false changed_when: false tags: install - name: Pv port ip add_host: name: pv map_ip: "{{ item.item }}" with_items: "{{ ports_available.results }}" when: item.rc == 0 - name: Pv port ip set_fact: map_ip_output: "{{ item.stdout_lines }}" with_items: "{{ ports_available.results }}" when: item.rc == 0 - name: Find feasible port ip set_fact: discover: "{{ item }}" with_items: "{{ map_ip_output }}" when: hostvars['pv']['map_ip'] in item - name: Split on comma set_fact: ip_port: "{{ discover.split(',')[0] }}" - name: Pv name set_fact: pv_name: "{{ discover.split(',')[1].split()[1] }}" - name: IQDN id shell: > set -o pipefail && \ grep "InitiatorName=" /etc/iscsi/initiatorname.iscsi | cut -f2 -d"=" register: iqdn_id changed_when: false tags: install - name: Add ME4 volume data to dummy host add_host: name: "server_iqdn_id" server_iqdn: "{{ iqdn_id.stdout }}" - name: Login to the powervault command: iscsiadm -m node --login {{ pv_name }} -p {{ ip_port }} changed_when: true failed_when: false tags: install