Ensure nginx config is present for ironic inspector

In an LXC deployment, nginx runs in both the ironc-api and
ironic-inspector containers. The api container can use ipxe to
boot the deployment and user images when `ironic_ipxe_enabled'
is true. The inspector container can use ipxe to independantly
serve the deploy images during inspection.

On a metal deployment these nginx instances are co-located on the
same host and share the same config files and directory structure
so no additional config is needed for inspectors nginx instance.

In an LXC depoyment the api and inspector containers need their
own individual nginx configuration to be written. This patch adds
that configuration for inspector.

A future patch could refactor the code so that only one set of
tasks is needed to deploy the nginx config to both inspector
and api.

Change-Id: Ida20e6835c6ca1c941fa76eadecf3d49e8b1239f
This commit is contained in:
Jonathan Rosser 2022-11-14 11:49:56 +00:00 committed by Dmitriy Rabotyagov
parent b09526d494
commit 7794cbd60b

View File

@ -42,3 +42,45 @@
owner: "{{ ironic_system_user_name }}"
group: "{{ ironic_system_group_name }}"
mode: '0644'
- name: Configure nginx when inspector boot mode is http
when: ironic_inspector_boot_mode == 'http'
block:
- name: Disable default nginx configuration
file:
path: /etc/nginx/sites-enabled/default
state: absent
notify:
- Restart web server
- name: Remove default nginx config
file:
path: /etc/nginx/conf.d/default.conf
state: absent
notify:
- Restart web server
- name: Ensure nginx configuration directories exist
file:
path: "{{ item }}"
state: directory
with_items:
- "/etc/nginx/{{ ironic_nginx_conf_path }}"
- name: Configure nginx virtual hosts
template:
src: ironic-ipxe.conf.j2
dest: "/etc/nginx/{{ ironic_nginx_conf_path }}/ironic-ipxe.conf"
notify:
- Restart web server
- name: Link to enable nginx virtual hosts
file:
src: "/etc/nginx/sites-available/ironic-ipxe.conf"
path: "/etc/nginx/sites-enabled/ironic-ipxe.conf"
state: link
when:
- ansible_facts['os_family'] == "Debian"
notify:
- Restart web server