Selaa lähdekoodia

Merge pull request #730 from abhishek-sa1/devel

Issue #729: iDRAC provisioning with multiple profile support
Sujit Jadhav 3 vuotta sitten
vanhempi
commit
02c1966cfc

+ 2 - 1
control_plane/control_plane.yml

@@ -13,7 +13,7 @@
 #  limitations under the License.
 ---
 
-- name: Executing omnia roles
+- name: Executing control_plane roles
   hosts: localhost
   connection: local
   roles:
@@ -28,4 +28,5 @@
     - control_plane_customiso
     - control_plane_repo
     - control_plane_security
+    - control_plane_monitoring
     - deploy_job_templates

+ 25 - 6
control_plane/roles/control_plane_customiso/tasks/check_prerequisites.yml

@@ -13,9 +13,17 @@
 # limitations under the License.
 ---
 
+- name: Include control_plane_common vars
+  include_vars: ../../control_plane_common/vars/main.yml
+  tags: install
+
+- name: Include provision_cobbler vars
+  include_vars: ../../provision_cobbler/vars/main.yml
+  tags: install
+
 - name: Install xorriso package - rocky
   package:
-    name: xorriso
+    name: "{{ iso_package }}"
     state: present
   tags: install
   when:
@@ -24,7 +32,7 @@
 
 - name: Install xorriso package - leap
   zypper:
-    name: xorriso
+    name: "{{ iso_package }}"
     state: present
   tags: install
   when: os_supported_leap in ansible_distribution | lower
@@ -33,9 +41,7 @@
   command: ansible-galaxy collection install {{ item }}
   changed_when: true
   tags: install
-  with_items:
-   - community.general
-   - dellemc.openmanage
+  with_items: "{{ idrac_collections }}"
 
 - name: Install omsdk using pip
   pip:
@@ -49,10 +55,23 @@
   register: check_mount_iso
   tags: install
 
+- name: Include provision_cobbler vars
+  include_tasks: ../../provision_cobbler/tasks/mount_iso.yml
+  when: not check_mount_iso.stat.exists
+
+- name: Recheck iso mount folder
+  stat:
+    path: "{{ iso_mount_path }}{{ grub_cfg_path }}"
+  register: recheck_mount_iso
+  when: not check_mount_iso.stat.exists
+  tags: install
+
 - name: Incorrect iso mount
   fail:
     msg: "{{ iso_mount_check_fail_msg }}"
-  when: not check_mount_iso.stat.exists
+  when:
+    - not check_mount_iso.stat.exists
+    - not recheck_mount_iso.stat.exists
   register: iso_mount_fail
   tags: install
 

+ 0 - 86
control_plane/roles/control_plane_customiso/tasks/create_unattended_iso.yml

@@ -1,86 +0,0 @@
-#  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: ISO creation - centos
-  block:
-    - name: Create custom ISO
-      command: >-
-        xorriso -as mkisofs -o {{ nfs_share_offline_repo }}/{{ centos_iso_filename }} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4
-        -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -J -R -V "CentOS 7 x86_64"  {{ tmp_iso_dir }}
-      changed_when: true
-      register: centos_iso_status
-      tags: install
-      args:
-        chdir: "{{ tmp_iso_dir }}"
-
-    - name: Custom ISO creation status check
-      assert:
-        that:
-          - custom_iso_success_keyword1 in centos_iso_status.stderr
-          - custom_iso_success_keyword2 in centos_iso_status.stderr
-        success_msg: "{{ custom_iso_success_msg }}"
-        fail_msg: "{{ custom_iso_fail_msg }}"
-      tags: install
-  when: provision_os == os_supported_centos
-
-- name: ISO creation - rocky
-  block:
-    - name: Create custom ISO
-      command: >-
-        xorriso -as mkisofs -o {{ nfs_share_offline_repo }}/{{ rocky_iso_filename }} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4
-        -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -J -R -V "Rocky-8-4-x86_64-dvd"  {{ tmp_iso_dir }}
-      changed_when: true
-      register: rocky_iso_status
-      tags: install
-      args:
-        chdir: "{{ tmp_iso_dir }}"
-
-    - name: Custom ISO creation status check
-      assert:
-        that:
-          - custom_iso_success_keyword1 in rocky_iso_status.stderr
-          - custom_iso_success_keyword2 in rocky_iso_status.stderr
-        success_msg: "{{ custom_iso_success_msg }}"
-        fail_msg: "{{ custom_iso_fail_msg }}"
-      tags: install
-  when: provision_os == os_supported_rocky
-
-- name: ISO creation - leap
-  block:
-    - name: Create custom ISO
-      command: >-
-        xorriso -as mkisofs -no-emul-boot -boot-load-size 4 -boot-info-table -iso-level 4 -b boot/x86_64/loader/isolinux.bin 
-        -c boot/x86_64/loader/boot.cat -eltorito-alt-boot -e boot/x86_64/efi -no-emul-boot -o {{ nfs_share_offline_repo }}/{{ leap_iso_filename }} {{ tmp_iso_dir }}
-      changed_when: true
-      register: leap_iso_status
-      tags: install
-      args:
-        chdir: "{{ tmp_iso_dir }}"
-
-    - name: Custom ISO creation status check
-      assert:
-        that:
-          - custom_iso_success_keyword1 in leap_iso_status.stderr
-          - custom_iso_success_keyword2 in leap_iso_status.stderr
-        success_msg: "{{ custom_iso_success_msg }}"
-        fail_msg: "{{ custom_iso_fail_msg }}"
-      tags: install
-  when: provision_os == os_supported_leap
-
-- name: Remove the kickstart file
-  file:
-    path: "{{ role_path }}/files/{{ idrac_kickstart_file }}"
-    state: absent
-  tags: install

