Files
kolla-ansible/ansible/roles/ironic/tasks/config.yml
Michal Nasiadka fd2f14cbae ironic: Add support for using uWSGI
Change-Id: I2b72712479a05a73b82d8e30235333db2c92ebfd
Signed-off-by: Michal Nasiadka <mnasiadka@gmail.com>
2025-08-12 09:04:39 +00:00

286 lines
9.5 KiB
YAML

---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory"
owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}"
mode: "0770"
become: true
with_dict: "{{ ironic_services | select_services_enabled_and_mapped_to_host }}"
- name: Check if Ironic policies shall be overwritten
stat:
path: "{{ item }}"
delegate_to: localhost
run_once: True
register: ironic_policy
with_first_found:
- files: "{{ supported_policy_format_list }}"
paths:
- "{{ node_custom_config }}/ironic/"
skip: true
- name: Check if Ironic Inspector policies shall be overwritten
stat:
path: "{{ item }}"
delegate_to: localhost
run_once: True
register: ironic_inspector_policy
with_first_found:
- files: "{{ supported_policy_format_list }}"
paths:
- "{{ node_custom_config }}/ironic/inspector/"
skip: true
- name: Set ironic policy file
set_fact:
ironic_policy_file: "{{ ironic_policy.results.0.stat.path | basename }}"
ironic_policy_file_path: "{{ ironic_policy.results.0.stat.path }}"
when:
- ironic_policy.results
- name: Set ironic-inspector policy file
set_fact:
ironic_inspector_policy_file: "{{ ironic_inspector_policy.results.0.stat.path | basename }}"
ironic_inspector_policy_file_path: "{{ ironic_inspector_policy.results.0.stat.path }}"
when:
- ironic_inspector_policy.results
- name: Check if Ironic Inspector known_devices.yaml shall be overwritten
stat:
path: "{{ node_custom_config }}/ironic-inspector/known_devices.yaml"
delegate_to: localhost
run_once: True
register: ironic_inspector_known_devices
- name: Set known_devices file path
set_fact:
ironic_inspector_known_devices_file_path: "{{ ironic_inspector_known_devices.stat.path }}"
when:
- ironic_inspector_known_devices.stat.exists
- name: Copying over known_devices.yaml
vars:
service: "{{ ironic_services['ironic-inspector'] }}"
template:
src: "{{ ironic_inspector_known_devices_file_path }}"
dest: "{{ node_config_directory }}/ironic-inspector/known_devices.yaml"
mode: "0660"
become: true
when:
- ironic_inspector_known_devices_file_path is defined
- service | service_enabled_and_mapped_to_host
- include_tasks: copy-certs.yml
when:
- ironic_copy_certs | bool
- name: Copying over config.json files for services
template:
src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
mode: "0660"
become: true
with_dict: "{{ ironic_services | select_services_enabled_and_mapped_to_host }}"
- name: Copying over ironic.conf
vars:
service_name: "{{ item.key }}"
merge_configs:
sources:
- "{{ role_path }}/templates/ironic.conf.j2"
- "{{ node_custom_config }}/global.conf"
- "{{ node_custom_config }}/ironic.conf"
- "{{ node_custom_config }}/ironic/{{ item.key }}.conf"
- "{{ node_custom_config }}/ironic/{{ inventory_hostname }}/ironic.conf"
dest: "{{ node_config_directory }}/{{ item.key }}/ironic.conf"
mode: "0660"
become: true
when:
- item.key in [ "ironic-api", "ironic-conductor", "ironic-prometheus-exporter" ]
with_dict: "{{ ironic_services | select_services_enabled_and_mapped_to_host }}"
- name: Copying over inspector.conf
vars:
service: "{{ ironic_services['ironic-inspector'] }}"
merge_configs:
sources:
- "{{ role_path }}/templates/ironic-inspector.conf.j2"
- "{{ node_custom_config }}/global.conf"
- "{{ node_custom_config }}/ironic-inspector.conf"
- "{{ node_custom_config }}/ironic-inspector/inspector.conf"
- "{{ node_custom_config }}/ironic-inspector/{{ inventory_hostname }}/inspector.conf"
dest: "{{ node_config_directory }}/ironic-inspector/inspector.conf"
mode: "0660"
become: true
when: service | service_enabled_and_mapped_to_host
- name: Copying over dnsmasq.conf
vars:
service: "{{ ironic_services['ironic-dnsmasq'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/ironic-dnsmasq/dnsmasq.conf"
mode: "0660"
become: true
when: service | service_enabled_and_mapped_to_host
with_first_found:
- "{{ node_custom_config }}/ironic/ironic-dnsmasq.conf"
- "{{ node_custom_config }}/ironic/{{ inventory_hostname }}/ironic-dnsmasq.conf"
- "ironic-dnsmasq.conf.j2"
- name: Copying pxelinux.cfg default
vars:
service: "{{ ironic_services['ironic-tftp'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/ironic-tftp/default"
mode: "0660"
become: true
with_first_found:
- "{{ node_custom_config }}/ironic/pxelinux.default"
- "{{ node_custom_config }}/ironic/{{ inventory_hostname }}/pxelinux.default"
- "pxelinux.default.j2"
when:
# Only required when Ironic inspector is in use.
- groups['ironic-inspector'] | length > 0
- service | service_enabled_and_mapped_to_host
- not ironic_dnsmasq_serve_ipxe | bool
- name: Copying ironic-agent kernel and initramfs (PXE)
vars:
service: "{{ ironic_services['ironic-tftp'] }}"
copy:
src: "{{ ironic_agent_files_directory }}/ironic/{{ item }}"
dest: "{{ node_config_directory }}/ironic-tftp/{{ item }}"
mode: "0660"
become: true
with_items:
- "ironic-agent.kernel"
- "ironic-agent.initramfs"
when:
# Only required when Ironic inspector is in use.
- groups['ironic-inspector'] | length > 0
- service | service_enabled_and_mapped_to_host
- not ironic_dnsmasq_serve_ipxe | bool
- name: Copying ironic-agent kernel and initramfs (iPXE)
vars:
service: "{{ ironic_services['ironic-http'] }}"
copy:
src: "{{ ironic_agent_files_directory }}/ironic/{{ item }}"
dest: "{{ node_config_directory }}/ironic-http/{{ item }}"
mode: "0660"
become: true
with_items:
- "ironic-agent.kernel"
- "ironic-agent.initramfs"
when:
# Only required when Ironic inspector is in use.
- groups['ironic-inspector'] | length > 0
- service | service_enabled_and_mapped_to_host
- name: Copying inspector.ipxe
vars:
service: "{{ ironic_services['ironic-http'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/ironic-http/inspector.ipxe"
mode: "0660"
become: true
with_first_found:
- "{{ node_custom_config }}/ironic/{{ inventory_hostname }}/inspector.ipxe"
- "{{ node_custom_config }}/ironic/inspector.ipxe"
- "inspector.ipxe.j2"
when:
# Only required when Ironic inspector is in use.
- groups['ironic-inspector'] | length > 0
- service | service_enabled_and_mapped_to_host
- name: Copying ironic-http-httpd.conf
vars:
service: "{{ ironic_services['ironic-http'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/ironic-http/httpd.conf"
mode: "0660"
become: true
with_first_found:
- "{{ node_custom_config }}/ironic/ironic-http-httpd.conf"
- "ironic-http-httpd.conf.j2"
when: service | service_enabled_and_mapped_to_host
- name: Copying over ironic-prometheus-exporter-wsgi.conf
vars:
service: "{{ ironic_services['ironic-prometheus-exporter'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/ironic-prometheus-exporter/ironic-prometheus-exporter-wsgi.conf"
mode: "0660"
become: true
with_first_found:
- "{{ node_config_directory }}/ironic/{{ inventory_hostname }}/ironic-prometheus-exporter-wsgi.conf"
- "{{ node_config_directory }}/ironic/ironic-prometheus-exporter-wsgi.conf"
- "ironic-prometheus-exporter-wsgi.conf.j2"
when: service | service_enabled_and_mapped_to_host
- name: Copying over existing Ironic policy file
vars:
services_require_policy_json:
- ironic-api
- ironic-conductor
template:
src: "{{ ironic_policy_file_path }}"
dest: "{{ node_config_directory }}/{{ item.key }}/{{ ironic_policy_file }}"
mode: "0660"
become: true
when:
- ironic_policy_file is defined
- item.key in services_require_policy_json
with_dict: "{{ ironic_services | select_services_enabled_and_mapped_to_host }}"
- name: Copying over existing Ironic Inspector policy file
vars:
services_require_inspector_policy_json:
- ironic-inspector
template:
src: "{{ ironic_inspector_policy_file_path }}"
dest: "{{ node_config_directory }}/{{ item.key }}/{{ ironic_inspector_policy_file }}"
mode: "0660"
become: true
when:
- ironic_inspector_policy_file is defined
- item.key in services_require_inspector_policy_json
with_dict: "{{ ironic_services | select_services_enabled_and_mapped_to_host }}"
- name: Copying over ironic-api-wsgi.conf
vars:
service: "{{ ironic_services['ironic-api'] }}"
template:
src: "ironic-api-wsgi.conf.j2"
dest: "{{ node_config_directory }}/ironic-api/ironic-api-wsgi.conf"
mode: "0660"
become: true
when:
- service | service_enabled_and_mapped_to_host
- ironic_wsgi_provider == "apache"
- name: "Configure uWSGI for ironic-api"
include_role:
name: service-uwsgi-config
vars:
project_services: "{{ ironic_services }}"
service: "{{ ironic_services['ironic-api'] }}"
service_name: "ironic-api"
service_uwsgi_config_http_port: "{{ ironic_api_listen_port }}"
service_uwsgi_config_log_file_chmod: "644"
service_uwsgi_config_module: "{{ service.wsgi }}"
service_uwsgi_config_tls_backend: "{{ ironic_enable_tls_backend | bool }}"
service_uwsgi_config_tls_cert: "/etc/ironic/certs/ironic-cert.pem"
service_uwsgi_config_tls_key: "/etc/ironic/certs/ironic-key.pem"
service_uwsgi_config_uid: "ironic"
when:
- service | service_enabled_and_mapped_to_host
- ironic_wsgi_provider == "uwsgi"