diff --git a/playbooks/deploy-standalone-compute.yml b/playbooks/deploy-standalone-compute.yml index 516997db7..15cd83f5c 100644 --- a/playbooks/deploy-standalone-compute.yml +++ b/playbooks/deploy-standalone-compute.yml @@ -1,45 +1,50 @@ --- -# This playbook does: -# - On undercloud node -# + it bootstrap the node and deploy standalone -# + Generate 99 standalone vars and copy it to -# subnode-1 -# +# First, deploy the undercloud. This will also ensure the inventory is properly +# populated with the subnode-1 host and all the needed data. - hosts: undercloud gather_facts: true tags: - standalone - vars: - deploy_standalone: true tasks: - name: Run External Data Plane management role include_role: - name: external-data-plane-management + name: external_data_plane_management + tasks_from: prepare_node.yml -# On subnode-1 -# It bootstrap the node and install required packages -# copy 99 standalone vars to tripleo inventory -# Deploy compute services +# Now that we have the updated inventory, we can get to subnode-1 using the +# correct data. Let's bootstrap it! - hosts: subnode-1 gather_facts: true tags: - standalone - vars: - deploy_standalone: false - copy_inventory: true - target_host: subnode-1 tasks: - name: Run External Data Plane management role include_role: - name: external-data-plane-management + name: external_data_plane_management + tasks_from: prepare_node.yml -# On Controller node -# Run validate_external_compute.sh +# On undercloud: +# + Deploy standalone +# + Deploy the external compute from within the undercloud +# + Validate external compute - hosts: undercloud - gather_facts: true + gather_facts: false tags: - standalone tasks: - - include_role: - name: external-data-plane-management + - name: Deploy standalone + include_role: + name: external_data_plane_management + tasks_from: deploy_standalone.yml + - name: Deploy remote compute + vars: + target_host: 'subnode-1' + include_role: + name: external_data_plane_management + tasks_from: compute_services_on_target_host.yml + - name: Validate EDPM deploy + vars: + target_host: 'subnode-1' + include_role: + name: external_data_plane_management tasks_from: validate_edpm.yml diff --git a/roles/external-data-plane-management/tasks/compute_services_on_target_host.yml b/roles/external-data-plane-management/tasks/compute_services_on_target_host.yml deleted file mode 100644 index 83b3466d5..000000000 --- a/roles/external-data-plane-management/tasks/compute_services_on_target_host.yml +++ /dev/null @@ -1,61 +0,0 @@ ---- -# It contains following tasks: -# - Set hostname for target node -# - Run repo-setup role to enable specific release files -# - Build depends-on changes using build-test-packages and enable gating repo -# to install built packages from gating repo -# - Install tripleo-ansible and its required dependencies -# - Copy standalone env vars to subnode-1 -# - Change localhost to target hostname -# - Deploy compute services. - -- name: Install Required packages - become: true - package: - name: - - ansible-collection-containers-podman - - python3-tenacity - - tripleo-ansible - - ansible-role-chrony - state: present - -- name: Copy 99 standalone var from controller to compute node - copy: - src: "/home/{{ ansible_user }}/99-standalone-vars" - dest: "/usr/share/ansible/tripleo-inventory/99-standalone-vars" - become: true - when: copy_inventory | default('false') | bool - -- name: Change localhost name to target host - become: true - lineinfile: - path: "/usr/share/ansible/tripleo-inventory/02-computes" - search_string: 'localhost:' - # 4 spaces is added to place at proper hostname position - # TODO(chkumar): Explore inifile module to manipulate yaml - # file later. - line: " {{ target_host }}:" - -- name: Rename the host_vars file to target host - become: true - copy: - src: "/usr/share/ansible/tripleo-inventory/host_vars/localhost" - dest: "/usr/share/ansible/tripleo-inventory/host_vars/{{ target_host }}" - -- name: Remove the old file - become: true - file: - path: "/usr/share/ansible/tripleo-inventory/host_vars/localhost" - state: absent - -- name: Generate deploy_compute.sh script - template: - src: deploy_compute.sh.j2 - dest: "{{ working_dir }}/deploy_compute.sh" - mode: 0755 - -- name: Run deploy_compute.sh script - shell: > - set -o pipefail && - {{ working_dir }}/deploy_compute.sh - 2>&1 {{ timestamper_cmd }} > {{ working_dir }}/deploy_compute.log diff --git a/roles/external-data-plane-management/tasks/main.yml b/roles/external-data-plane-management/tasks/main.yml deleted file mode 100644 index 5329881be..000000000 --- a/roles/external-data-plane-management/tasks/main.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -# This Playbook does the following things in order - -# prepare_node.yml -# * It will run on both controller and compute node. -# - Add the host to tripleo-inventory -# - Run undercloud-setup -- import_tasks: prepare_node.yml - -# deploy_standalone.yml -# * It will run on controller node -# - Deploy Standalone -# - Generate 99 standalone vars -- import_tasks: deploy_standalone.yml - when: deploy_standalone | bool - -# compute_services_on_target_host.yml -# * It will run on target node. -# - Install the tripleo-ansible dependencies on target node -# - Copy 99 standalone vars from controller to -# compute node inventory -# - Deploy compute services on target node -- import_tasks: compute_services_on_target_host.yml - when: not deploy_standalone | bool diff --git a/roles/external-data-plane-management/templates/deploy_compute.sh.j2 b/roles/external-data-plane-management/templates/deploy_compute.sh.j2 deleted file mode 100644 index e40b0c6ed..000000000 --- a/roles/external-data-plane-management/templates/deploy_compute.sh.j2 +++ /dev/null @@ -1,19 +0,0 @@ -sudo ansible-playbook -i /usr/share/ansible/tripleo-inventory \ - -e tripleo_iscsid_image={{ tripleo_iscsid_image }} \ - -e tripleo_logrotate_crond_image={{ tripleo_logrotate_crond_image }} \ - -e tripleo_nova_compute_container_image={{ tripleo_nova_compute_container_image }} \ - -e tripleo_nova_libvirt_container_image={{ tripleo_nova_libvirt_container_image }} \ - -e tripleo_ovn_controller_image={{ tripleo_ovn_controller_image }} \ - -e tripleo_selinux_mode={{ tripleo_selinux_mode }} \ - -e neutron_public_interface_name={{ neutron_public_interface_name }} \ - -e tripleo_network_config_template={{ tripleo_network_config_template }} \ - -e '{ctlplane_dns_nameservers: {{ ctlplane_dns_nameservers }}}' \ - -e '{tripleo_container_registry_insecure_registries: {{ tripleo_container_registry_insecure_registries }}}' \ - -e '{tripleo_hosts_entries_overcloud_hosts_entries: {{ tripleo_hosts_entries_overcloud_hosts_entries|to_json }}}' \ - {% if not copy_inventory | bool %} - -e '{dns_search_domains: {{ dns_search_domains }}}' \ - -e '{tripleo_ovn_dbs: {{ tripleo_ovn_dbs }}}' \ - {% else %} - -e ctlplane_ip={{ ctlplane_ip }} \ - {% endif %} - /usr/share/ansible/tripleo-playbooks/deploy-overcloud-compute.yml diff --git a/roles/external-data-plane-management/README.md b/roles/external_data_plane_management/README.md similarity index 100% rename from roles/external-data-plane-management/README.md rename to roles/external_data_plane_management/README.md diff --git a/roles/external-data-plane-management/defaults/main.yml b/roles/external_data_plane_management/defaults/main.yml similarity index 97% rename from roles/external-data-plane-management/defaults/main.yml rename to roles/external_data_plane_management/defaults/main.yml index 6c4969271..2fcf04a05 100644 --- a/roles/external-data-plane-management/defaults/main.yml +++ b/roles/external_data_plane_management/defaults/main.yml @@ -5,13 +5,11 @@ tripleo_logrotate_crond_image: "{{ docker_registry_host }}/{{ docker_registry_na tripleo_nova_compute_container_image: "{{ docker_registry_host }}/{{ docker_registry_namespace }}/openstack-nova-compute:{{ docker_image_tag }}" tripleo_nova_libvirt_container_image: "{{ docker_registry_host }}/{{ docker_registry_namespace }}/openstack-nova-libvirt:{{ docker_image_tag }}" tripleo_ovn_controller_image: "{{ docker_registry_host }}/{{ docker_registry_namespace }}/openstack-ovn-controller:{{ docker_image_tag }}" -deploy_standalone: false # tripleo-standalone-vars script related vars tripleo_standalone_vars: "/home/{{ ansible_user }}/src/opendev.org/openstack/tripleo-ansible/scripts/tripleo-standalone-vars" config_download_dir: "/home/{{ ansible_user }}/tripleo-deploy" role_type: "Standalone" -copy_inventory: false target_host: undercloud timestamper_cmd: >- diff --git a/roles/external-data-plane-management/meta/main.yml b/roles/external_data_plane_management/meta/main.yml similarity index 100% rename from roles/external-data-plane-management/meta/main.yml rename to roles/external_data_plane_management/meta/main.yml diff --git a/roles/external_data_plane_management/tasks/compute_services_on_target_host.yml b/roles/external_data_plane_management/tasks/compute_services_on_target_host.yml new file mode 100644 index 000000000..0ba7ecf8b --- /dev/null +++ b/roles/external_data_plane_management/tasks/compute_services_on_target_host.yml @@ -0,0 +1,96 @@ +--- +# It contains following tasks: +# - Set hostname for target node +# - Copy standalone env vars to subnode-1 +# - Change localhost to target hostname +# - Deploy compute services. + +- name: Copy id_rsa key to working_dir + become: true + copy: + src: /etc/nodepool/id_rsa + dest: "{{ working_dir }}/.ssh/edpm_rsa" + owner: "{{ ansible_user }}" + mode: 0600 + +- name: Copy tripleo-inventory as EDPM env + become: true + copy: + src: /usr/share/ansible/tripleo-inventory/ + dest: "{{ working_dir }}/tripleo-deploy/edpm-inventory/" + remote_src: true + directory_mode: 0755 + owner: "{{ ansible_user }}" + +- name: Copy 99 standalone var into EDPM inventory + copy: + src: "{{ working_dir }}/99-standalone-vars" + dest: "{{ working_dir }}/tripleo-deploy/edpm-inventory/99-standalone-vars" + remote_src: true + +- name: Manipulate inventory + block: + - name: Get subnode IP + register: subnode_ip + slurp: + path: /etc/nodepool/sub_nodes + + - name: Get inventory content + register: original_inventory + slurp: + path: "{{ working_dir }}/tripleo-deploy/edpm-inventory/02-computes" + + - name: Set inventory host content + set_fact: + inventory_hosts: | + { + hosts: { + {{ target_host }}: { + ansible_host: "{{ subnode_ip['content']|b64decode|trim }}", + ansible_ssh_private_key_file: '{{ working_dir }}/.ssh/edpm_rsa', + ansible_ssh_common_args: '-o StrictHostKeyChecking=no' + } + } + } + + - name: Update inventory content + set_fact: + updated_inventory: >- + {%- set _inventory = original_inventory['content']|b64decode|from_yaml %} + {%- set _hosts = inventory_hosts |from_yaml %} + {%- set _ = _inventory['Compute'].update( _hosts ) %} + {{ _inventory }} + + - name: Output new inventory as clean yaml + copy: + dest: "{{ working_dir }}/tripleo-deploy/edpm-inventory/02-computes" + content: "{{ updated_inventory | from_yaml | to_nice_yaml }}" + +- name: Rename the host_vars file to target host + copy: + src: "{{ working_dir }}/tripleo-deploy/edpm-inventory/host_vars/localhost" + dest: "{{ working_dir }}/tripleo-deploy/edpm-inventory/host_vars/{{ target_host }}" + remote_src: true + +- name: Remove the old file + file: + path: "{{ working_dir }}/tripleo-deploy/edpm-inventory/host_vars/localhost" + state: absent + +- name: Generate parameter file for deploy_compute task + template: + src: compute-parameter.yaml.j2 + dest: "{{ working_dir }}/edpm-compute-parameter.yaml" + mode: 0644 + +- name: Generate deploy_compute.sh script + template: + src: deploy_compute.sh.j2 + dest: "{{ working_dir }}/deploy_compute.sh" + mode: 0755 + +- name: Run deploy_compute.sh script + shell: > + set -o pipefail && + {{ working_dir }}/deploy_compute.sh + 2>&1 {{ timestamper_cmd }} > {{ working_dir }}/deploy_compute.log diff --git a/roles/external-data-plane-management/tasks/deploy_standalone.yml b/roles/external_data_plane_management/tasks/deploy_standalone.yml similarity index 100% rename from roles/external-data-plane-management/tasks/deploy_standalone.yml rename to roles/external_data_plane_management/tasks/deploy_standalone.yml diff --git a/roles/external-data-plane-management/tasks/generate_tripleo_standalone_vars.yml b/roles/external_data_plane_management/tasks/generate_tripleo_standalone_vars.yml similarity index 100% rename from roles/external-data-plane-management/tasks/generate_tripleo_standalone_vars.yml rename to roles/external_data_plane_management/tasks/generate_tripleo_standalone_vars.yml diff --git a/roles/external-data-plane-management/tasks/install_required_packages.yml b/roles/external_data_plane_management/tasks/install_required_packages.yml similarity index 100% rename from roles/external-data-plane-management/tasks/install_required_packages.yml rename to roles/external_data_plane_management/tasks/install_required_packages.yml diff --git a/roles/external_data_plane_management/tasks/main.yml b/roles/external_data_plane_management/tasks/main.yml new file mode 100644 index 000000000..f4d8e56dd --- /dev/null +++ b/roles/external_data_plane_management/tasks/main.yml @@ -0,0 +1,4 @@ +--- +- name: Do not do anything + fail: + msg: "This role doesn't do anything unless you include a specific task file" diff --git a/roles/external-data-plane-management/tasks/prepare_node.yml b/roles/external_data_plane_management/tasks/prepare_node.yml similarity index 83% rename from roles/external-data-plane-management/tasks/prepare_node.yml rename to roles/external_data_plane_management/tasks/prepare_node.yml index b7cedd1d8..5961adaf1 100644 --- a/roles/external-data-plane-management/tasks/prepare_node.yml +++ b/roles/external_data_plane_management/tasks/prepare_node.yml @@ -6,7 +6,7 @@ include_role: name: tripleo-inventory -- name: Prepare the node for installation +- name: Prepare nodes with repositories and custom builds include_role: name: undercloud-setup diff --git a/roles/external-data-plane-management/tasks/validate_edpm.yml b/roles/external_data_plane_management/tasks/validate_edpm.yml similarity index 87% rename from roles/external-data-plane-management/tasks/validate_edpm.yml rename to roles/external_data_plane_management/tasks/validate_edpm.yml index f6e62fd95..5291c6cc7 100644 --- a/roles/external-data-plane-management/tasks/validate_edpm.yml +++ b/roles/external_data_plane_management/tasks/validate_edpm.yml @@ -5,7 +5,7 @@ dest: "{{ working_dir }}/validate_external_compute.sh" mode: 0755 -- name: Run deploy_compute.sh script +- name: Run validate_external_compute.sh script shell: > set -o pipefail && {{ working_dir }}/validate_external_compute.sh diff --git a/roles/external_data_plane_management/templates/compute-parameter.yaml.j2 b/roles/external_data_plane_management/templates/compute-parameter.yaml.j2 new file mode 100644 index 000000000..49cd82a78 --- /dev/null +++ b/roles/external_data_plane_management/templates/compute-parameter.yaml.j2 @@ -0,0 +1,18 @@ +--- +# Parameter file for the deploy-overcloud-compute.yml playbook + +ctlplane_ip: "{{ ctlplane_ip }}" +tripleo_iscsid_image: "{{ tripleo_iscsid_image }}" +tripleo_logrotate_crond_image: "{{ tripleo_logrotate_crond_image }}" +tripleo_nova_compute_container_image: "{{ tripleo_nova_compute_container_image }}" +tripleo_nova_libvirt_container_image: "{{ tripleo_nova_libvirt_container_image }}" +tripleo_ovn_controller_image: "{{ tripleo_ovn_controller_image }}" +tripleo_selinux_mode: "{{ tripleo_selinux_mode }}" +neutron_public_interface_name: "{{ neutron_public_interface_name }}" +tripleo_network_config_template: "{{ tripleo_network_config_template }}" +ctlplane_dns_nameservers: {{ ctlplane_dns_nameservers }} +tripleo_container_registry_insecure_registries: {{ tripleo_container_registry_insecure_registries }} +tripleo_hosts_entries_overcloud_hosts_entries: {{ tripleo_hosts_entries_overcloud_hosts_entries|to_json }} +# For now, don't load firewall +deploy_tripleo_openstack_run_firewall: false +tripleo_sshd_configure_firewall: true diff --git a/roles/external_data_plane_management/templates/deploy_compute.sh.j2 b/roles/external_data_plane_management/templates/deploy_compute.sh.j2 new file mode 100644 index 000000000..63ad9b89b --- /dev/null +++ b/roles/external_data_plane_management/templates/deploy_compute.sh.j2 @@ -0,0 +1,3 @@ +sudo ansible-playbook -i {{ working_dir }}/tripleo-deploy/edpm-inventory \ + -e @{{ working_dir }}/edpm-compute-parameter.yaml \ + /usr/share/ansible/tripleo-playbooks/deploy-overcloud-compute.yml diff --git a/roles/external-data-plane-management/templates/validate_edpm.sh.j2 b/roles/external_data_plane_management/templates/validate_edpm.sh.j2 similarity index 96% rename from roles/external-data-plane-management/templates/validate_edpm.sh.j2 rename to roles/external_data_plane_management/templates/validate_edpm.sh.j2 index 828ebc795..ab2626276 100644 --- a/roles/external-data-plane-management/templates/validate_edpm.sh.j2 +++ b/roles/external_data_plane_management/templates/validate_edpm.sh.j2 @@ -1,5 +1,5 @@ #!/bin/bash - +# {{ target_host }} set -eux # Discover new compute nodes @@ -8,6 +8,16 @@ sudo podman exec -it nova_api nova-manage cell_v2 discover_hosts --verbose # Export standalone cloud export OS_CLOUD=standalone +# Export some needed variables +export GATEWAY='{{ tempest_cidr|nthhost(1) }}' +export PUBLIC_NETWORK_CIDR='{{ tempest_cidr }}' +export PRIVATE_NETWORK_CIDR=192.168.74.0/28 +export PUBLIC_NET_START='{{ tempest_cidr|nthhost(150) }}' +export PUBLIC_NET_END='{{ tempest_cidr|nthhost(200) }}' +export DNS_SERVER=1.1.1.1 +export HYPER='{{ hostvars[target_host].ansible_fqdn }}' +export INSTANCE_NAME=myserver-$HYPER + # List Available Zones openstack availability zone list @@ -25,15 +35,6 @@ openstack network agent list # Steps to validate host # copied from https://github.com/fultonj/zed/blob/main/standalone/verify.sh -export GATEWAY='{{ tempest_cidr|nthhost(1) }}' -export PUBLIC_NETWORK_CIDR='{{ tempest_cidr }}' -export PRIVATE_NETWORK_CIDR=192.168.74.0/28 -export PUBLIC_NET_START='{{ tempest_cidr|nthhost(150) }}' -export PUBLIC_NET_END='{{ tempest_cidr|nthhost(200) }}' -export DNS_SERVER=1.1.1.1 -export HYPER='{{ hostvars['subnode-1'].ansible_fqdn }}' -export INSTANCE_NAME=myserver-$HYPER - openstack keypair create --private-key ~/test_key default openstack keypair list