+ 39 - 0
control_plane/roles/control_plane_customiso/tasks/create_unattended_iso_centos.yml

@@ -0,0 +1,39 @@
+#  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: Create custom ISO centos
+  command: >-
+    xorriso -as mkisofs -o {{ nfs_share_offline_repo }}/{{ centos_iso_filename }} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4
+    -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -J -R -V "CentOS 7 x86_64"  {{ tmp_iso_dir }}
+  changed_when: true
+  register: centos_iso_status
+  tags: install
+  args:
+    chdir: "{{ tmp_iso_dir }}"
+
+- name: Custom ISO creation status check centos
+  assert:
+    that:
+      - custom_iso_success_keyword1 in centos_iso_status.stderr
+      - custom_iso_success_keyword2 in centos_iso_status.stderr
+    success_msg: "{{ custom_iso_success_msg }}"
+    fail_msg: "{{ custom_iso_fail_msg }}"
+  tags: install
+
+- name: Remove the kickstart file
+  file:
+    path: "{{ role_path }}/files/{{ idrac_kickstart_file }}"
+    state: absent
+  tags: install

+ 39 - 0
control_plane/roles/control_plane_customiso/tasks/create_unattended_iso_leap.yml

@@ -0,0 +1,39 @@
+#  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: Create custom ISO leap
+  command: >-
+    xorriso -as mkisofs -no-emul-boot -boot-load-size 4 -boot-info-table -iso-level 4 -b boot/x86_64/loader/isolinux.bin 
+    -c boot/x86_64/loader/boot.cat -eltorito-alt-boot -e boot/x86_64/efi -no-emul-boot -o {{ nfs_share_offline_repo }}/{{ leap_iso_filename }} {{ tmp_iso_dir }}
+  changed_when: true
+  register: leap_iso_status
+  tags: install
+  args:
+    chdir: "{{ tmp_iso_dir }}"
+
+- name: Custom ISO creation status check leap
+  assert:
+    that:
+      - custom_iso_success_keyword1 in leap_iso_status.stderr
+      - custom_iso_success_keyword2 in leap_iso_status.stderr
+    success_msg: "{{ custom_iso_success_msg }}"
+    fail_msg: "{{ custom_iso_fail_msg }}"
+  tags: install
+  
+- name: Remove the kickstart file
+  file:
+    path: "{{ role_path }}/files/{{ idrac_kickstart_file }}"
+    state: absent
+  tags: install

+ 44 - 0
control_plane/roles/control_plane_customiso/tasks/create_unattended_iso_rocky.yml

@@ -0,0 +1,44 @@
+#  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: Fetch rocky profile name
+  shell: set -o pipefail && grep 'Rocky-8' {{ tmp_iso_dir }}{{ grub_cfg_path }} | head -1
+  register: rocky_profile_name
+  changed_when: false
+
+- name: Create custom ISO rocky
+  command: >-
+    xorriso -as mkisofs -o {{ nfs_share_offline_repo }}/{{ rocky_iso_filename }} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4
+    -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -J -R -V {{ rocky_profile_name.stdout.split(' ')[4] | replace("'","") }}  {{ tmp_iso_dir }}
+  changed_when: true
+  register: rocky_iso_status
+  tags: install
+  args:
+    chdir: "{{ tmp_iso_dir }}"
+
+- name: Custom ISO creation status check rocky
+  assert:
+    that:
+      - custom_iso_success_keyword1 in rocky_iso_status.stderr
+      - custom_iso_success_keyword2 in rocky_iso_status.stderr
+    success_msg: "{{ custom_iso_success_msg }}"
+    fail_msg: "{{ custom_iso_fail_msg }}"
+  tags: install
+
+- name: Remove the kickstart file
+  file:
+    path: "{{ role_path }}/files/{{ idrac_kickstart_file }}"
+    state: absent
+  tags: install

