Cleanup yaml files for molecule lint

This commit is contained in:
Till Maas 2019-04-25 10:31:09 +02:00
parent a2380ece03
commit 0c59fe1c6a
7 changed files with 49 additions and 23 deletions

View file

@ -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

View file

@ -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'] }}"

View file

@ -1,11 +1,19 @@
# SPDX-License-Identifier: BSD-3-Clause
---
galaxy_info:
author: Thomas Haller <thaller@redhat.com>, Till Maas <till@redhat.com>
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:

View file

@ -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():

View file

@ -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''

View file

@ -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''

View file

@ -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''