Merge branch 'master' into kolla-build-config-path

This commit is contained in:
Mark Goddard
2017-10-25 09:39:59 +01:00
committed by GitHub
30 changed files with 327 additions and 72 deletions

View File

@@ -15,6 +15,22 @@
import six
def switch_interface_config_select_name(switch_interface_config, names):
"""Select and return all switch interfaces matching requested names.
:param switch_interface_config: Switch interface configuration dict
:param names: String or list of strings - interface names to match
"""
if isinstance(names, six.string_types):
names = [names]
return {
name: config
for name, config in switch_interface_config.items()
if name in names
}
def switch_interface_config_select_description(switch_interface_config, descriptions):
"""Select and return all switch interfaces matching requested descriptions.
@@ -32,10 +48,27 @@ def switch_interface_config_select_description(switch_interface_config, descript
}
def switch_interface_config_select_trunk(switch_interface_config):
"""Select and return all switch interfaces which are trunk links.
Interfaces are assumed to be trunked, unless they have a ngs_trunk_port
item which is set to False.
:param switch_interface_config: Switch interface configuration dict
"""
return {
name: config
for name, config in switch_interface_config.items()
if config.get('ngs_trunk_port', True)
}
class FilterModule(object):
"""Switch filters."""
def filters(self):
return {
'switch_interface_config_select_name': switch_interface_config_select_name,
'switch_interface_config_select_description': switch_interface_config_select_description,
'switch_interface_config_select_trunk': switch_interface_config_select_trunk,
}

View File

@@ -13,8 +13,8 @@ controller_bootstrap_user: "{{ lookup('env', 'USER') }}"
controller_network_interfaces: >
{{ (controller_default_network_interfaces +
controller_extra_network_interfaces +
controller_network_host_network_interfaces
if inventory_hostname in groups['network'] else []) | unique | list }}
(controller_network_host_network_interfaces
if inventory_hostname in groups['network'] else [])) | unique | list }}
# List of default networks to which controller nodes are attached.
controller_default_network_interfaces: >

View File

@@ -58,7 +58,7 @@ inspector_ipmi_password: "{{ ipmi_password }}"
# Ironic inspector default network interface name on which to check for an LLDP
# switch port description to use as the node's name.
inspector_lldp_switch_port_interface_default:
inspector_lldp_switch_port_interface_default: eth0
# Ironic inspector map from hostname to network interface name on which to
# check for an LLDP switch port description to use as the node's name.

View File

@@ -236,12 +236,14 @@ kolla_openstack_logging_debug: "False"
kolla_enable_barbican: "no"
kolla_enable_glance: "yes"
kolla_enable_haproxy: "yes"
kolla_enable_heat: "yes"
kolla_enable_ironic: "yes"
kolla_enable_neutron: "yes"
kolla_enable_nova: "yes"
kolla_enable_magnum: "no"
kolla_enable_murano: "no"
kolla_enable_sahara: "no"
kolla_enable_swift: "yes"
kolla_enable_swift: "no"
###############################################################################
# Passwords and credentials.

View File

@@ -59,3 +59,9 @@ kolla_neutron_ml2_generic_switch_hosts: []
# switch_interface_config variable for each switch to determine which
# interfaces should be configured.
kolla_neutron_ml2_generic_switch_trunk_port_hosts: "{{ groups['network'] }}"
# Dict containing additional configuration for switches managed by the
# genericswitch ML2 mechanism driver. For per-switch configuration of switches
# in kolla_neutron_ml2_generic_switch_hosts, this may be set as a group or
# host variable for the switch host.
kolla_neutron_ml2_generic_switch_extra: {}

View File

@@ -134,8 +134,9 @@
'password': hostvars[item].ansible_ssh_pass,
'ngs_trunk_ports': (
hostvars[item].switch_interface_config |
switch_interface_config_select_description(kolla_neutron_ml2_generic_switch_trunk_port_hosts)).keys() | join(',')
}]
switch_interface_config_select_description(kolla_neutron_ml2_generic_switch_trunk_port_hosts) |
switch_interface_config_select_trunk()).keys() | join(',')
} | combine(hostvars[item].kolla_neutron_ml2_generic_switch_extra) ]
}}
with_items: "{{ kolla_neutron_ml2_generic_switch_hosts }}"
@@ -184,5 +185,4 @@
kolla_extra_neutron_ml2: "{{ kolla_extra_config.neutron_ml2 | default }}"
kolla_extra_nova: "{{ kolla_extra_config.nova | default }}"
kolla_extra_sahara: "{{ kolla_extra_config.sahara | default }}"
kolla_extra_glance_path: "{{ kayobe_config_path }}/kolla/config/glance"
kolla_extra_fluentd_output_path: "{{ kayobe_config_path }}/kolla/config/fluentd/output"
kolla_extra_config_path: "{{ kayobe_config_path }}/kolla/config"

View File

@@ -35,6 +35,7 @@
bash -c '. env-vars &&
export OS_URL=$IRONIC_URL &&
export OS_TOKEN=$OS_AUTH_TOKEN &&
export OS_BAREMETAL_API_VERSION=1.34 &&
export BIFROST_INVENTORY_SOURCE=ironic &&
ansible baremetal
--connection local
@@ -94,6 +95,7 @@
bash -c '. env-vars &&
export OS_URL=$IRONIC_URL &&
export OS_TOKEN=$OS_AUTH_TOKEN &&
export OS_BAREMETAL_API_VERSION=1.34 &&
export BIFROST_INVENTORY_SOURCE=ironic &&
ansible baremetal
--connection local

View File

@@ -49,6 +49,6 @@
# These variables may be referenced in the introspection rules.
inspector_rule_var_ipmi_username: "{{ inspector_ipmi_username }}"
inspector_rule_var_ipmi_password: "{{ inspector_ipmi_password }}"
inspector_rule_var_lldp_switch_port_interface: "{{ inspector_lldp_switch_port_interface_default or '' }}"
inspector_rule_var_lldp_switch_port_interface: "{{ inspector_lldp_switch_port_interface_default }}"
inspector_rule_var_deploy_kernel: "{{ ipa_kernel_id.stdout }}"
inspector_rule_var_deploy_ramdisk: "{{ ipa_ramdisk_id.stdout }}"

View File

@@ -38,6 +38,7 @@
bash -c '. env-vars &&
export OS_URL=$IRONIC_URL &&
export OS_TOKEN=$OS_AUTH_TOKEN &&
export OS_BAREMETAL_API_VERSION=1.34 &&
export BIFROST_INVENTORY_SOURCE=ironic &&
ansible baremetal
--connection local
@@ -127,6 +128,7 @@
docker exec bifrost_deploy
bash -c '. env-vars &&
export BIFROST_INVENTORY_SOURCE=ironic &&
export OS_BAREMETAL_API_VERSION=1.34 &&
ansible-playbook -vvvv
/bifrost/playbooks/deploy-dynamic.yaml
--inventory /etc/bifrost/inventory/
@@ -149,6 +151,7 @@
bash -c '. env-vars &&
export OS_URL=$IRONIC_URL &&
export OS_TOKEN=$OS_AUTH_TOKEN &&
export OS_BAREMETAL_API_VERSION=1.34 &&
export BIFROST_INVENTORY_SOURCE=ironic &&
ansible baremetal
--connection local

View File

@@ -2,25 +2,75 @@
# 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
- name: Group hosts by their switch type and apply configuration filters
hosts: switches
gather_facts: no
vars:
# Set this variable to True to configure of network for hardware discovery.
# Set this variable to True to configure the network for hardware
# discovery.
physical_network_enable_discovery: False
# Set this variable to a comma-separated list of names of interfaces to
# configure in order to restrict configuration to a subset of interfaces.
physical_network_interface_limit: ''
# Set this variable to a comma-separated list of descriptions of interfaces
# 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:
msg: >
The interface name and interface description limits are mutually
exclusive.
when:
- physical_network_interface_limit != ''
- physical_network_interface_description_limit != ''
- name: Group hosts by their switch type
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: >
{{ switch_interface_config | combine(switch_interface_config_discovery) }}
when: "{{ physical_network_enable_discovery | bool }}"
- name: Restrict switch interfaces to requested subset by name
set_fact:
switch_interface_config: >
{{ switch_interface_config |
switch_interface_config_select_name(physical_network_interface_limit.split(",")) }}
when: physical_network_interface_limit != ''
- name: Restrict switch interfaces to requested subset by description
set_fact:
switch_interface_config: >
{{ switch_interface_config |
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
@@ -32,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

View File

@@ -30,4 +30,4 @@ docker_registry_tag: "latest"
docker_registry_image_full: "{{ docker_registry_image }}:{{ docker_registry_tag }}"
docker_registry_restart_policy: "unless-stopped"
docker_registry_restart_retries: 10
#docker_registry_restart_retries:

View File

@@ -7,7 +7,7 @@
privileged: "{{ item.value.privileged | default(omit) }}"
read_only: "{{ item.value.read_only | default(omit) }}"
restart_policy: "{{ docker_registry_restart_policy }}"
restart_retries: "{{ docker_registry_restart_retries }}"
restart_retries: "{{ docker_registry_restart_retries | default(omit) }}"
state: "{{ (item.value.enabled and action != 'destroy') | ternary('started', 'absent') }}"
volumes: "{{ item.value.volumes }}"
with_dict: "{{ docker_registry_services }}"

View File

@@ -34,4 +34,4 @@ inspection_store_tag: "latest"
inspection_store_image_full: "{{ inspection_store_image }}:{{ inspection_store_tag }}"
inspection_store_restart_policy: "unless-stopped"
inspection_store_restart_retries: 10
#inspection_store_restart_retries:

View File

@@ -7,7 +7,7 @@
privileged: "{{ item.value.privileged | default(omit) }}"
read_only: "{{ item.value.read_only | default(omit) }}"
restart_policy: "{{ inspection_store_restart_policy }}"
restart_retries: "{{ inspection_store_restart_retries }}"
restart_retries: "{{ inspection_store_restart_retries | default(omit) }}"
state: "{{ item.value.enabled | ternary('started', 'absent') }}"
volumes: "{{ item.value.volumes }}"
with_dict: "{{ inspection_store_services }}"

View File

@@ -1,13 +1,10 @@
---
# Path to extra kolla-ansible configuration files.
kolla_extra_config_path:
# Directory where Kolla custom configuration files will be installed.
kolla_node_custom_config_path:
###############################################################################
# Fluentd configuration.
# Path to extra Fluentd output configuration files.
kolla_extra_fluentd_output_path:
###############################################################################
# Glance configuration.
@@ -269,3 +266,9 @@ kolla_enable_sahara:
# Free form extra configuration to append to sahara.conf.
kolla_extra_sahara:
###############################################################################
# Swift configuration.
# Whether to enable swift.
kolla_enable_swift:

View File

@@ -1,16 +1,11 @@
---
- name: Ensure the Kolla OpenStack configuration directores exist
file:
path: "{{ kolla_node_custom_config_path }}/{{ item.name }}"
path: "{{ item.dest }}"
state: directory
mode: 0750
with_items:
- { name: fluentd/output, enabled: "{{ kolla_extra_fluentd_output_path != None }}" }
- { name: ironic, enabled: "{{ kolla_enable_ironic }}" }
- { name: neutron, enabled: "{{ kolla_enable_neutron }}" }
- { name: swift, enabled: "{{ kolla_enable_swift }}" }
- { name: glance, enabled: "{{ kolla_enable_glance }}" }
when: "{{ item.enabled | bool }}"
with_items: "{{ kolla_openstack_custom_config }}"
when: item.enabled | bool
- name: Ensure the Kolla OpenStack configuration files exist
template:
@@ -29,25 +24,7 @@
- { src: nova.conf.j2, dest: nova.conf, enabled: "{{ kolla_enable_nova }}" }
- { src: pxelinux.default.j2, dest: ironic/pxelinux.default, enabled: "{{ kolla_enable_ironic }}" }
- { src: sahara.conf.j2, dest: sahara.conf, enabled: "{{ kolla_enable_sahara }}" }
when: "{{ item.enabled | bool }}"
- name: Ensure extra glance configuration files exist
template:
src: "{{ item }}"
dest: "{{ kolla_node_custom_config_path }}/glance/{{ item | basename }}"
mode: 0640
with_fileglob:
- "{{ kolla_extra_glance_path }}/*"
when: "{{ kolla_extra_glance_path != None }}"
- name: Ensure extra fluentd output configuration files exist
template:
src: "{{ item }}"
dest: "{{ kolla_node_custom_config_path }}/fluentd/output/{{ item | basename }}"
mode: 0640
with_fileglob:
- "{{ kolla_extra_fluentd_output_path }}/*.conf"
when: "{{ kolla_extra_fluentd_output_path != None }}"
when: item.enabled | bool
- name: Ensure the ironic inspector kernel and ramdisk are downloaded
get_url:
@@ -72,3 +49,51 @@
when:
- kolla_enable_ironic | bool
- item.path != None
# We support a fairly flexible mechanism of dropping config file templates into
# an 'extra' config directory, and passing these through to kolla-ansible. We
# look for matching files in the source directory to template, and also remove
# any unexpected files from the destination, to support removal of files.
- name: Find extra configuration files
find:
path: "{{ item.src }}"
patterns: "{{ item.patterns }}"
with_items: "{{ kolla_openstack_custom_config }}"
register: find_src_result
- name: Find previously generated extra configuration files
find:
path: "{{ item.dest }}"
patterns: "{{ item.patterns }}"
with_items: "{{ kolla_openstack_custom_config }}"
register: find_dest_result
- name: Ensure extra configuration files exist
template:
src: "{{ item.1.path }}"
dest: "{{ item.0.item.dest }}/{{ item.1.path | basename }}"
mode: 0640
with_subelements:
- "{{ find_src_result.results }}"
- files
- skip_missing: True
when: item.0.item.enabled | bool
- name: Ensure unnecessary extra configuration files are absent
file:
path: "{{ item.1.path }}"
state: absent
with_subelements:
- "{{ find_dest_result.results }}"
- files
- skip_missing: True
when:
- not item.0.item.enabled or
item.1.path | basename not in src_files
- item.1.path | basename not in item.0.item.ignore | default([])
vars:
# Find the source result that corresponds to this one.
src_result: "{{ (find_src_result.results | selectattr('item', 'equalto', item.0.item) | list)[0] }}"
# Find the list of files in the source.
src_files: "{{ src_result.files | map(attribute='path') | map('basename') | list }}"

View File

@@ -28,9 +28,11 @@ key_file = {{ switch.key_file }}
{% if switch.secret is defined %}
secret = {{ switch.secret }}
{% endif %}
{% if switch.ngs_trunk_ports is defined %}
ngs_trunk_ports = {{ switch.ngs_trunk_ports }}
{% for key, value in switch.items() %}
{% if key.startswith('ngs_') %}
{{ key }} = {{ value }}
{% endif %}
{% endfor %}
{% endfor %}

View File

@@ -1,22 +1,5 @@
# {{ ansible_managed }}
[DEFAULT]
{% if kolla_enable_ironic | bool %}
# Taken from the ironic configuration guide.
# Flag to decide whether to use baremetal_scheduler_default_filters or not.
# (boolean value)
scheduler_use_baremetal_filters=True
# Determines if the Scheduler tracks changes to instances to help with
# its filtering decisions (boolean value)
scheduler_tracks_instance_changes=False
# For ironic, this should be set to a number >= the number of ironic nodes
# to more evenly distribute instances across the nodes.
scheduler_host_subset_size=9999999
{% endif %}
{% if kolla_extra_nova %}
#######################
# Extra configuration

View File

@@ -0,0 +1,79 @@
---
# List of custom configuration directories.
# Each item is a dict containing the following items:
# src: Path to directory containing configuration file templates.
# dest: Path to directory in which generated files will be created.
# patterns: One or more file name patterns to match.
# enabled: Whether these files should be templated.
# ignore: Optional list of files to leave in the destination, even if disabled
# or unexpected.
kolla_openstack_custom_config:
# Fluentd filters.
- src: "{{ kolla_extra_config_path }}//fluentd/filter"
dest: "{{ kolla_node_custom_config_path }}/fluentd/filter"
patterns: "*.conf"
enabled: True
# Fluentd outputs.
- src: "{{ kolla_extra_config_path }}/fluentd/output"
dest: "{{ kolla_node_custom_config_path }}/fluentd/output"
patterns: "*.conf"
enabled: True
# Glance.
- src: "{{ kolla_extra_config_path }}/glance"
dest: "{{ kolla_node_custom_config_path }}/glance"
patterns: "*"
enabled: "{{ kolla_enable_glance }}"
# Heat.
- src: "{{ kolla_extra_config_path }}/heat"
dest: "{{ kolla_node_custom_config_path }}/heat"
patterns: "*"
enabled: "{{ kolla_enable_heat }}"
# Ironic.
- src: "{{ kolla_extra_config_path }}/ironic"
dest: "{{ kolla_node_custom_config_path }}/ironic"
patterns: "*"
enabled: "{{ kolla_enable_ironic }}"
ignore:
# These are templated by kayobe, so don't remove them.
- ironic-agent.initramfs
- ironic-agent.kernel
- ironic-dnsmasq.conf
- pxelinux.default
# Keystone.
- src: "{{ kolla_extra_config_path }}/keystone"
dest: "{{ kolla_node_custom_config_path }}/keystone"
patterns: "*"
enabled: True
# Magnum.
- src: "{{ kolla_extra_config_path }}/magnum"
dest: "{{ kolla_node_custom_config_path }}/magnum"
patterns: "*"
enabled: "{{ kolla_enable_magnum }}"
# Murano.
- src: "{{ kolla_extra_config_path }}/murano"
dest: "{{ kolla_node_custom_config_path }}/murano"
patterns: "*"
enabled: "{{ kolla_enable_murano }}"
# Neutron.
- src: "{{ kolla_extra_config_path }}/neutron"
dest: "{{ kolla_node_custom_config_path }}/neutron"
patterns: "*"
enabled: "{{ kolla_enable_neutron }}"
ignore:
# These are templated by kayobe, so don't remove them.
- ml2_conf.ini
# Nova.
- src: "{{ kolla_extra_config_path }}/nova"
dest: "{{ kolla_node_custom_config_path }}/nova"
patterns: "*"
enabled: "{{ kolla_enable_nova }}"
# Sahara.
- src: "{{ kolla_extra_config_path }}/sahara"
dest: "{{ kolla_node_custom_config_path }}/sahara"
patterns: "*"
enabled: "{{ kolla_enable_sahara }}"
# Swift.
- src: "{{ kolla_extra_config_path }}/swift"
dest: "{{ kolla_node_custom_config_path }}/swift"
patterns: "*"
enabled: "{{ kolla_enable_swift }}"

View File

@@ -27,4 +27,4 @@ opensm_tag: "latest"
opensm_image_full: "{{ opensm_image }}:{{ opensm_tag }}"
opensm_restart_policy: "unless-stopped"
opensm_restart_retries: 10
#opensm_restart_retries:

View File

@@ -7,7 +7,7 @@
privileged: "{{ item.value.privileged | default(omit) }}"
read_only: "{{ item.value.read_only | default(omit) }}"
restart_policy: "{{ opensm_restart_policy }}"
restart_retries: "{{ opensm_restart_retries }}"
restart_retries: "{{ opensm_restart_retries | default(omit) }}"
state: "{{ (item.value.enabled and action != 'destroy') | ternary('started', 'absent') }}"
volumes: "{{ item.value.volumes }}"
with_dict: "{{ opensm_services }}"

View File

@@ -12,6 +12,6 @@
# These variables may be referenced in the introspection rules.
inspector_rule_var_ipmi_username: "{{ kolla_bifrost_inspector_ipmi_username }}"
inspector_rule_var_ipmi_password: "{{ kolla_bifrost_inspector_ipmi_password }}"
inspector_rule_var_lldp_switch_port_interface: "{{ kolla_bifrost_inspector_lldp_switch_port_interface or '' }}"
inspector_rule_var_lldp_switch_port_interface: "{{ kolla_bifrost_inspector_lldp_switch_port_interface }}"
inspector_rule_var_deploy_kernel: "{{ kolla_bifrost_inspector_deploy_kernel }}"
inspector_rule_var_deploy_ramdisk: "{{ kolla_bifrost_inspector_deploy_ramdisk }}"

View File

@@ -40,6 +40,19 @@ The ``--enable-discovery`` argument enables a one-time configuration of ports
attached to baremetal compute nodes to support hardware discovery via ironic
inspector.
It is possible to limit the switch interfaces that will be configured, either
by interface name or interface description::
(kayobe) $ kayobe physical network configure --group <group> --interface-limit <interface names>
(kayobe) $ kayobe physical network configure --group <group> --interface-description-limit <interface descriptions>
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
===============

View File

@@ -5,6 +5,19 @@ Release Notes
In Development
==============
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.
* Adds support for configuration of custom fluentd filters, and additional
config file templates for heat, ironic, keystone, magnum, murano, sahara, and
swift in ``$KAYOBE_CONFIG_PATH/kolla/config/<component>/``.
Upgrade Notes
-------------
@@ -12,6 +25,8 @@ Upgrade Notes
to ``True``. Management of the firewall by ironic inspector is important to
ensure that DHCP offers are not made to nodes during provisioning by
inspector's DHCP server.
* Disables swift by default. The default value of ``kolla_enable_swift`` is
now ``no``.
* Adds a variable ``config_path``, used to set the base path to configuration
on remote hosts. The default value is ``/opt/kayobe/etc``.
* Modifies the variable used to configure the kolla build configuration path

View File

@@ -21,6 +21,9 @@
# List of Neutron ML2 extention drivers to use.
#kolla_neutron_ml2_extension_drivers:
###############################################################################
# Neutron ML2 generic switch driver configuration.
# List of switches to configure for use by genericswitch ML2 mechanism driver.
# Each item should be a dict containing the following items:
# name: Hostname of the switch
@@ -43,6 +46,12 @@
# secret: not currently supported
#kolla_neutron_ml2_generic_switch_hosts:
# Dict containing additional configuration for switches managed by the
# genericswitch ML2 mechanism driver. For per-switch configuration of switches
# in kolla_neutron_ml2_generic_switch_hosts, this may be set as a group or
# host variable for the switch host.
#kolla_neutron_ml2_generic_switch_extra:
###############################################################################
# Dummy variable to allow Ansible to accept this file.
workaround_ansible_issue_8743: yes

View File

@@ -55,6 +55,9 @@ def add_args(parser):
parser.add_argument("-l", "--limit", metavar="SUBSET",
help="further limit selected hosts to an additional "
"pattern")
parser.add_argument("--skip-tags", metavar="TAGS",
help="only run plays and tasks whose tags do not match"
"these values")
parser.add_argument("-t", "--tags", metavar="TAGS",
help="only run plays and tasks tagged with these "
"values")
@@ -135,6 +138,8 @@ def build_args(parsed_args, playbooks,
if parsed_args.limit or limit:
limits = [l for l in [parsed_args.limit, limit] if l]
cmd += ["--limit", ":&".join(limits)]
if parsed_args.skip_tags:
cmd += ["--skip-tags", parsed_args.skip_tags]
if parsed_args.tags or tags:
all_tags = [t for t in [parsed_args.tags, tags] if t]
cmd += ["--tags", ",".join(all_tags)]

View File

@@ -227,15 +227,31 @@ 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",
help="limit the switch interfaces to be configured "
"by interface name")
group.add_argument("--interface-description-limit",
help="limit the switch interfaces to be configured "
"by interface description")
return parser
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:
extra_vars["physical_network_interface_limit"] = (
parsed_args.interface_limit)
if parsed_args.interface_description_limit:
extra_vars["physical_network_interface_description_limit"] = (
parsed_args.interface_description_limit)
self.run_kayobe_playbook(parsed_args, "ansible/physical-network.yml",
limit=parsed_args.group,
extra_vars=extra_vars)

View File

@@ -55,6 +55,9 @@ def add_args(parser):
parser.add_argument("-kl", "--kolla-limit", metavar="SUBSET",
help="further limit selected hosts to an additional "
"pattern")
parser.add_argument("--kolla-skip-tags", metavar="TAGS",
help="only run plays and tasks whose tags do not match"
"these values in Kolla Ansible")
parser.add_argument("-kt", "--kolla-tags", metavar="TAGS",
help="only run plays and tasks tagged with these "
"values in Kolla Ansible")
@@ -120,6 +123,8 @@ def build_args(parsed_args, command, inventory_filename, extra_vars=None,
if parsed_args.kolla_limit or limit:
limits = [l for l in [parsed_args.kolla_limit, limit] if l]
cmd += ["--limit", ":&".join(limits)]
if parsed_args.kolla_skip_tags:
cmd += ["--skip-tags", parsed_args.kolla_skip_tags]
if parsed_args.kolla_tags or tags:
all_tags = [t for t in [parsed_args.kolla_tags, tags] if t]
cmd += ["--tags", ",".join(all_tags)]

View File

@@ -109,6 +109,7 @@ class TestCase(unittest.TestCase):
"--extra-vars", "ev_name1=ev_value1",
"--inventory", "/path/to/inventory",
"--limit", "group1:host1",
"--skip-tags", "tag3,tag4",
"--tags", "tag1,tag2",
"--list-tasks",
]
@@ -125,6 +126,7 @@ class TestCase(unittest.TestCase):
"--become",
"--check",
"--limit", "group1:host1",
"--skip-tags", "tag3,tag4",
"--tags", "tag1,tag2",
"playbook1.yml",
"playbook2.yml",

View File

@@ -83,6 +83,7 @@ class TestCase(unittest.TestCase):
"--kolla-extra-vars", "ev_name1=ev_value1",
"--kolla-inventory", "/path/to/inventory",
"--kolla-limit", "host1:host2",
"--kolla-skip-tags", "tag3,tag4",
"--kolla-tags", "tag1,tag2",
]
parsed_args = parser.parse_args(args)
@@ -95,6 +96,7 @@ class TestCase(unittest.TestCase):
"--passwords", "/path/to/config/passwords.yml",
"-e", "ev_name1=ev_value1",
"--limit", "host1:host2",
"--skip-tags", "tag3,tag4",
"--tags", "tag1,tag2",
]
expected_cmd = " ".join(expected_cmd)