+ 8 - 12
control_plane/roles/control_plane_customiso/tasks/edit_iso_config.yml

@@ -13,14 +13,6 @@
 #  limitations under the License.
 ---
 
-- name: Include control_plane_common vars
-  include_vars: ../../control_plane_common/vars/main.yml
-  tags: install
-
-- name: Include provision_cobbler vars
-  include_vars: ../../provision_cobbler/vars/main.yml
-  tags: install
-
 - name: Random phrase generation
   command: openssl rand -base64 12
   changed_when: false
@@ -49,8 +41,10 @@
     warn: false
   tags: install
 
-- block:
-    - block:
+- name: Kickstart file changes rocky and centos
+  block:
+    - name: Kickstart file changes centos
+      block:
         - name: Set centos kickstart file name
           set_fact:
             idrac_kickstart_file: "{{ idrac_centos_ks }}"
@@ -78,7 +72,8 @@
           with_items: "{{ centos_host_nic }}"
       when: provision_os == os_supported_centos
 
-    - block:
+    - name: Kickstart file changes rocky
+      block:
         - name: Set rocky kickstart file name
           set_fact:
             idrac_kickstart_file: "{{ idrac_rocky_ks }}"
@@ -165,7 +160,8 @@
     - provision_os == os_supported_rocky or
       provision_os == os_supported_centos
 
-- block:
+- name: Kickstart file changes leap
+  block:
     - name: Set leap kickstart file name
       set_fact:
         idrac_kickstart_file: "{{ idrac_leap_ks }}"

+ 11 - 2
control_plane/roles/control_plane_customiso/tasks/main.yml

@@ -21,5 +21,14 @@
 - name: Edit iso config files
   include_tasks: edit_iso_config.yml
 
-- name: Create unattended iso file
-  include_tasks: create_unattended_iso.yml
+- name: Create unattended iso file rocky
+  include_tasks: create_unattended_iso_rocky.yml
+  when: provision_os == os_supported_rocky
+
+- name: Create unattended iso file leap
+  include_tasks: create_unattended_iso_leap.yml
+  when: provision_os == os_supported_leap
+
+- name: Create unattended iso file centos
+  include_tasks: create_unattended_iso_centos.yml
+  when: provision_os == os_supported_centos

+ 16 - 8
control_plane/roles/control_plane_customiso/vars/main.yml

@@ -15,12 +15,16 @@
 
 # vars file for control_plane_customiso
 
-#Usage: check_prerequisites.yml
-iso_mount_path: /mnt/iso/
-iso_mount_check_fail_msg: "ISO file not mounted. Ensure /mnt/iso path is mounted with {{ provision_os }} ISO file."
+# Usage: check_prerequisites.yml
+iso_mount_path: /mnt/{{ provision_os }}/
+iso_mount_check_fail_msg: "ISO file not mounted successfully. Ensure /mnt/{{ provision_os }} path is mounted with {{ provision_os }} ISO file."
 management_station_ip_file: "management_station_ip.txt"
+idrac_collections:
+  - community.general
+  - dellemc.openmanage
+iso_package: xorriso
 
-#Usage: edit_iso_config.yml
+# Usage: edit_iso_config.yml
 tmp_iso_dir: /tmp/{{ provision_os }}/
 idrac_centos_ks: centos7.cfg
 idrac_rocky_ks: rocky8.cfg
@@ -29,11 +33,15 @@ file_permission: 0744
 isolinux_cfg_path: isolinux/isolinux.cfg
 grub_cfg_path: EFI/BOOT/grub.cfg
 
-#Usage: create_unattended_iso.yml
-centos_iso_filename: unattended_centos7.iso
+# Usage: create_unattended_iso_rocky.yml
 rocky_iso_filename: unattended_rocky8.iso
-leap_iso_filename: unattended_leap15.iso
 custom_iso_success_msg: "Unattended ISO file created successfully"
-custom_iso_fail_msg: "Unattended ISO file creation failed. Ensure /mnt/iso path is mounted with valid centos minimal ISO file."
+custom_iso_fail_msg: "Unattended ISO file creation failed. Ensure /mnt/{{ provision_os }} path is mounted with valid {{ provision_os }} ISO file."
 custom_iso_success_keyword1: "ISO image produced:"
 custom_iso_success_keyword2: "completed successfully"
+
+# Usage: create_unattended_iso_leap.yml
+leap_iso_filename: unattended_leap15.iso
+
+# Usage: create_unattended_iso_centos.yml
+centos_iso_filename: unattended_centos7.iso

+ 3 - 1
control_plane/roles/webui_awx/files/requirements.yml

@@ -2,4 +2,6 @@
 collections:
   - community.general
   - dellemc.openmanage
-  - dellemc.os10
+  - dellemc.os10
+  - kubernetes.core
+  - community.grafana