From 13a14664f93813b10258776b4c951430bf76e322 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Tue, 17 Oct 2017 11:43:53 +0000 Subject: [PATCH] Add a --display argument to kayobe physical network configure This will output the candidate configuration, without applying it. --- ansible/physical-network.yml | 23 +++++++++++++++++++++-- doc/source/deployment.rst | 3 +++ doc/source/release-notes.rst | 2 ++ kayobe/cli/commands.py | 4 ++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ansible/physical-network.yml b/ansible/physical-network.yml index 7789b3c35..cb81c89c6 100644 --- a/ansible/physical-network.yml +++ b/ansible/physical-network.yml @@ -16,6 +16,9 @@ # to configure in order to restrict configuration to a subset of # interfaces. physical_network_interface_description_limit: '' + # Set this variable to True in order to display the candidate switch + # configuration and exit without applying it. + physical_network_display: False tasks: - name: Fail if both interface name and description limits are specified fail: @@ -30,6 +33,10 @@ group_by: key: "switches_of_type_{{ switch_type }}" + - name: Group hosts by whether display mode is set + group_by: + key: "switches_in_display_mode_{{ physical_network_display | bool }}" + - name: Add discovery interface configuration when performing discovery set_fact: switch_interface_config: > @@ -50,8 +57,20 @@ switch_interface_config_select_description(physical_network_interface_description_limit.split(",")) }} when: physical_network_interface_description_limit != '' +- name: Display switch configuration + hosts: switches_in_display_mode_True + gather_facts: no + tasks: + - name: Display the candidate global switch configuration + debug: + var: switch_config + + - name: Display the candidate switch interface configuration + debug: + var: switch_interface_config + - name: Ensure DellOS physical switches are configured - hosts: switches_of_type_dellos6:switches_of_type_dellos9 + hosts: switches_of_type_dellos6:switches_of_type_dellos9:&switches_in_display_mode_False gather_facts: no roles: - role: ssh-known-host @@ -63,7 +82,7 @@ dell_switch_interface_config: "{{ switch_interface_config }}" - name: Ensure Juniper physical switches are configured - hosts: switches_of_type_junos + hosts: switches_of_type_junos:&switches_in_display_mode_False gather_facts: no roles: - role: ssh-known-host diff --git a/doc/source/deployment.rst b/doc/source/deployment.rst index d722c6223..99b489189 100644 --- a/doc/source/deployment.rst +++ b/doc/source/deployment.rst @@ -50,6 +50,9 @@ The names or descriptions should be separated by commas. This may be useful when adding compute nodes to an existing deployment, in order to avoid changing the configuration interfaces in use by active nodes. +The ``display`` argument will display the candidate switch configuration, +without actually applying it. + Seed Hypervisor =============== diff --git a/doc/source/release-notes.rst b/doc/source/release-notes.rst index 535f8066b..bf91f98da 100644 --- a/doc/source/release-notes.rst +++ b/doc/source/release-notes.rst @@ -11,6 +11,8 @@ Features * Adds ``--interface-limit`` and ``--interface-description-limit`` arguments to the ``kayobe physical network configure`` command. These arguments allow configuration to be limited to a subset of switch interfaces. +* Adds a ``display`` argument to ``kayobe physical network configure`` command. + This will output the candidate switch configuration without applying it. Upgrade Notes ------------- diff --git a/kayobe/cli/commands.py b/kayobe/cli/commands.py index d31a124e0..e83be4fd0 100644 --- a/kayobe/cli/commands.py +++ b/kayobe/cli/commands.py @@ -227,6 +227,9 @@ class PhysicalNetworkConfigure(KayobeAnsibleMixin, VaultMixin, Command): group = parser.add_argument_group("Physical Networking") group.add_argument("--group", required=True, help="the Ansible group to apply configuration to") + group.add_argument("--display", action="store_true", + help="display the candidate configuration and exit " + "without applying it") group.add_argument("--enable-discovery", action="store_true", help="configure the network for hardware discovery") group.add_argument("--interface-limit", @@ -240,6 +243,7 @@ class PhysicalNetworkConfigure(KayobeAnsibleMixin, VaultMixin, Command): def take_action(self, parsed_args): self.app.LOG.debug("Configuring a physical network") extra_vars = {} + extra_vars["physical_network_display"] = parsed_args.display if parsed_args.enable_discovery: extra_vars["physical_network_enable_discovery"] = True if parsed_args.interface_limit: