<commit_before>// Module included in the following assemblies:
//
// * installing/installing_openstack/installing-openstack-user.adoc

[id="installation-osp-creating-compute-machines_{context}"]
= Creating compute machines

After standing up the control plane, create compute machines.

.Prerequisites
* The `inventory.yaml` and `common.yaml` Ansible playbooks in a common directory
** If you need these files, copy them from *Creating network resources*
* The `metadata.yaml` file that the installation program created is in the same directory as the Ansible playbooks
* The control plane is active

.Procedure

. On a command line, change the working directory to the location of the `inventory.yaml`and `common.yaml` files.

. Insert the following content into a local file that is called `05_compute-nodes.yaml`:
+
[source,yaml]
----
# Required Python packages:
#
# ansible
# openstackclient
# openstacksdk
# netaddr

- import_playbook: common.yaml

- hosts: all
  gather_facts: no

  tasks:
  - name: 'Create the Compute ports'
    os_port:
      name: "{{ item.1 }}-{{ item.0 }}"
      network: "{{ os_network }}"
      security_groups:
      - "{{ os_sg_worker }}"
      allowed_address_pairs:
      - ip_address: "{{ os_subnet_range | next_nth_usable(7) }}"
    with_indexed_items: "{{ [os_port_worker] * os_compute_nodes_number }}"
    register: ports

  - name: 'Set Compute ports tag'
    command:
      cmd: "openstack port set --tag {{ [cluster_id_tag] }} {{ item.1 }}-{{ item.0 }}"
    with_indexed_items: "{{ [os_port_worker] * os_compute_nodes_number }}"

  - name: 'List the Compute Trunks'
    command:
      cmd: "openstack network trunk list"
    when: os_networking_type == "Kuryr"
    register: compute_trunks

  - name: 'Create the Compute trunks'
    command:
      cmd: "openstack network trunk create --parent-port {{ item.1.id }} {{ os_compute_trunk_name }}-{{ item.0 }}"
    with_indexed_items: "{{ ports.results }}"
    when:
    - os_networking_type == "Kuryr"
    - "os_compute_trunk_name|string not in compute_trunks.stdout"

  - name: 'Create the Compute servers'
    os_server:
      name: "{{ item.1 }}-{{ item.0 }}"
      image: "{{ os_image_rhcos }}"
      flavor: "{{ os_flavor_worker }}"
      auto_ip: no
      userdata: "{{ lookup('file', 'worker.ign') | string }}"
      nics:
      - port-name: "{{ os_port_worker }}-{{ item.0 }}"
    with_indexed_items: "{{ [os_compute_server_name] * os_compute_nodes_number }}"
----

. On a command line, run the playbook:
+
[source,terminal]
----
$ ansible-playbook -i inventory.yaml 05_compute-nodes.yaml
----

.Next steps

* Approve the machines' certificate signing requests
<commit_msg>Bug 1873448: Ensure proper tagging of compute node ports (#25137)<commit_after>// Module included in the following assemblies:
//
// * installing/installing_openstack/installing-openstack-user.adoc
// * installing/installing_openstack/installing-openstack-user-kuryr.adoc

[id="installation-osp-creating-compute-machines_{context}"]
= Creating compute machines

After standing up the control plane, create compute machines.

.Prerequisites
* The `inventory.yaml` and `common.yaml` Ansible playbooks in a common directory
** If you need these files, copy them from *Creating network resources*
* The `metadata.yaml` file that the installation program created is in the same directory as the Ansible playbooks
* The control plane is active

.Procedure

. On a command line, change the working directory to the location of the `inventory.yaml`and `common.yaml` files.

. Insert the following content into a local file that is called `05_compute-nodes.yaml`:
+
[source,yaml]
----
# Required Python packages:
#
# ansible
# openstackclient
# openstacksdk
# netaddr

- import_playbook: common.yaml

- hosts: all
  gather_facts: no

  tasks:
  - name: 'Create the Compute ports'
    os_port:
      name: "{{ item.1 }}-{{ item.0 }}"
      network: "{{ os_network }}"
      security_groups:
      - "{{ os_sg_worker }}"
      allowed_address_pairs:
      - ip_address: "{{ os_subnet_range | next_nth_usable(7) }}"
    with_indexed_items: "{{ [os_port_worker] * os_compute_nodes_number }}"
    register: ports

  - name: 'Set Compute ports tag'
    command:
      cmd: "openstack port set --tag {{ cluster_id_tag }} {{ item.1 }}-{{ item.0 }}"
    with_indexed_items: "{{ [os_port_worker] * os_compute_nodes_number }}"

  - name: 'List the Compute Trunks'
    command:
      cmd: "openstack network trunk list"
    when: os_networking_type == "Kuryr"
    register: compute_trunks

  - name: 'Create the Compute trunks'
    command:
      cmd: "openstack network trunk create --parent-port {{ item.1.id }} {{ os_compute_trunk_name }}-{{ item.0 }}"
    with_indexed_items: "{{ ports.results }}"
    when:
    - os_networking_type == "Kuryr"
    - "os_compute_trunk_name|string not in compute_trunks.stdout"

  - name: 'Create the Compute servers'
    os_server:
      name: "{{ item.1 }}-{{ item.0 }}"
      image: "{{ os_image_rhcos }}"
      flavor: "{{ os_flavor_worker }}"
      auto_ip: no
      userdata: "{{ lookup('file', 'worker.ign') | string }}"
      nics:
      - port-name: "{{ os_port_worker }}-{{ item.0 }}"
    with_indexed_items: "{{ [os_compute_server_name] * os_compute_nodes_number }}"
----

. On a command line, run the playbook:
+
[source,terminal]
----
$ ansible-playbook -i inventory.yaml 05_compute-nodes.yaml
----

.Next steps

* Approve the machines' certificate signing requests

{'fraction_non_alphanumeric': 0.12792825768667643, 'fraction_numerical': 0.007320644216691069, 'mean_word_length': 3.542809642560266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4226186', 'n_tokens_mistral': 1823, 'n_tokens_neox': 1755, 'n_words': 478}