diff --git a/docs/set-variables-group-vars.md b/docs/set-variables-group-vars.md index 64c3c635..b26d7894 100644 --- a/docs/set-variables-group-vars.md +++ b/docs/set-variables-group-vars.md @@ -328,10 +328,11 @@ **hcp.data_plane.vcpus** | vCPUs for compute nodes | 4 **hcp.data_plane.memory** | RAM for compute nodes | 16384 **hcp.data_plane.nameserver** | Nameserver for compute nodes | 192.168.10.1 -**hcp.data_plane.storage.type** | Storage type for KVM guests qcow/dasd | qcow -**hcp.data_plane.storage.qcow.disk_size** | Disk size for kvm guests | 100G -**hcp.data_plane.storage.qcow.pool_path** | Storage pool path for creating disks | /home/images/ -**hcp.data_plane.storage.dasd** | dasd disks for kvm guests | /disk +**hcp.data_plane.kvm.boot_method** | Boot method for booting agents. Supported methods: pxe, iso | pxe +**hcp.data_plane.kvm.storage.type** | Storage type for KVM guests qcow/dasd | qcow +**hcp.data_plane.kvm.storage.qcow.disk_size** | Disk size for kvm guests | 100G +**hcp.data_plane.kvm.storage.qcow.pool_path** | Storage pool path for creating disks | /home/images/ +**hcp.data_plane.kvm.storage.dasd** | dasd disks for kvm guests | /disk **hcp.data_plane.kvm.ip_params.static_ip.enabled** | true or false - use static IPs for agents using NMState | true **hcp.data_plane.kvm.ip_params.static_ip.ip** | List of IP addresses for agents | 192.168.10.1 **hcp.data_plane.kvm.ip_params.static_ip.interface** | Interface for agents for configuring NMStateConfig | eth0 diff --git a/inventories/default/group_vars/hcp.yaml.template b/inventories/default/group_vars/hcp.yaml.template index 3c47c2b2..611009bc 100644 --- a/inventories/default/group_vars/hcp.yaml.template +++ b/inventories/default/group_vars/hcp.yaml.template @@ -72,6 +72,7 @@ hcp: nameserver: kvm: + boot_method: pxe # Supported methods : pxe, iso storage: type: qcow # Supported types: qcow, dasd qcow: diff --git a/playbooks/create_hosted_cluster.yaml b/playbooks/create_hosted_cluster.yaml index f18d7cbd..dfbbca83 100644 --- a/playbooks/create_hosted_cluster.yaml +++ b/playbooks/create_hosted_cluster.yaml @@ -86,6 +86,8 @@ - name: Configure httpd on bastion for hosting rootfs hosts: bastion_hcp - roles: - - download_rootfs_hcp - + tasks: + - name: Download rootfs image + include_role: + name: download_rootfs_hcp + when: ( hcp.data_plane.kvm.boot_method | lower != 'iso' and hcp.compute_node_type | lower == 'kvm' ) or hcp.compute_node_type | lower != 'kvm' \ No newline at end of file diff --git a/roles/boot_agents_hcp/tasks/main.yaml b/roles/boot_agents_hcp/tasks/main.yaml index cae8f3be..8c2a8ecc 100644 --- a/roles/boot_agents_hcp/tasks/main.yaml +++ b/roles/boot_agents_hcp/tasks/main.yaml @@ -4,7 +4,7 @@ loop: "{{ range(hcp.data_plane.compute_count|int) | list }}" when: hcp.data_plane.kvm.storage.type != 'dasd' -- name: Boot Agents +- name: Boot Agents with pxe artifacts shell: | {% if hcp.data_plane.kvm.ip_params.static_ip.enabled == true %} mac_address=$(oc get NmStateConfig static-ip-nmstate-config-{{ hcp.control_plane.hosted_cluster_name }}-{{ item }} -n {{ hcp.control_plane.clusters_namespace }}-{{ hcp.control_plane.hosted_cluster_name }} -o json | jq -r '.spec.interfaces[] | .macAddress') @@ -35,4 +35,37 @@ --extra-args "console=tty1 console=ttyS1,115200n8 coreos.inst.persistent-kargs=console=tty1 console=ttyS1,115200n8" async: 3600 poll: 0 - loop: "{{ range(hcp.data_plane.compute_count|int) | list }}" \ No newline at end of file + loop: "{{ range(hcp.data_plane.compute_count|int) | list }}" + when: hcp.data_plane.kvm.boot_method | lower != 'iso' + +- name: Boot Agents with iso + shell: | + {% if hcp.data_plane.kvm.ip_params.static_ip.enabled == true %} + mac_address=$(oc get NmStateConfig static-ip-nmstate-config-{{ hcp.control_plane.hosted_cluster_name }}-{{ item }} -n {{ hcp.control_plane.clusters_namespace }}-{{ hcp.control_plane.hosted_cluster_name }} -o json | jq -r '.spec.interfaces[] | .macAddress') + {% else %} + mac_address="{{ hcp.data_plane.kvm.ip_params.mac[item] }}" + {% endif %} + {% if hcp.data_plane.kvm.storage.type != "dasd" %} + disk_param="{{ hcp.data_plane.kvm.storage.qcow.pool_path }}{{ hcp.control_plane.hosted_cluster_name }}-agent{{ item }}.qcow2" + {% else %} + disk_param="{{ hcp.data_plane.kvm.storage.dasd[item] }}" + {% endif %} + + virt-install \ + --name "{{ hcp.control_plane.hosted_cluster_name }}-agent-{{ item }}" \ + --autostart \ + --memory="{{ hcp.data_plane.memory }}" \ + --cpu host \ + --vcpus="{{ hcp.data_plane.vcpus }}" \ + --network network:{{ hcp.bastion_params.network_name }},mac=$mac_address \ + --cdrom "/var/lib/libvirt/images/pxeboot/image.iso" \ + --disk $disk_param \ + --graphics none \ + --noautoconsole \ + --os-variant detect=on,require=off \ + --wait=-1 + async: 3600 + poll: 0 + loop: "{{ range(hcp.data_plane.compute_count|int) | list }}" + when: hcp.data_plane.kvm.boot_method | lower == 'iso' + diff --git a/roles/boot_zvm_nodes_hcp/tasks/main.yaml b/roles/boot_zvm_nodes_hcp/tasks/main.yaml index 3e808c62..e79ae871 100644 --- a/roles/boot_zvm_nodes_hcp/tasks/main.yaml +++ b/roles/boot_zvm_nodes_hcp/tasks/main.yaml @@ -44,5 +44,5 @@ register: agent_name - name: Approve agents - shell: oc -n {{ hcp.control_plane.clusters_namespace }}-{{ hcp.control_plane.hosted_cluster_name }} patch agent {{ agent_name.stdout.split(' ')[0] }} -p '{"spec":{"approved":true,"hostname":"compute-{{ item }}.{{hcp.control_plane.hosted_cluster_name }}.{{ hcp.control_plane.hcp.basedomain }}"}}' --type merge + shell: oc -n {{ hcp.control_plane.clusters_namespace }}-{{ hcp.control_plane.hosted_cluster_name }} patch agent {{ agent_name.stdout.split(' ')[0] }} -p '{"spec":{"approved":true,"hostname":"compute-{{ item }}.{{hcp.control_plane.hosted_cluster_name }}.{{ hcp.control_plane.basedomain }}"}}' --type merge diff --git a/roles/delete_resources_bastion_hcp/tasks/main.yaml b/roles/delete_resources_bastion_hcp/tasks/main.yaml index 41e64c2f..7e542030 100644 --- a/roles/delete_resources_bastion_hcp/tasks/main.yaml +++ b/roles/delete_resources_bastion_hcp/tasks/main.yaml @@ -106,7 +106,6 @@ until: managedcluster.rc != 0 retries: 50 delay: 25 - when: hcp.mce.delete == true ignore_errors: yes - fail: @@ -115,6 +114,7 @@ - name: Disable local-cluster component in MCE command: oc patch mce {{ hcp.mce.instance_name }} -p '{"spec":{"overrides":{"components":[{"name":"local-cluster","enabled":false}]}}}' --type merge + when: hcp.mce.delete == true - name: Wait for local-cluster components to be deleted shell: oc get ns local-cluster @@ -127,7 +127,9 @@ - fail: msg: "local-cluster namespace is still present" - when: localcluster.rc == 0 and localcluster.attempts >= 40 + when: + - hcp.mce.delete == true + - localcluster.rc == 0 and localcluster.attempts >= 40 - name: Delete AgentServiceConfig k8s: diff --git a/roles/delete_resources_kvm_host_hcp/tasks/main.yaml b/roles/delete_resources_kvm_host_hcp/tasks/main.yaml index 1338deff..c14fa8c4 100644 --- a/roles/delete_resources_kvm_host_hcp/tasks/main.yaml +++ b/roles/delete_resources_kvm_host_hcp/tasks/main.yaml @@ -12,11 +12,19 @@ file: path: /var/lib/libvirt/images/pxeboot/initrd.img state: absent + when: ( hcp.data_plane.kvm.boot_method | lower != 'iso' and hcp.compute_node_type | lower == 'kvm' ) or hcp.compute_node_type | lower != 'kvm' - name: Delete kernel.img file: path: /var/lib/libvirt/images/pxeboot/kernel.img state: absent + when: ( hcp.data_plane.kvm.boot_method | lower != 'iso' and hcp.compute_node_type | lower == 'kvm' ) or hcp.compute_node_type | lower != 'kvm' + +- name: Delete iso + file: + path: /var/lib/libvirt/images/pxeboot/image.iso + state: absent + when: hcp.data_plane.kvm.boot_method | lower == 'iso' and hcp.compute_node_type | lower == 'kvm' - name: Destroy bastion command: virsh destroy {{ hcp.control_plane.hosted_cluster_name }}-bastion diff --git a/roles/setup_for_agents_hcp/tasks/main.yaml b/roles/setup_for_agents_hcp/tasks/main.yaml index 6484ec01..c24b08bc 100644 --- a/roles/setup_for_agents_hcp/tasks/main.yaml +++ b/roles/setup_for_agents_hcp/tasks/main.yaml @@ -8,22 +8,38 @@ - name: Get URL for initrd.img shell: oc -n "{{ hcp.control_plane.clusters_namespace }}-{{ hcp.control_plane.hosted_cluster_name }}" get InfraEnv "{{ hcp.control_plane.hosted_cluster_name }}" -ojsonpath="{.status.bootArtifacts.initrd}" register: initrd + when: ( hcp.data_plane.kvm.boot_method | lower != 'iso' and hcp.compute_node_type | lower == 'kvm' ) or hcp.compute_node_type | lower != 'kvm' - name: Download initrd.img get_url: url: "{{ initrd.stdout }}" dest: /var/lib/libvirt/images/pxeboot/initrd.img validate_certs: false + when: ( hcp.data_plane.kvm.boot_method | lower != 'iso' and hcp.compute_node_type | lower == 'kvm' ) or hcp.compute_node_type | lower != 'kvm' - name: Get URL for kernel.img shell: oc -n "{{ hcp.control_plane.clusters_namespace }}-{{ hcp.control_plane.hosted_cluster_name }}" get InfraEnv "{{ hcp.control_plane.hosted_cluster_name }}" -ojsonpath="{.status.bootArtifacts.kernel}" register: kernel + when: ( hcp.data_plane.kvm.boot_method | lower != 'iso' and hcp.compute_node_type | lower == 'kvm' ) or hcp.compute_node_type | lower != 'kvm' - name: Download kernel.img get_url: url: "{{ kernel.stdout }}" dest: /var/lib/libvirt/images/pxeboot/kernel.img validate_certs: false + when: ( hcp.data_plane.kvm.boot_method | lower != 'iso' and hcp.compute_node_type | lower == 'kvm' ) or hcp.compute_node_type | lower != 'kvm' + +- name: Get URL for ISO + shell: oc -n "{{ hcp.control_plane.clusters_namespace }}-{{ hcp.control_plane.hosted_cluster_name }}" get InfraEnv "{{ hcp.control_plane.hosted_cluster_name }}" -ojsonpath="{.status.isoDownloadURL}" + register: iso + when: hcp.data_plane.kvm.boot_method | lower == 'iso' and hcp.compute_node_type | lower == 'kvm' + +- name: Download ISO image + get_url: + url: "{{ iso.stdout }}" + dest: /var/lib/libvirt/images/pxeboot/image.iso + validate_certs: false + when: hcp.data_plane.kvm.boot_method | lower == 'iso' and hcp.compute_node_type | lower == 'kvm' - name: Generate param files template: