Skip to content

Commit

Permalink
Merge pull request #2591 from pierreprinetti/os_upi_ansible_master
Browse files Browse the repository at this point in the history
openstack UPI: Automate Control Plane creation
  • Loading branch information
openshift-merge-robot committed Dec 3, 2019
2 parents 79dae77 + ca8d3b3 commit c82a585
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
46 changes: 46 additions & 0 deletions upi/openstack/04_control-plane.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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

0 comments on commit c82a585

Please sign in to comment.