diff --git a/.travis.yml b/.travis.yml index 571e66d..516b00f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ matrix: - python: 3.7 - python: 3.7-dev - python: 3.8-dev - - nightly + # - python: nightly install: - pip install tox tox-travis diff --git a/defaults/main.yml b/defaults/main.yml index 9c9d9c4..e5c8c6f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,11 +1,19 @@ # SPDX-License-Identifier: BSD-3-Clause -network_connections: [] +--- +network_connections: [] # Use initscripts for RHEL/CentOS < 7, nm otherwise -network_provider_os_default: "{{ 'initscripts' if ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('7', '<') else 'nm' }}" +network_provider_os_default: "{{ + 'initscripts' if ansible_distribution in ['RedHat', 'CentOS'] and + ansible_distribution_major_version is version('7', '<') + else 'nm' }}" # If NetworkManager.service is running, assume that 'nm' is currently in-use, # otherwise initscripts -network_provider_current: "{{ 'nm' if 'NetworkManager.service' in ansible_facts.services and ansible_facts.services['NetworkManager.service']['state'] == 'running' else 'initscripts' }}" +network_provider_current: "{{ + 'nm' if 'NetworkManager.service' in ansible_facts.services and + ansible_facts.services['NetworkManager.service']['state'] == 'running' + else 'initscripts' + }}" # Default to the auto-detected value network_provider: "{{ network_provider_current }}" @@ -15,7 +23,10 @@ network_provider: "{{ network_provider_current }}" # - python-gobject-base or python2-gobject-base on Fedora 27 # - python3-gobject-base on Fedora 28+ network_service_name_default_nm: NetworkManager -network_packages_default_nm: [ ethtool, NetworkManager, "python{{ ansible_python['version']['major'] | replace('2', '') }}-gobject-base"] +network_packages_default_nm: + - ethtool + - NetworkManager + - "python{{ ansible_python['version']['major'] | replace('2', '') }}-gobject-base" network_service_name_default_initscripts: network @@ -33,7 +44,8 @@ if (ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_ %}initscripts{% else %}network-scripts{% endif %}"] # convert _network_packages_default_initscripts_bridge to an empty list if it # contains only the empty string and add it to the default package list -# |select() filters the list to include only values that evalueate to true (the empty string is false) +# |select() filters the list to include only values that evaluate to true +# (the empty string is false) # |list() converts the generator that |select() creates to a list network_packages_default_initscripts: "{{ ['ethtool'] + _network_packages_default_initscripts_bridge|select()|list() @@ -57,12 +69,14 @@ network_packages_default_initscripts: "{{ ['ethtool'] # apply. These values are hard-coded in this file, but they also could # be overwritten as host variables or via vars/*.yml. _network_provider_setup: - nm: - service_name: "{{ network_service_name_default_nm }}" - packages: "{{ network_packages_default_nm }}" - initscripts: - service_name: "{{ network_service_name_default_initscripts }}" - packages: "{{ network_packages_default_initscripts }}" + nm: + service_name: "{{ network_service_name_default_nm }}" + packages: "{{ network_packages_default_nm }}" + initscripts: + service_name: "{{ network_service_name_default_initscripts }}" + packages: "{{ network_packages_default_initscripts }}" -network_packages: "{{ _network_provider_setup[network_provider]['packages'] }}" -network_service_name: "{{ _network_provider_setup[network_provider]['service_name'] }}" +network_packages: "{{ + _network_provider_setup[network_provider]['packages'] }}" +network_service_name: "{{ + _network_provider_setup[network_provider]['service_name'] }}" diff --git a/meta/main.yml b/meta/main.yml index 7229b0d..b350d57 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,11 +1,19 @@ # SPDX-License-Identifier: BSD-3-Clause +--- galaxy_info: author: Thomas Haller , Till Maas description: Configure networking company: Red Hat, Inc. license: BSD-3-Clause min_ansible_version: 2.5 - galaxy_tags: [ 'system', 'network', 'networking', 'redhat', 'rhel', 'fedora', 'centos' ] + galaxy_tags: + - centos + - fedora + - network + - networking + - redhat + - rhel + - system platforms: - name: Fedora versions: diff --git a/tests/ensure_non_running_provider.py b/tests/ensure_non_running_provider.py index 33776c0..c6a6eef 100755 --- a/tests/ensure_non_running_provider.py +++ b/tests/ensure_non_running_provider.py @@ -28,7 +28,8 @@ OTHER_PLAYBOOK = """ service_facts: - name: Set network provider set_fact: - network_provider: "{{{{ 'initscripts' if network_provider_current == 'nm' else 'nm' }}}}" + network_provider: '{{{{ "initscripts" if network_provider_current == "nm" + else "nm" }}}}' - import_playbook: "{tests_playbook}" when: @@ -47,7 +48,7 @@ def generate_nominal_other_playbook(tests_playbook): nominal_other_testfile_data = OTHER_PLAYBOOK.format(tests_playbook=tests_playbook) nominal = yaml.safe_load(nominal_other_testfile_data) nominal[0]["vars"]["network_provider_current"] = get_current_provider_code() - return yaml.dump(nominal, default_flow_style=False) + return yaml.dump(nominal, default_flow_style=False, explicit_start=True, width=80) def main(): diff --git a/tests/tests_bridge_other_provider.yml b/tests/tests_bridge_other_provider.yml index efec9bd..e5a4ad7 100644 --- a/tests/tests_bridge_other_provider.yml +++ b/tests/tests_bridge_other_provider.yml @@ -1,3 +1,4 @@ +--- - hosts: all name: Run playbook 'tests_bridge.yml' with non-default provider tasks: @@ -5,8 +6,8 @@ service_facts: null - name: Set network provider set_fact: - network_provider: '{{ ''initscripts'' if network_provider_current == ''nm'' - else ''nm'' }}' + network_provider: '{{ "initscripts" if network_provider_current == "nm" else + "nm" }}' vars: network_provider_current: '{{ ''nm'' if ''NetworkManager.service'' in ansible_facts.services and ansible_facts.services[''NetworkManager.service''][''state''] == ''running'' diff --git a/tests/tests_default_other_provider.yml b/tests/tests_default_other_provider.yml index 88f4089..697bc57 100644 --- a/tests/tests_default_other_provider.yml +++ b/tests/tests_default_other_provider.yml @@ -1,3 +1,4 @@ +--- - hosts: all name: Run playbook 'tests_default.yml' with non-default provider tasks: @@ -5,8 +6,8 @@ service_facts: null - name: Set network provider set_fact: - network_provider: '{{ ''initscripts'' if network_provider_current == ''nm'' - else ''nm'' }}' + network_provider: '{{ "initscripts" if network_provider_current == "nm" else + "nm" }}' vars: network_provider_current: '{{ ''nm'' if ''NetworkManager.service'' in ansible_facts.services and ansible_facts.services[''NetworkManager.service''][''state''] == ''running'' diff --git a/tests/tests_ethernet_other_provider.yml b/tests/tests_ethernet_other_provider.yml index 1cf4acb..456b052 100644 --- a/tests/tests_ethernet_other_provider.yml +++ b/tests/tests_ethernet_other_provider.yml @@ -1,3 +1,4 @@ +--- - hosts: all name: Run playbook 'tests_ethernet.yml' with non-default provider tasks: @@ -5,8 +6,8 @@ service_facts: null - name: Set network provider set_fact: - network_provider: '{{ ''initscripts'' if network_provider_current == ''nm'' - else ''nm'' }}' + network_provider: '{{ "initscripts" if network_provider_current == "nm" else + "nm" }}' vars: network_provider_current: '{{ ''nm'' if ''NetworkManager.service'' in ansible_facts.services and ansible_facts.services[''NetworkManager.service''][''state''] == ''running''