4702ad329d
We're collocating the etcd and master nodes, we should also be run the etcd scaleup playbook when adding new master nodes to the cluster. However, this needs to happen in a separate ansible run as the master node scale up and etcd scale up use different inventory files. Change-Id: I523ed32681818112b7570aeab3ede32ed4ec322b Closes-Bug: #1802319
175 lines
7.0 KiB
YAML
175 lines
7.0 KiB
YAML
heat_template_version: rocky
|
|
|
|
description: External tasks definition for OpenShift
|
|
|
|
parameters:
|
|
StackAction:
|
|
type: string
|
|
description: >
|
|
Heat action on performed top-level stack. Note StackUpdateType is
|
|
set to UPGRADE when a major-version upgrade is in progress.
|
|
constraints:
|
|
- allowed_values: ['CREATE', 'UPDATE']
|
|
RoleNetIpMap:
|
|
default: {}
|
|
type: json
|
|
ServiceData:
|
|
default: {}
|
|
description: Dictionary packing service data
|
|
type: json
|
|
ServiceNetMap:
|
|
default: {}
|
|
description: Mapping of service_name -> network name. Typically set
|
|
via parameter_defaults in the resource registry. This
|
|
mapping overrides those in ServiceNetMapDefaults.
|
|
type: json
|
|
DefaultPasswords:
|
|
default: {}
|
|
type: json
|
|
RoleName:
|
|
default: ''
|
|
description: Role name on which the service is applied
|
|
type: string
|
|
RoleParameters:
|
|
default: {}
|
|
description: Parameters specific to the role
|
|
type: json
|
|
EndpointMap:
|
|
default: {}
|
|
description: Mapping of service endpoint -> protocol. Typically set
|
|
via parameter_defaults in the resource registry.
|
|
type: json
|
|
OpenShiftNodeGroupName:
|
|
default: node-config-all-in-one
|
|
description: The group the nodes belong to.
|
|
type: string
|
|
tags:
|
|
- role_specific
|
|
OpenShiftDeploymentType:
|
|
default: 'origin'
|
|
description: The OpenShift-Ansible deployment type.
|
|
type: string
|
|
constraints:
|
|
- allowed_values: ['origin', 'openshift-enterprise']
|
|
|
|
resources:
|
|
RoleParametersValue:
|
|
type: OS::Heat::Value
|
|
properties:
|
|
type: json
|
|
value:
|
|
map_replace:
|
|
- map_replace:
|
|
- OpenShiftNodeGroupName: OpenShiftNodeGroupName
|
|
- values: {get_param: [RoleParameters]}
|
|
- values:
|
|
OpenShiftNodeGroupName: {get_param: OpenShiftNodeGroupName}
|
|
|
|
outputs:
|
|
role_data:
|
|
description: Role data for the Openshift Service
|
|
value:
|
|
service_name: openshift_node
|
|
config_settings: {}
|
|
upgrade_tasks: []
|
|
step_config: ''
|
|
external_deploy_tasks:
|
|
- name: openshift_node step 2
|
|
when: step == '2'
|
|
tags: openshift
|
|
block:
|
|
- name: set role facts for generating inventory
|
|
set_fact:
|
|
tripleo_role_name: {get_param: RoleName}
|
|
tripleo_stack_action: {get_param: StackAction}
|
|
tripleo_node_group_name: {get_attr: [RoleParametersValue, value, OpenShiftNodeGroupName]}
|
|
openshift_master_network: {get_param: [ServiceNetMap, OpenshiftMasterNetwork]}
|
|
tripleo_openshift_deployment_type: {get_param: OpenShiftDeploymentType}
|
|
|
|
- set_fact:
|
|
tripleo_openshift_service_type: >-
|
|
{%- if tripleo_openshift_deployment_type == 'origin' -%}
|
|
origin
|
|
{%- else -%}
|
|
atomic-openshift
|
|
{%- endif -%}
|
|
|
|
# NOTE(flaper87): Check if the node service is running in the
|
|
# openshift nodes so we can flag the node as new later on.
|
|
- name: Check if node service is running
|
|
command: "systemctl is-active --quiet {{tripleo_openshift_service_type}}-node"
|
|
register: node_services
|
|
delegate_to: "{{item}}"
|
|
with_items: "{{ groups[tripleo_role_name] | default([]) }}"
|
|
failed_when: false
|
|
|
|
# NOTE(flaper87): Create all the nodes objects now, as yaml dicts,
|
|
# instead of formatting everything as part of a template.
|
|
# We consider new_node all the nodes that exited with a non-zero
|
|
# status in the previous task *IF* this is a stack update.
|
|
# Openshift-ansible expects nodes to be in the new_nodes group for
|
|
# scale up operation only.
|
|
- set_fact:
|
|
nodes:
|
|
- new_node: "{{ tripleo_stack_action == 'UPDATE' and node_services.results | selectattr('item', 'equalto', item) | selectattr('rc', 'greaterthan', 0) | list | count > 0 }}"
|
|
hostname: "{{item}}"
|
|
ansible_user: "{{ hostvars[item]['ansible_user'] | default(hostvars[item]['ansible_ssh_user']) | default('root') }}"
|
|
ansible_host: "{{ hostvars[item]['ansible_host'] | default(item) }}"
|
|
ansible_become: true
|
|
openshift_node_group_name: '{{tripleo_node_group_name}}'
|
|
etcd_ip: "{{hostvars[item][openshift_master_network + '_ip']}}"
|
|
openshift_ip: "{{hostvars[item][openshift_master_network + '_ip']}}"
|
|
openshift_master_bind_addr: "{{hostvars[item][openshift_master_network + '_ip']}}"
|
|
openshift_public_ip: "{{hostvars[item][openshift_master_network + '_ip']}}"
|
|
openshift_public_hostname: "{{hostvars[item][openshift_master_network + '_ip']}}"
|
|
register: all_role_nodes
|
|
with_items: "{{groups[tripleo_role_name] | default([]) }}"
|
|
|
|
- set_fact:
|
|
role_nodes: "{{all_role_nodes.results | map(attribute='ansible_facts') | map(attribute='nodes') | flatten | selectattr('new_node', 'equalto', False) | list}}"
|
|
new_role_nodes: "{{all_role_nodes.results | map(attribute='ansible_facts') | map(attribute='nodes') | flatten | selectattr('new_node', 'equalto', True) | list}}"
|
|
|
|
- set_fact:
|
|
has_new_nodes: "{{ (has_new_nodes | default(False)) or new_role_nodes | count > 0 }}"
|
|
|
|
- name: generate openshift inventory for {{tripleo_role_name}} role hosts
|
|
copy:
|
|
dest: "{{playbook_dir}}/openshift/inventory/{{tripleo_role_name}}_hosts.yml"
|
|
content: |
|
|
{% if role_nodes | count > 0%}
|
|
all:
|
|
hosts:
|
|
{% for host in (role_nodes + new_role_nodes) -%}
|
|
{{host.hostname}}:
|
|
{{host | to_nice_yaml() | indent(6)}}
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
- name: generate openshift inventory for {{tripleo_role_name}} role groups
|
|
copy:
|
|
dest: "{{playbook_dir}}/openshift/inventory/{{tripleo_role_name}}_groups.yml"
|
|
content: |
|
|
{% if role_nodes | count > 0%}
|
|
all:
|
|
children:
|
|
{% if role_nodes | count > 0 -%}
|
|
nodes:
|
|
hosts:
|
|
{% for host in role_nodes -%}
|
|
{{host.hostname}}:
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% if new_role_nodes | count > 0 -%}
|
|
new_nodes:
|
|
hosts:
|
|
{% for host in new_role_nodes -%}
|
|
{{host.hostname}}:
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|