---
- import_playbook: gather-facts.yml
- name: Apply role baremetal
hosts: baremetal
serial: '{{ kolla_serial|default("0") }}'
gather_facts: false
roles:
- { role: baremetal,
tags: baremetal }
|
---
- include_tasks: "{{ kolla_action }}.yml"
|
---
- include_tasks: pre-install.yml
- include_tasks: install.yml
- include_tasks: post-install.yml
- include_tasks: configure-containerd-for-zun.yml
when: containerd_configure_for_zun|bool and
inventory_hostname in groups['zun-cni-daemon']
|
# ll /etc/| grep kolla
drwxr-xr-x. 42 kolla kolla 4096 Nov 11 17:54 kolla
|
- name: Apply role prechecks
gather_facts: false
# Apply only when kolla action is 'precheck'.
hosts: kolla_action_precheck
roles:
- role: prechecks
|
---
- include_tasks: host_os_checks.yml
when: prechecks_enable_host_os_checks | bool
- include_tasks: timesync_checks.yml
when:
- not enable_chrony | bool
- include_tasks: datetime_checks.yml
- include_tasks: port_checks.yml
when:
- inventory_hostname not in groups['deployment']|default([])
- include_tasks: service_checks.yml
- include_tasks: package_checks.yml
- include_tasks: user_checks.yml
- include_tasks: database_checks.yml
|
- name: Apply role haproxy
gather_facts: false
hosts:
- haproxy
- '&enable_haproxy_True'
serial: '{{ kolla_serial|default("0") }}'
tags:
- haproxy
roles:
- { role: haproxy,
when: enable_haproxy | bool }
tasks:
- block:
- include_role:
name: aodh
tasks_from: loadbalancer
tags: aodh
when: enable_aodh | bool
- include_role:
name: barbican
...... #此處省略openstack其它組件的role導入,共47個組件
when:
- enable_haproxy | bool
- kolla_action in ['deploy', 'reconfigure', 'upgrade', 'config']
|
- include_role:
name: nova
tasks_from: loadbalancer
tags:
- nova
- nova-api
when: enable_nova | bool
|
[root@ksfusion1 nova]# cat roles/nova/tasks/loadbalancer.yml
---
- name: "Configure haproxy for {{ project_name }}"
import_role:
name: haproxy-config
vars:
project_services: "{{ nova_services }}"
tags: always
[root@ksfusion1 nova]#
|
[root@ksfusion1 ansible]# more roles/nova/defaults/main.yml
---
project_name: "nova"
nova_services:
nova-api:
container_name: "nova_api"
group: "nova-api"
image: "{{ nova_api_image_full }}"
enabled: True
privileged: True
volumes: "{{ nova_api_default_volumes + nova_api_extra_volumes }}"
dimensions: "{{ nova_api_dimensions }}"
haproxy:
nova_api:
enabled: "{{ enable_nova }}"
mode: "http"
external: false
port: "{{ nova_api_port }}"
listen_port: "{{ nova_api_listen_port }}"
tls_backend: "{{ nova_enable_tls_backend }}"
nova_api_external:
enabled: "{{ enable_nova }}"
mode: "http"
external: true
port: "{{ nova_api_port }}"
listen_port: "{{ nova_api_listen_port }}"
tls_backend: "{{ nova_enable_tls_backend }}"
nova_metadata:
enabled: "{{ enable_nova }}"
mode: "http"
external: false
port: "{{ nova_metadata_port }}"
listen_port: "{{ nova_metadata_listen_port }}"
tls_backend: "{{ nova_enable_tls_backend }}"
nova_metadata_external:
enabled: "{{ enable_nova }}"
mode: "http"
external: true
port: "{{ nova_metadata_port }}"
listen_port: "{{ nova_metadata_listen_port }}"
tls_backend: "{{ nova_enable_tls_backend }}"
nova-scheduler:
container_name: "nova_scheduler"
group: "nova-scheduler"
image: "{{ nova_scheduler_image_full }}"
enabled: True
volumes: "{{ nova_scheduler_default_volumes + nova_scheduler_extra_volumes }}"
dimensions: "{{ nova_scheduler_dimensions }}"
nova-super-conductor:
container_name: "nova_super_conductor"
group: "nova-super-conductor"
enabled: "{{ enable_cells }}"
image: "{{ nova_super_conductor_image_full }}"
volumes: "{{ nova_super_conductor_default_volumes + nova_super_conductor_extra_volumes }}"
dimensions: "{{ nova_super_conductor_dimensions }}"
......
|
[root@ksfusion1 ansible]# cat roles/haproxy-config/tasks/main.yml
---
- name: "Copying over {{ project_name }} haproxy config"
vars:
service: "{{ item.value }}"
haproxy_templates:
- "{{ node_custom_config }}/haproxy-config/{{ inventory_hostname }}/{{ haproxy_service_template }}"
- "{{ node_custom_config }}/haproxy-config/{{ haproxy_service_template }}"
- "templates/{{ haproxy_service_template }}"
template_file: "{{ query('first_found', haproxy_templates) | first }}"
template:
src: "{{ template_file }}"
dest: "{{ node_config_directory }}/haproxy/services.d/{{ item.key }}.cfg"
mode: "0660"
become: true
when:
- service.enabled | bool # 從roles/nova/defaults/main.yml可知此變量爲True
- service.haproxy is defined # 從roles/nova/defaults/main.yml可知此變量已定義
- enable_haproxy | bool # 從/etc/kolla/globals.yml可知此變量默認值爲yes,所以,nova組件的三個條件都知足
with_dict: "{{ project_services }}"
notify:
- Restart haproxy container
[root@ksfusion1 ansible]#
|
- enable_cinder_{{ enable_cinder | bool }}
|
- include_role:
name: cinder
tasks_from: loadbalancer
tags: cinder
when: enable_cinder | bool
|
[root@ksfusion1 ansible]# cat roles/cinder/tasks/loadbalancer.yml
---
- name: "Configure haproxy for {{ project_name }}"
import_role:
name: haproxy-config
vars:
project_services: "{{ cinder_services }}"
tags: always
|
[root@ksfusion1 ansible]# more roles/cinder/defaults/main.yml
---
project_name: "cinder"
cinder_services:
cinder-api:
container_name: cinder_api
group: cinder-api
enabled: true
image: "{{ cinder_api_image_full }}"
volumes: "{{ cinder_api_default_volumes + cinder_api_extra_volumes }}"
dimensions: "{{ cinder_api_dimensions }}"
haproxy:
cinder_api:
enabled: "{{ enable_cinder }}"
mode: "http"
external: false
port: "{{ cinder_api_port }}"
listen_port: "{{ cinder_api_listen_port }}"
tls_backend: "{{ cinder_enable_tls_backend }}"
cinder_api_external:
enabled: "{{ enable_cinder }}"
mode: "http"
external: true
port: "{{ cinder_api_port }}"
listen_port: "{{ cinder_api_listen_port }}"
tls_backend: "{{ cinder_enable_tls_backend }}"
cinder-scheduler:
container_name: cinder_scheduler
group: cinder-scheduler
enabled: true
image: "{{ cinder_scheduler_image_full }}"
volumes: "{{ cinder_scheduler_default_volumes + cinder_scheduler_extra_volumes }}"
dimensions: "{{ cinder_scheduler_dimensions }}"
cinder-volume:
container_name: cinder_volume
group: cinder-volume
enabled: true
image: "{{ cinder_volume_image_full }}"
privileged: True
ipc_mode: "host"
volumes: "{{ cinder_volume_default_volumes + cinder_volume_extra_volumes }}"
dimensions: "{{ cinder_volume_dimensions }}"
cinder-backup:
container_name: cinder_backup
group: cinder-backup
enabled: "{{ enable_cinder_backup | bool }}"
image: "{{ cinder_backup_image_full }}"
privileged: True
volumes: "{{ cinder_backup_default_volumes + cinder_backup_extra_volumes }}"
dimensions: "{{ cinder_backup_dimensions }}"
......
|
[root@ksfusion1 ansible]# cat roles/haproxy-config/tasks/main.yml
---
- name: "Copying over {{ project_name }} haproxy config"
vars:
service: "{{ item.value }}"
haproxy_templates:
- "{{ node_custom_config }}/haproxy-config/{{ inventory_hostname }}/{{ haproxy_service_template }}"
- "{{ node_custom_config }}/haproxy-config/{{ haproxy_service_template }}"
- "templates/{{ haproxy_service_template }}"
template_file: "{{ query('first_found', haproxy_templates) | first }}"
template:
src: "{{ template_file }}"
dest: "{{ node_config_directory }}/haproxy/services.d/{{ item.key }}.cfg"
mode: "0660"
become: true
when:
- service.enabled | bool # 從roles/nova/defaults/main.yml可知此變量爲True
- service.haproxy is defined # 從roles/nova/defaults/main.yml可知此變量已定義
- enable_haproxy | bool # 從/etc/kolla/globals.yml可知此變量默認值爲yes,所以,nova組件的三個條件都知足
with_dict: "{{ project_services }}"
notify:
- Restart haproxy container
[root@ksfusion1 ansible]#
|
- name: Apply role cinder
gather_facts: false
hosts:
- cinder-api
- cinder-backup
- cinder-scheduler
- cinder-volume
- '&enable_cinder_True'
serial: '{{ kolla_serial|default("0") }}'
roles:
- { role: cinder,
tags: cinder,
when: enable_cinder | bool }
|
[root@ksfusion1 ansible]# cat roles/cinder/tasks/main.yml
---
- include_tasks: "{{ kolla_action }}.yml"
[root@ksfusion1 ansible]# cat roles/cinder/tasks/deploy.yml
---
- include_tasks: register.yml
when: inventory_hostname in groups['cinder-api']
- include_tasks: config.yml
- include_tasks: clone.yml
when: cinder_dev_mode | bool
- include_tasks: bootstrap.yml
when: inventory_hostname in groups['cinder-api']
- name: Flush handlers
meta: flush_handlers
- include_tasks: check.yml
|