Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openstack UPI: Automate Control Plane creation #2591

Merged
merged 2 commits into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 46 additions & 0 deletions upi/openstack/04_control-plane.yaml
@@ -0,0 +1,46 @@
# Required Python packages:
#
# ansible
# openstacksdk
# netaddr

- hosts: all

vars:
# The provided filename will be concatenated with the Control Plane node
# name and its 0-indexed serial number.
#
# In this case, the first node will look for this filename:
# "{{ os_infra_id }}-master-0-ignition.json"
cp_data: "ignition.json"

cp_server: "{{ os_infra_id }}-master"
cp_port: "{{ os_infra_id }}-master-port"

# These computed lists are used to feed the Ansible loops with the number
# of iterations specified in the Inventory.
cp_servers: "{{ [cp_server] * os_cp_nodes_number }}"
cp_ports: "{{ [cp_port] * os_cp_nodes_number }}"

tasks:
- name: 'Create the Control Plane ports'
os_port:
name: "{{ item.1 }}-{{ item.0 }}"
network: "{{ os_network }}"
security_groups:
- "{{ os_sg_master }}"
allowed_address_pairs:
- ip_address: "{{ os_subnet_range | next_nth_usable(5) }}"
- ip_address: "{{ os_subnet_range | next_nth_usable(6) }}"
with_indexed_items: "{{ cp_ports }}"

- name: 'Create the Control Plane servers'
os_server:
name: "{{ item.1 }}-{{ item.0 }}"
image: "{{ os_image_rhcos }}"
flavor: "{{ os_flavor_master }}"
auto_ip: no
userdata: "{{ lookup('file', [item.1, item.0, cp_data] | join('-')) | string }}"
nics:
- port-name: "{{ cp_port }}-{{ item.0 }}"
with_indexed_items: "{{ cp_servers }}"
28 changes: 28 additions & 0 deletions upi/openstack/down-04_control-plane.yaml
@@ -0,0 +1,28 @@
# Required Python packages:
#
# ansible
# openstacksdk

- hosts: all

vars:
cp_server: "{{ os_infra_id }}-master"
cp_port: "{{ os_infra_id }}-master-port"

# These computed lists are used to feed the Ansible loops with the number
# of iterations specified in the Inventory.
cp_servers: "{{ [cp_server] * os_cp_nodes_number }}"
cp_ports: "{{ [cp_port] * os_cp_nodes_number }}"

tasks:
- name: 'Remove the Control Plane servers'
os_server:
name: "{{ item.1 }}-{{ item.0 }}"
state: absent
with_indexed_items: "{{ cp_servers }}"

- name: 'Remove the Control Plane ports'
os_port:
name: "{{ item.1 }}-{{ item.0 }}"
state: absent
with_indexed_items: "{{ cp_ports }}"
4 changes: 4 additions & 0 deletions upi/openstack/inventory.yaml
Expand Up @@ -10,6 +10,10 @@ all:
os_flavor_master: 'm1.xlarge'
os_image_rhcos: 'rhcos'

# Number of provisioned Control Plane nodes
# 3 is the minimum number for a fully-functional cluster.
os_cp_nodes_number: 3

# Computed values

# os_infra_id is the string we will use as a prefix for the names of the
Expand Down