tripleo-heat-templates/extraconfig/services/openshift-worker.yaml
Martin André cc046a757c Do not fail on non existent ansible group
When a role is defined but this role has a host count of 0, the ansible
tasks to generate the openshift inventory for the service would fail
with an undefined variable error.

Setting the value for non existent groups to empty array should get us
past the error.

Change-Id: Ib42708c095d28827f5decdb885ceb4f2a67b3a8b
2018-06-11 11:31:12 +02:00

95 lines
3.5 KiB
YAML

heat_template_version: rocky
description: External tasks definition for OpenShift
parameters:
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
outputs:
role_data:
description: Role data for the Openshift Service
value:
# This service template essentially tags the nodes that we want
# as workers. The actual installation is performed in
# openshift-master service template.
service_name: openshift_worker
config_settings:
tripleo.openshift_worker.firewall_rules:
'200 openshift-worker kubelet':
dport:
- 10250
- 10255
proto: tcp
'200 openshift-worker external services':
dport: '30000-32767'
upgrade_tasks: []
step_config: ''
external_deploy_tasks:
- name: openshift_worker step 1
when: step == '1'
block:
- name: create openshift temp dirs
file:
path: "{{item}}"
state: directory
with_items:
- "{{playbook_dir}}/openshift/inventory"
- name: generate openshift inventory for openshift_worker service
copy:
dest:
str_replace:
template: "{{playbook_dir}}/openshift/inventory/ROLENAME_openshift_worker.yml"
params:
ROLENAME: {get_param: RoleName}
content:
str_replace:
params:
ROLENAME: {get_param: RoleName}
template: |
nodes:
hosts:
{% for host in groups['ROLENAME'] | default([]) -%}
{{ hostvars.raw_get(host)['ansible_hostname'] }}:
ansible_user: {{ hostvars.raw_get(host)['ansible_user'] | default(hostvars.raw_get(host)['ansible_ssh_user']) | default('root') }}
ansible_host: {{ hostvars.raw_get(host)['ansible_host'] | default(host) }}
ansible_become: true
etcd_ip: {{hostvars.raw_get(host)['ctlplane_ip']}}
openshift_ip: {{hostvars.raw_get(host)['ctlplane_ip']}}
openshift_public_ip: {{hostvars.raw_get(host)['ctlplane_ip']}}
openshift_hostname: {{hostvars.raw_get(host)['ctlplane_ip']}}
openshift_public_hostname: {{hostvars.raw_get(host)['ctlplane_ip']}}
openshift_schedulable: true
openshift_node_labels:
region: 'infra'
zone: 'default'
{% endfor %}