From 7794cbd60b1ca8d0e88782433119c7a90b9257e5 Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Mon, 14 Nov 2022 11:49:56 +0000 Subject: [PATCH] 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 --- tasks/ironic_inspector_post_install.yml | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tasks/ironic_inspector_post_install.yml b/tasks/ironic_inspector_post_install.yml index c4317e9b..2962240b 100644 --- a/tasks/ironic_inspector_post_install.yml +++ b/tasks/ironic_inspector_post_install.yml @@ -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