Add kayobe CLI command to configure the physical network
Currently this can configure interfaces on DellOS6 switches only but can be extended to support other makes and models.
This commit is contained in:
parent
4652c29706
commit
3ca08afd93
15
ansible/group_vars/switches/dell
Normal file
15
ansible/group_vars/switches/dell
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
# Switch configuration.
|
||||
|
||||
###############################################################################
|
||||
# Authentication configuration.
|
||||
|
||||
# For DellOS6 switches, this defines a 'provider' argument to the dellos6_*
|
||||
# modules.
|
||||
switch_dellos6_provider:
|
||||
host: "{{ ansible_host }}"
|
||||
username: "{{ ansible_user }}"
|
||||
password: "{{ ansible_ssh_pass }}"
|
||||
transport: cli
|
||||
authorize: yes
|
||||
auth_pass: "{{ switch_auth_pass }}"
|
7
ansible/group_vars/switches/type
Normal file
7
ansible/group_vars/switches/type
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
###############################################################################
|
||||
# Switch type configuration.
|
||||
|
||||
# This configures the type of switch, which is used to determine how the switch
|
||||
# will be configured.
|
||||
switch_type:
|
@ -1,23 +0,0 @@
|
||||
---
|
||||
- name: Ensure the power and management network switches are configured
|
||||
hosts: mgmt-switches
|
||||
gather_facts: no
|
||||
vars:
|
||||
provider:
|
||||
host: "{{ ansible_host }}"
|
||||
username: "{{ ansible_user }}"
|
||||
password: "{{ ansible_ssh_pass }}"
|
||||
transport: cli
|
||||
authorize: yes
|
||||
auth_pass: "{{ switch_auth_pass }}"
|
||||
tasks:
|
||||
- name: Ensure switch interfaces are configured
|
||||
local_action:
|
||||
module: dellos6_config
|
||||
provider: "{{ provider }}"
|
||||
lines: >
|
||||
{{ ['description ' ~ item.value.description] +
|
||||
item.value.config | default([]) }}
|
||||
parents:
|
||||
- "interface {{ item.key }}"
|
||||
with_dict: "{{ switch_interface_config }}"
|
26
ansible/physical-network.yml
Normal file
26
ansible/physical-network.yml
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
# Switch configuration depends on the type of switch, so groups hosts by their
|
||||
# switch type and apply tasks/roles to the relevant groups.
|
||||
|
||||
- name: Group hosts by their switch type
|
||||
hosts: switches
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Group hosts by their switch type
|
||||
group_by:
|
||||
key: "switches_of_type_{{ switch_type }}"
|
||||
|
||||
- name: Ensure DellOS6 physical network devices are configured
|
||||
hosts: switches_of_type_dellos6
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Ensure DellOS6 switch interfaces are configured
|
||||
local_action:
|
||||
module: dellos6_config
|
||||
provider: "{{ switch_dellos6_provider }}"
|
||||
lines: >
|
||||
{{ ['description ' ~ item.value.description] +
|
||||
item.value.config | default([]) }}
|
||||
parents:
|
||||
- "interface {{ item.key }}"
|
||||
with_dict: "{{ switch_interface_config }}"
|
@ -127,6 +127,23 @@ class KollaAnsibleRun(KollaAnsibleMixin, Command):
|
||||
parsed_args.kolla_inventory_filename)
|
||||
|
||||
|
||||
class PhysicalNetworkConfigure(KayobeAnsibleMixin, Command):
|
||||
"""Configure a set of physical network devices."""
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(PhysicalNetworkConfigure, self).get_parser(
|
||||
prog_name)
|
||||
group = parser.add_argument_group("Physical Networking")
|
||||
group.add_argument("--group", required=True,
|
||||
help="the Ansible group to apply configuration to")
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.app.LOG.debug("Configuring a physical network")
|
||||
ansible.run_playbook(parsed_args, "ansible/physical-network.yml",
|
||||
limit=parsed_args.group)
|
||||
|
||||
|
||||
class SeedVMProvision(KollaAnsibleMixin, KayobeAnsibleMixin, Command):
|
||||
"""Provision the seed VM."""
|
||||
|
||||
|
1
setup.py
1
setup.py
@ -44,6 +44,7 @@ setup(
|
||||
'overcloud_inventory_discover = kayobe.cli.commands:OvercloudInventoryDiscover',
|
||||
'overcloud_service_deploy = kayobe.cli.commands:OvercloudServiceDeploy',
|
||||
'overcloud_provision = kayobe.cli.commands:OvercloudProvision',
|
||||
'physical_network_configure = kayobe.cli.commands:PhysicalNetworkConfigure',
|
||||
'playbook_run = kayobe.cli.commands:PlaybookRun',
|
||||
'seed_container_image_build = kayobe.cli.commands:SeedContainerImageBuild',
|
||||
'seed_host_configure = kayobe.cli.commands:SeedHostConfigure',
|
||||
|
Loading…
Reference in New Issue
Block a user