Browse Source

Issue #896: Updated collections for ipaddr if ansible version is > 2.9

Signed-off-by: DeepikaKrishnaiah <deepika_k2@dell.com>
DeepikaKrishnaiah 3 years ago
parent
commit
017802c620

+ 3 - 0
control_plane/roles/control_plane_ib/files/Dockerfile

@@ -1,5 +1,6 @@
 FROM rockylinux/rockylinux:docker_os
 
+RUN dnf -y update && dnf clean all
 RUN dnf install -y epel-release
 RUN dnf install dhcp-server -y \
   ansible \
@@ -20,5 +21,7 @@ COPY opensm.conf /etc/rdma/opensm.conf
 COPY start.sh /
 
 RUN systemctl enable dhcpd
+RUN chmod +x /start.sh
 
+ENTRYPOINT ["/start.sh"]
 CMD ["sbin/init"]

+ 1 - 11
control_plane/roles/control_plane_ib/files/infiniband_container_configure.yml

@@ -1,4 +1,4 @@
-# Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
+# 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.
@@ -21,13 +21,3 @@
   - name: Start dhcpd services
     command: dhcpd {{ ib_nic }}
     changed_when: false
-
-  - name: Change mode
-    command: chmod 777 /start.sh
-    changed_when: false
-
-  - name: Run shell
-    shell: ./start.sh
-    args:
-      chdir: /
-    changed_when: false

+ 3 - 3
control_plane/roles/control_plane_ib/files/k8s_infiniband.yml

@@ -35,8 +35,8 @@ spec:
         - name: infiniband-container
           image: 'localhost/infiniband-container:latest'
           imagePullPolicy: Never
-          command:
-            - /sbin/init
+          command: [ "/start.sh" ]
+          args: [ "/sbin/init" ]
           volumeMounts:
             - name: omnia-storage
               mountPath: /root/omnia
@@ -52,4 +52,4 @@ spec:
             capabilities:
               add:
                 - NET_RAW
-            privileged: false
+            privileged: true

+ 1 - 1
control_plane/roles/control_plane_ib/files/start.sh

@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 /usr/libexec/rdma-init-kernel
 

+ 2 - 0
control_plane/roles/webui_awx/files/requirements.yml

@@ -10,3 +10,5 @@ collections:
     version: 2.2.3
   - name: community.grafana
     version: 1.3.0
+  - name: ansible.utils
+    version: 2.5.2

+ 30 - 0
roles/cluster_validation/tasks/install_packages.yml

@@ -0,0 +1,30 @@
+#  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: Set fact for ansible version
+  set_fact:
+    ansible_collection_used: true
+  when: "ansible_version.full is version_compare(ansible_base_version, '>')"
+
+- name: Install netaddr
+  pip:
+    name: netaddr
+    state: present
+    executable: pip3
+
+- name: Install ansible galaxy collection ansible.utils
+  command: ansible-galaxy collection install "{{ ipaddr_collection }}"
+  changed_when: false
+  when: ansible_collection_used

+ 6 - 1
roles/cluster_validation/tasks/main.yml

@@ -27,6 +27,7 @@
     control_plane_status: false
     powervault_status: false
     nfs_node_status: false
+    ansible_collection_used: false
 
 - name: Check AWX instance
   command: awx --version
@@ -46,6 +47,10 @@
     - not awx_version_check.failed
     - awx_search_key in awx_hostname.stdout
 
+- name: Install Packages
+  include_tasks: install_packages.yml
+  when: not control_plane_status
+
 - name: Set NFS node status
   set_fact:
     nfs_node_status: true
@@ -90,4 +95,4 @@
         regexp: '#log_path = /var/log/ansible.log'
         replace: 'log_path = /var/log/omnia.log'
       when: ansible_conf_exists.stat.exists
-  when: not control_plane_status
+  when: not control_plane_status

+ 5 - 1
roles/cluster_validation/vars/main.yml

@@ -99,4 +99,8 @@ allow_deny_fail_msg: "Failed. Incorrect Access format in security_vars.yml"
 restrict_program_support_success_msg: "restrict_program_support successfully validated"
 restrict_program_support_failure_msg: "Failed. Accepted values are true or false."
 restrict_softwares_success_msg: "restrict_softwares successfully validated"
-restrict_softwares_failure_msg: "Warning. Values should be comma separated. The supported services are telnet, lpd, bluetooth, rlogin, rexec. Please check restrict_softwares variable"
+restrict_softwares_failure_msg: "Warning. Values should be comma separated. The supported services are telnet, lpd, bluetooth, rlogin, rexec. Please check restrict_softwares variable"
+
+# Usage: install_packages.yml
+ansible_base_version: '2.9'
+ipaddr_collection: ansible.utils:2.5.2

+ 6 - 0
roles/slurm_manager/tasks/main.yml

@@ -120,6 +120,12 @@
 - name: Get network address/subnet mask
   set_fact:
     network_address: "{{ (ansible_default_ipv4.network + '/' + ansible_default_ipv4.netmask) | ipaddr('network/prefix') }}"
+  when: not hostvars['127.0.0.1']['ansible_collection_used']
+
+- name: Get network address/subnet mask
+  set_fact:
+    network_address: "{{ (ansible_default_ipv4.network + '/' + ansible_default_ipv4.netmask) | ansible.utils.ipaddr('network/prefix') }}"
+  when: hostvars['127.0.0.1']['ansible_collection_used']
 
 - name: Firewall rule slurm - allow all incoming traffic on internal network
   firewalld:

+ 1 - 1
telemetry/roles/slurm_telemetry/tasks/get_node_inventory.yml

@@ -39,7 +39,7 @@
     register: awx_svc_ip
 
   - name: AWX needs to be installed
-   fail:
+    fail:
       msg: "{{ awx_fail_msg }}"
     when: not awx_svc_ip.stdout
 

+ 75 - 73
telemetry/roles/slurm_telemetry/tasks/update_service_tags.yml

@@ -1,4 +1,4 @@
- Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
+# 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.
@@ -34,83 +34,85 @@
   - name: Assert slurmctld status
     fail:
       msg: "{{ slurmctld_status_fail_msg }}"
-    when: not slurm_service
+    when: not hostvars[groups['manager'][0]]['slurm_service']
 
   - name: Prepare input config file
     block:
     - name: Get service tag
-        shell: >
+      shell: >
           set -o pipefail && \
           dmidecode -t 1 | grep Serial
