From 20fdea4bde4a88736f74ee38950c68f937b76f8a Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 23 Mar 2017 11:45:47 +0000 Subject: [PATCH] Add support for Bare Metal Provisioning (BMP) of Dell switches via seed We extend the configuration of the Bifrost dnsmasq server on the seed to support Bare Metal Provisioning of Dell switches. --- ansible/dell-switch-bmp.yml | 11 ++++++++ ansible/group_vars/all/dell-switch-bmp | 10 +++++++ .../roles/dell-switch-bmp/defaults/main.yml | 16 +++++++++++ .../roles/dell-switch-bmp/handlers/main.yml | 28 +++++++++++++++++++ ansible/roles/dell-switch-bmp/tasks/main.yml | 22 +++++++++++++++ .../templates/dell-switch-bmp.conf.j2 | 12 ++++++++ etc/kayobe/dell-switch-bmp.yml | 14 ++++++++++ kayobe/cli/commands.py | 4 ++- 8 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 ansible/dell-switch-bmp.yml create mode 100644 ansible/group_vars/all/dell-switch-bmp create mode 100644 ansible/roles/dell-switch-bmp/defaults/main.yml create mode 100644 ansible/roles/dell-switch-bmp/handlers/main.yml create mode 100644 ansible/roles/dell-switch-bmp/tasks/main.yml create mode 100644 ansible/roles/dell-switch-bmp/templates/dell-switch-bmp.conf.j2 create mode 100644 etc/kayobe/dell-switch-bmp.yml diff --git a/ansible/dell-switch-bmp.yml b/ansible/dell-switch-bmp.yml new file mode 100644 index 000000000..38e4b3989 --- /dev/null +++ b/ansible/dell-switch-bmp.yml @@ -0,0 +1,11 @@ +--- +# This playbook will configure a Bare Metal Provisioning (BMP) environment for +# Dell switches on the seed node so that they can be network booted. + +- name: Ensure that a Bare Metal Provisioning (BMP) environment is configured for Dell switches on the seed + hosts: seed + roles: + - role: dell-switch-bmp + # This is the Nginx web server on the seed node. + dell_switch_bmp_http_base_url: "http://{{ provision_oc_net_name | net_ip }}:8080" + when: "{{ dell_switch_bmp_images }}" diff --git a/ansible/group_vars/all/dell-switch-bmp b/ansible/group_vars/all/dell-switch-bmp new file mode 100644 index 000000000..6be98f918 --- /dev/null +++ b/ansible/group_vars/all/dell-switch-bmp @@ -0,0 +1,10 @@ +--- +# Dell Switch Bare Metal Provisioning (BMP) configuration. + +# List of images to provide a BMP configuration for. +# Each item should be a dict with the following keys: +# url: URL of the image to download. +# dest: Name of the file to download the image to. +# match: dnsmasq match rule to match hosts against. +# tag: dnsmasq tag to apply to matching hosts. +dell_switch_bmp_images: [] diff --git a/ansible/roles/dell-switch-bmp/defaults/main.yml b/ansible/roles/dell-switch-bmp/defaults/main.yml new file mode 100644 index 000000000..d4427a3fd --- /dev/null +++ b/ansible/roles/dell-switch-bmp/defaults/main.yml @@ -0,0 +1,16 @@ +--- +# List of images to provide a BMP configuration for. +# Each item should be a dict with the following keys: +# url: URL of the image to download. +# dest: Name of the file to download the image to. +# match: dnsmasq match rule to match hosts against. +# tag: dnsmasq tag to apply to matching hosts. +# checksum: optional checksum of image, in format required for Ansible's +# get_url module. +dell_switch_bmp_images: [] + +# Base URL of HTTP server. +dell_switch_bmp_http_base_url: + +# Path to HTTP server base directory. +dell_switch_bmp_httpboot_path: "/httpboot" diff --git a/ansible/roles/dell-switch-bmp/handlers/main.yml b/ansible/roles/dell-switch-bmp/handlers/main.yml new file mode 100644 index 000000000..1cf0db2c6 --- /dev/null +++ b/ansible/roles/dell-switch-bmp/handlers/main.yml @@ -0,0 +1,28 @@ +--- +- name: Copy dnsmasq configuration + command: > + docker exec bifrost_deploy + bash -c 'source /bifrost/env-vars && + ansible -vvvv target -i /bifrost/playbooks/inventory/target + -m copy + -a "src=/etc/bifrost/dell-switch-bmp.conf dest=/etc/dnsmasq.d/dell-switch-bmp.conf" + -e "ansible_python_interpreter=/var/lib/kolla/venv/bin/python"' + +- name: Restart bifrost dnsmasq + command: > + docker exec bifrost_deploy + bash -c 'source /bifrost/env-vars && + ansible -vvvv target -i /bifrost/playbooks/inventory/target + -m service + -a "name=dnsmasq state=restarted" + -e "ansible_python_interpreter=/var/lib/kolla/venv/bin/python"' + +- name: Copy Dell switch BMP images + command: > + docker exec bifrost_deploy + bash -c 'source /bifrost/env-vars && + ansible -vvvv target -i /bifrost/playbooks/inventory/target + -m copy + -a "src=/etc/bifrost/{{ item.dest }} dest={{ dell_switch_bmp_httpboot_path }}/{{ item.dest }}" + -e "ansible_python_interpreter=/var/lib/kolla/venv/bin/python"' + with_items: "{{ dell_switch_bmp_images }}" diff --git a/ansible/roles/dell-switch-bmp/tasks/main.yml b/ansible/roles/dell-switch-bmp/tasks/main.yml new file mode 100644 index 000000000..cc7e65894 --- /dev/null +++ b/ansible/roles/dell-switch-bmp/tasks/main.yml @@ -0,0 +1,22 @@ +--- +- name: Ensure dnsmasq configuration is present + template: + src: dell-switch-bmp.conf.j2 + dest: /etc/kolla/bifrost/dell-switch-bmp.conf + notify: + - Copy dnsmasq configuration + - Restart bifrost dnsmasq + become: True + +- name: Ensure Dell BMP installer images are downloaded + get_url: + url: "{{ item.url }}" + dest: "/etc/kolla/bifrost/{{ item.dest }}" + # If no checksum is provided, download images every time to ensure changes + # are pulled. + force: "{{ omit if item.checksum is defined else 'yes' }}" + checksum: "{{ item.checksum | default(omit) }}" + with_items: "{{ dell_switch_bmp_images }}" + notify: + - Copy Dell switch BMP images + become: True diff --git a/ansible/roles/dell-switch-bmp/templates/dell-switch-bmp.conf.j2 b/ansible/roles/dell-switch-bmp/templates/dell-switch-bmp.conf.j2 new file mode 100644 index 000000000..068fe3bc2 --- /dev/null +++ b/ansible/roles/dell-switch-bmp/templates/dell-switch-bmp.conf.j2 @@ -0,0 +1,12 @@ +# {{ ansible_managed }} + +# This file provides dnsmasq configuration for Dell Switches using Bare Metal +# Provisioning (BMP). + +{% for image in dell_switch_bmp_images %} +# Match entry for Dell Switch BMP image {{ image.dest }}. +dhcp-match=set:{{ image.tag }},{{ image.match }} +# Boot entry for Dell Switch BMP image {{ image.dest }}. +dhcp-boot=tag:{{ image.tag }},{{ dell_switch_bmp_http_base_url }}/{{ image.dest | basename }} + +{% endfor %} diff --git a/etc/kayobe/dell-switch-bmp.yml b/etc/kayobe/dell-switch-bmp.yml new file mode 100644 index 000000000..33e04f34e --- /dev/null +++ b/etc/kayobe/dell-switch-bmp.yml @@ -0,0 +1,14 @@ +--- +# Dell Switch Bare Metal Provisioning (BMP) configuration. + +# List of images to provide a BMP configuration for. +# Each item should be a dict with the following keys: +# url: URL of the image to download. +# dest: Name of the file to download the image to. +# match: dnsmasq match rule to match hosts against. +# tag: dnsmasq tag to apply to matching hosts. +#dell_switch_bmp_images: + +############################################################################### +# Dummy variable to allow Ansible to accept this file. +workaround_ansible_issue_8743: yes diff --git a/kayobe/cli/commands.py b/kayobe/cli/commands.py index e3a17667f..ef1b282b5 100644 --- a/kayobe/cli/commands.py +++ b/kayobe/cli/commands.py @@ -193,7 +193,9 @@ class SeedServiceDeploy(KollaAnsibleMixin, KayobeAnsibleMixin, Command): self.app.LOG.debug("Deploying seed services") ansible.run_playbook(parsed_args, "ansible/kolla-bifrost.yml") kolla_ansible.run_seed(parsed_args, "deploy-bifrost") - ansible.run_playbook(parsed_args, "ansible/seed-introspection-rules.yml") + playbooks = _build_playbook_list( + "seed-introspection-rules", "dell-switch-bmp") + ansible.run_playbooks(parsed_args, playbooks) class SeedContainerImageBuild(KayobeAnsibleMixin, Command):