Update Cookiecutter role template for newer ansible-lint
Change-Id: I818b25ba4112f8dc3ac30e93eac256558b258ab1
diff --git a/cookiecutters/role/README.md b/cookiecutters/role/README.md
index cfd29e1..b467a50 100644
--- a/cookiecutters/role/README.md
+++ b/cookiecutters/role/README.md
@@ -1,8 +1,3 @@
-<!--
-SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
-SPDX-License-Identifier: Apache-2.0
---!>
-
# Cookiecutter for Ansible roles
Goals of this cookiecutter
diff --git a/cookiecutters/role/cookiecutter.json b/cookiecutters/role/cookiecutter.json
index a5c1aa7..084d103 100644
--- a/cookiecutters/role/cookiecutter.json
+++ b/cookiecutters/role/cookiecutter.json
@@ -3,16 +3,6 @@
"description": "Description for README and Galaxy",
"issue_tracker_url": "https://jira.opennetworking.org/",
- "role_defaults":{
- "example_default1":"example_value1",
- "example_default2":"example_value2"
- },
-
- "platform": "deleteme",
- "platforms":{
- "Ubuntu": ["16.04","18.04"]
- },
-
"author": "Open Networking Foundation",
"email": "support@opennetworking.org",
"company": "Open Networking Foundation",
@@ -20,6 +10,5 @@
"year": "{% now 'utc', '%Y' %}",
"license": ["Apache-2.0", "BSD-2-Clause", "MIT"],
- "min_ansible_version": "2.9.5",
- "molecule_privileged": ["true", "false"]
+ "min_ansible_version": "2.10.7"
}
diff --git a/cookiecutters/role/hooks/post_gen_project.py b/cookiecutters/role/hooks/post_gen_project.py
index c915d1f..438b09e 100644
--- a/cookiecutters/role/hooks/post_gen_project.py
+++ b/cookiecutters/role/hooks/post_gen_project.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-FileCopyrightText: 2020 Open Networking Foundation <support@opennetworking.org>
# SPDX-License-Identifier: Apache-2.0
# role/hooks/post_gen_project.py
@@ -8,11 +8,6 @@
from __future__ import absolute_import
import os
-import jinja2
-
-from cookiecutter import generate as ccg
-from cookiecutter.environment import StrictEnvironment
-import cookiecutter.utils as utils
# Docs for hooks
# https://cookiecutter.readthedocs.io/en/latest/advanced/hooks.html
@@ -38,58 +33,10 @@
def delete_file(filepath):
- """ delete generated file from output directory """
+ """delete generated file from output directory"""
os.remove(os.path.join(PROJECT_DIR, filepath))
-def generate_platforms():
- """ Generate files specific to each platform in platforms dict """
-
- # list all platform tmplated files here
- # {% raw %}
- platform_files = [
- "{{cookiecutter.role_name}}/tasks/{{cookiecutter.platform}}.yml",
- "{{cookiecutter.role_name}}/vars/{{cookiecutter.platform}}.yml",
- ]
- # {% endraw %}
-
- # delete the unneded file generated by platform_files earlier
- env = StrictEnvironment(context={"cookiecutter": CONTEXT})
- for infile in platform_files:
- outfile_tmpl = env.from_string(infile)
- delete_file(outfile_tmpl.render({"cookiecutter": CONTEXT}))
-
- platforms = list(CONTEXT["platforms"].keys()) # pylint: disable=E1136
-
- # Combine Ubuntu and Debian as they're the same ansible_os_family
- if "Ubuntu" in platforms and "Debian" not in platforms:
- platforms.remove("Ubuntu")
- platforms.append("Debian")
-
- # Iterate over platforms creating files
- for platform in platforms:
-
- # assign platform name to cookiecutter.platform
- CONTEXT.update({"platform": platform})
-
- # build jinja2 environment
- env = StrictEnvironment(
- context={"cookiecutter": CONTEXT}, keep_trailing_newline=True,
- )
-
- # must be in template dir for generate_file to work
- with utils.work_in(TEMPLATE_DIR):
- env.loader = jinja2.FileSystemLoader(".")
-
- for infile in platform_files:
- ccg.generate_file(
- project_dir=PROJECT_DIR,
- infile=infile,
- context={"cookiecutter": CONTEXT},
- env=env,
- )
-
-
def delete_inactive_licenses():
# get list of licenses written to output
@@ -104,5 +51,4 @@
if __name__ == "__main__":
- generate_platforms()
delete_inactive_licenses()
diff --git "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/.reuse/dep5" "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/.reuse/dep5"
index 8bcf9a4..2851d4e 100644
--- "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/.reuse/dep5"
+++ "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/.reuse/dep5"
@@ -1,5 +1,5 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
-Files: .cookiecutter_params.json VERSION .gitreview
+Files: VERSION README.md
Copyright: {{ cookiecutter.year }} {{ cookiecutter.author }}
License: {{ cookiecutter.license }}
diff --git "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/Makefile" "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/Makefile"
index 1c1bb02..c4d8e94 100644
--- "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/Makefile"
+++ "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/Makefile"
@@ -1,6 +1,6 @@
# {{ cookiecutter.role_name }} Makefile
#
-# SPDX-FileCopyrightText: © {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
+# SPDX-FileCopyrightText: {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
# SPDX-License-Identifier: {{ cookiecutter.license }}
SHELL = bash -eu -o pipefail
@@ -12,25 +12,28 @@
molecule --version
molecule test
-lint: yamllint ansiblelint ## run all lint checks
+lint: license yamllint ansiblelint ## run all lint checks
# all YAML files
YAML_FILES ?= $(shell find . -type f \( -name '*.yaml' -o -name '*.yml' \) -print )
+license: ## Check license with the reuse tool
+ reuse --version
+ reuse --root . lint
+
yamllint: ## lint check with yamllint
yamllint --version
yamllint \
-d "{extends: default, rules: {line-length: {max: 99}}}" \
-s $(YAML_FILES)
+# List of molecule files, not including base molecule.yml which isn't ansible format
+MOLECULE_FILES ?= $(shell find molecule -type f -name '*.yml' \! -name 'molecule.yml' -print )
+
ansiblelint: ## lint check with ansible-lint
ansible-lint --version
ansible-lint -v .
- ansible-lint -v molecule/*/*
-
-license: ## Check license with the reuse tool
- reuse --version
- reuse --root . lint
+ ansible-lint -v $(MOLECULE_FILES)
help: ## Print help for each target
@echo {{ cookiecutter.role_name }} test targets
diff --git "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/README.md" "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/README.md"
index dca0c0c..65acfac 100644
--- "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/README.md"
+++ "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/README.md"
@@ -1,38 +1,17 @@
-<!--
-SPDX-FileCopyrightText: © {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
-SPDX-License-Identifier: {{ cookiecutter.license }}
---!>
# {{ cookiecutter.role_name }}
{{ cookiecutter.description }}
-## Requirements
-
-Minimum ansible version: {{ cookiecutter.min_ansible_version }}
-
-## Defaults
-
-List of default values for variables:
-
-{%- for key, val in cookiecutter.role_defaults|dictsort %}
-* `{{ key }}: {{ val }}`
-{%- endfor %}
-
## Example Playbook
```yaml
- hosts: all
- vars:
-{%- for key, val in cookiecutter.role_defaults|dictsort %}
- {{ key }}: {{ val }}
-{%- endfor %}
roles:
- {{ cookiecutter.role_name }}
-
```
## License and Author
-© {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
+Copyright {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
License: {{ cookiecutter.license }}
diff --git "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/defaults/main.yml" "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/defaults/main.yml"
index c418946..fd4a7fc 100644
--- "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/defaults/main.yml"
+++ "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/defaults/main.yml"
@@ -1,8 +1,5 @@
---
# {{ cookiecutter.role_name }} defaults/main.yml
#
-# SPDX-FileCopyrightText: © {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
+# SPDX-FileCopyrightText: {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
# SPDX-License-Identifier: {{ cookiecutter.license }}
-{% for key, val in cookiecutter.role_defaults|dictsort %}
-{{ key }}: {{ val }}
-{%- endfor %}
diff --git "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/handlers/main.yml" "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/handlers/main.yml"
index b904b65..053b337 100644
--- "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/handlers/main.yml"
+++ "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/handlers/main.yml"
@@ -1,5 +1,5 @@
---
# {{ cookiecutter.role_name }} handlers/main.yml
#
-# SPDX-FileCopyrightText: © {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
+# SPDX-FileCopyrightText: {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
# SPDX-License-Identifier: {{ cookiecutter.license }}
diff --git "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/meta/main.yml" "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/meta/main.yml"
index fa586ab..efcb2da 100644
--- "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/meta/main.yml"
+++ "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/meta/main.yml"
@@ -1,10 +1,13 @@
---
# {{ cookiecutter.role_name }} meta/main.yml
#
-# SPDX-FileCopyrightText: © {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
+# SPDX-FileCopyrightText: {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
# SPDX-License-Identifier: {{ cookiecutter.license }}
galaxy_info:
+ role_name: {{ cookiecutter.role_name }}
+ namespace: onf
+
author: {{ cookiecutter.author }}
description: {{ cookiecutter.description }}
company: {{ cookiecutter.company }}
@@ -16,13 +19,12 @@
min_ansible_version: {{ cookiecutter.min_ansible_version }}
platforms:
-{%- for platform, versions in cookiecutter.platforms.items() %}
- - name: {{ platform }}
+ - name: Ubuntu
versions:
-{%- for version in versions %}
- - "{{ version }}"
-{%- endfor %}
-{%- endfor %}
+ - bionic
+ - name: Debian
+ versions:
+ - bullseye
galaxy_tags:
- {{ cookiecutter.role_name }}
diff --git "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/molecule/default/converge.yml" "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/molecule/default/converge.yml"
index 00e5fa4..5e3c1b5 100644
--- "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/molecule/default/converge.yml"
+++ "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/molecule/default/converge.yml"
@@ -1,7 +1,7 @@
---
# {{ cookiecutter.role_name }} molecule/default/verify.yml
#
-# SPDX-FileCopyrightText: © {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
+# SPDX-FileCopyrightText: {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
# SPDX-License-Identifier: {{ cookiecutter.license }}
- name: Converge
diff --git "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/molecule/default/molecule.yml" "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/molecule/default/molecule.yml"
index 4264731..ca1ec97 100644
--- "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/molecule/default/molecule.yml"
+++ "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/molecule/default/molecule.yml"
@@ -1,7 +1,7 @@
---
# {{ cookiecutter.role_name }} molecule/default/molecule.yml
#
-# SPDX-FileCopyrightText: © {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
+# SPDX-FileCopyrightText: {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
# SPDX-License-Identifier: {{ cookiecutter.license }}
dependency:
@@ -9,22 +9,23 @@
driver:
name: docker
platforms:
-{%- for platform, versions in cookiecutter.platforms.items() %}
-{%- set platform = platform | lower %}
-{%- for version in versions %}
-{%- if not cookiecutter.molecule_privileged %}
- - name: "{{ platform }}-{{ version }}"
- image: "{{ platform }}:{{ version }}"
-{%- else %}{# privileged, running custom images generated by: https://github.com/paulfantom/dockerfiles #}
- - name: "{{ platform }}-{{ version }}-priv"
- image: "quay.io/paulfantom/molecule-systemd:{{ platform }}-{{ version }}"
+ - name: "ubuntu-18.04-priv"
+ image: "quay.io/paulfantom/molecule-systemd:ubuntu-18.04"
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:ro"
-{%- endif %}
-{%- endfor %}
-{%- endfor %}
+ - name: "debian-11-priv"
+ image: "onfinfra/molecule-systemd:debian-11"
+ privileged: true
+ volumes:
+ - "/sys/fs/cgroup:/sys/fs/cgroup:ro"
provisioner:
name: ansible
+ inventory:
+ host_vars:
+ debian-11-priv:
+ ansible_python_interpreter: /usr/bin/python3
+ ubuntu-18.04-priv:
+ ansible_python_interpreter: /usr/bin/python3
verifier:
name: ansible
diff --git "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/molecule/default/verify.yml" "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/molecule/default/verify.yml"
index 285b2d7..0abd479 100644
--- "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/molecule/default/verify.yml"
+++ "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/molecule/default/verify.yml"
@@ -1,7 +1,7 @@
---
# {{ cookiecutter.role_name }} molecule/default/verify.yml
#
-# SPDX-FileCopyrightText: © {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
+# SPDX-FileCopyrightText: {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
# SPDX-License-Identifier: {{ cookiecutter.license }}
- name: Verify
diff --git "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/tasks/Debian.yml" "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/tasks/Debian.yml"
new file mode 100644
index 0000000..5cf1ffe
--- /dev/null
+++ "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/tasks/Debian.yml"
@@ -0,0 +1,5 @@
+---
+# {{ cookiecutter.role_name }} tasks/Debian.yml
+#
+# SPDX-FileCopyrightText: {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
+# SPDX-License-Identifier: {{ cookiecutter.license }}
diff --git "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/tasks/main.yml" "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/tasks/main.yml"
index 7cced3b..e58a706 100644
--- "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/tasks/main.yml"
+++ "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/tasks/main.yml"
@@ -1,7 +1,7 @@
---
# {{ cookiecutter.role_name }} tasks/main.yml
#
-# SPDX-FileCopyrightText: © {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
+# SPDX-FileCopyrightText: {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
# SPDX-License-Identifier: {{ cookiecutter.license }}
{% raw %}
- name: include OS-specific vars
diff --git "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/tasks/\173\173cookiecutter.platform\175\175.yml" "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/tasks/\173\173cookiecutter.platform\175\175.yml"
deleted file mode 100644
index 1b4df91..0000000
--- "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/tasks/\173\173cookiecutter.platform\175\175.yml"
+++ /dev/null
@@ -1,5 +0,0 @@
----
-# {{ cookiecutter.role_name }} tasks/{{ cookiecutter.platform }}.yml
-#
-# SPDX-FileCopyrightText: © {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
-# SPDX-License-Identifier: {{ cookiecutter.license }}
diff --git "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/vars/Debian.yml" "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/vars/Debian.yml"
new file mode 100644
index 0000000..27077d9
--- /dev/null
+++ "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/vars/Debian.yml"
@@ -0,0 +1,8 @@
+---
+# {{ cookiecutter.role_name }} vars/Debian.yml
+#
+# SPDX-FileCopyrightText: {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
+# SPDX-License-Identifier: {{ cookiecutter.license }}
+#
+# NOTE: Only put platform/OS-specific variables in this file.
+# Put all other variables in the 'defaults/main.yml' file.
diff --git "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/vars/\173\173cookiecutter.platform\175\175.yml" "b/cookiecutters/role/\173\173cookiecutter.role_name\175\175/vars/\173\173cookiecutter.platform\175\175.yml"
deleted file mode 100644
index feed32c..0000000
--- "a/cookiecutters/role/\173\173cookiecutter.role_name\175\175/vars/\173\173cookiecutter.platform\175\175.yml"
+++ /dev/null
@@ -1,8 +0,0 @@
----
-# {{ cookiecutter.role_name }} vars/{{ cookiecutter.platform }}.yml
-#
-# SPDX-FileCopyrightText: © {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
-# SPDX-License-Identifier: {{ cookiecutter.license }}
-#
-# NOTE: Only put platform/OS-specific variables in this file.
-# Put all other variables in the 'defaults/main.yml' file.