-        changed_when: false
-        register: service_tag_details
-
-      - name: Set fact service tag
-        set_fact:
-          service_tag: "{{ service_tag_details.stdout.split(':')[1].strip() }}"
-
-      - name: Get the hostname
-        command: hostname
-        register: machine_hostname
-        changed_when: false
-
-      - name: Update Head Node IP
-        replace:
-          path: "{{ role_path }}{{ monster_input_file_path }}"
-          regexp: '  ip:.*'
-          replace: "  ip: {{ groups['manager'][0] }}"
-        delegate_to: localhost
-
-      - name: Update Head Node hostname
-        replace:
-          path: "{{ role_path }}{{ monster_input_file_path }}"
-          regexp: '  headnode:.*'
-          replace: "  headnode: {{ hostvars[groups['manager'][0]]['machine_hostname'].stdout }}"
-        delegate_to: localhost
-
-      - name: Update nodes hostnames
-        lineinfile:
-          path: "{{ role_path }}{{ monster_input_file_path }}"
-          line: "  {{ machine_hostname.stdout }}: {{ inventory_hostname }}"
-          insertafter: "hostnames:"
-        delegate_to: localhost
-
-      - name: Update service tag info
-        lineinfile:
-          path: "{{ role_path }}{{ monster_input_file_path }}"
-          line: "  - Servicetag: {{ service_tag }}\n    Os_Ip_Addr: {{ inventory_hostname }}"
-          insertafter: "clusternodes:"
-        delegate_to: localhost
-
-      - name: Copy initialization file
-        copy:
-          src: "{{ role_path }}/files/init_k8s_pod_local.sh"
-          dest: "{{ role_path }}/files/init_k8s_pod.sh"
-          mode: "{{ monster_config_file_mode }}"
-
-      - name: Update manager node details in init_k8s_pod.sh
-        replace:
-          path: "{{ role_path }}/files/init_k8s_pod.sh"
-          regexp: echo 'manager_node_ip manager_node_hostname' >> /etc/hosts
-          replace: echo '{{ inventory_hostname }} {{ machine_hostname.stdout }}' >> /etc/hosts
-        delegate_to: localhost
-        when: manager_group in group_names
-
-      - name: Update manager node IP in init_k8s_pod.sh
-        replace:
-          path: "{{ role_path }}/files/init_k8s_pod.sh"
-          regexp: ssh-keyscan -H manager_node_hostname >> /root/.ssh/known_hosts
-          replace: ssh-keyscan -H {{ machine_hostname.stdout }} >> /root/.ssh/known_hosts
-        delegate_to: localhost
-        when: manager_group in group_names
-
-      - name: Update manager node IP in init_k8s_pod.sh
-        replace:
-          path: "{{ role_path }}/files/init_k8s_pod.sh"
-          regexp: sshpass -p 'os_passwd' ssh-copy-id 'root@manager_node_ip'
-          replace: sshpass -p "{{ hostvars['127.0.0.1']['provision_password'] }}" ssh-copy-id 'root@{{ inventory_hostname }}'
-        delegate_to: localhost
-        when: manager_group in group_names
+      changed_when: false
+      register: service_tag_details
+
+    - name: Set fact service tag
+      set_fact:
+        service_tag: "{{ service_tag_details.stdout.split(':')[1].strip() }}"
+
+    - name: Get the hostname
+      command: hostname
+      register: machine_hostname
+      changed_when: false
+
+    - name: Update Head Node IP
+      replace:
+        path: "{{ role_path }}{{ monster_input_file_path }}"
+        regexp: '  ip:.*'
+        replace: "  ip: {{ groups['manager'][0] }}"
+      delegate_to: localhost
+
+    - name: Update Head Node hostname
+      replace:
+        path: "{{ role_path }}{{ monster_input_file_path }}"
+        regexp: '  headnode:.*'
+        replace: "  headnode: {{ hostvars[groups['manager'][0]]['machine_hostname'].stdout }}"
+      delegate_to: localhost
+
+    - name: Update nodes hostnames
+      lineinfile:
+        path: "{{ role_path }}{{ monster_input_file_path }}"
+        line: "  {{ machine_hostname.stdout }}: {{ inventory_hostname }}"
+        insertafter: "hostnames:"
+      delegate_to: localhost
+
+    - name: Update service tag info
+      lineinfile:
+        path: "{{ role_path }}{{ monster_input_file_path }}"
+        line: "  - Servicetag: {{ service_tag }}\n    Os_Ip_Addr: {{ inventory_hostname }}"
+        insertafter: "clusternodes:"
+      delegate_to: localhost
+
+    - name: Copy initialization file
+      copy:
+        src: "{{ role_path }}/files/init_k8s_pod_local.sh"
+        dest: "{{ role_path }}/files/init_k8s_pod.sh"
+        mode: "{{ monster_config_file_mode }}"
+      delegate_to: localhost
+      when: manager_group in group_names
+
+    - name: Update manager node details in init_k8s_pod.sh
+      replace:
+        path: "{{ role_path }}/files/init_k8s_pod.sh"
+        regexp: echo 'manager_node_ip manager_node_hostname' >> /etc/hosts
+        replace: echo '{{ inventory_hostname }} {{ machine_hostname.stdout }}' >> /etc/hosts
+      delegate_to: localhost
+      when: manager_group in group_names
+
+    - name: Update manager node IP in init_k8s_pod.sh
+      replace:
+        path: "{{ role_path }}/files/init_k8s_pod.sh"
+        regexp: ssh-keyscan -H manager_node_hostname >> /root/.ssh/known_hosts
+        replace: ssh-keyscan -H {{ machine_hostname.stdout }} >> /root/.ssh/known_hosts
+      delegate_to: localhost
+      when: manager_group in group_names
+
+    - name: Update manager node IP in init_k8s_pod.sh
+      replace:
+        path: "{{ role_path }}/files/init_k8s_pod.sh"
+        regexp: sshpass -p 'os_passwd' ssh-copy-id 'root@manager_node_ip'
+        replace: sshpass -p "{{ hostvars['127.0.0.1']['provision_password'] }}" ssh-copy-id 'root@{{ inventory_hostname }}'
+      delegate_to: localhost
+      when: manager_group in group_names
 
     when: hostvars[groups['manager'][0]]['slurm_service']
-  when: slurm_telemetry_support
+  when: hostvars['127.0.0.1']['slurm_telemetry_support']