Browse Source

[FIX] rename

master
Justin Lecher 2 months ago
parent
commit
ca7191046a
  1. 2
      Makefile
  2. 9
      cookiecutter.json
  3. 14
      hooks/pre_gen_project.py
  4. 6
      tests/test_bake_project.py
  5. 0
      {{ cookiecutter.role_name }}/.yamllint
  6. 2
      {{ cookiecutter.role_name }}/Makefile
  7. 7
      {{ cookiecutter.role_name }}/README.md
  8. 2
      {{ cookiecutter.role_name }}/meta/main.yml
  9. 7
      {{ cookiecutter.role_name }}/molecule/default/converge.yml
  10. 0
      {{ cookiecutter.role_name }}/molecule/default/molecule.yml
  11. 0
      {{ cookiecutter.role_name }}/molecule/default/tests/test_role.py
  12. 0
      {{ cookiecutter.role_name }}/molecule/default/verify.yml
  13. 0
      {{ cookiecutter.role_name }}/tests/inventory
  14. 2
      {{ cookiecutter.role_name }}/tests/test.yml
  15. 7
      {{cookiecutter.project_slug}}/molecule/default/converge.yml
  16. 2
      {{cookiecutter.project_slug}}/tasks/main.yml

2
Makefile

@ -1,5 +1,5 @@
PIPENV := pipenv run
PYTESTARGS ?= -x -vvvv
PYTESTARGS ?= -x -vvl
.PHONY: help

9
cookiecutter.json

@ -1,9 +1,8 @@
{
"full_name": "John Doe",
"email": "john@doe.com",
"github_username": "john_d",
"project_name": "Ansible Role Boilerplate",
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}",
"project_short_description": "Ansible Skeleton for either ansible roles",
"version": "0.1.0"
"ansible_namespace": "john_d",
"ansible_collection": "collection_name",
"role_name": "ansible_role",
"role_short_description": "Ansible Skeleton for either ansible roles"
}

14
hooks/pre_gen_project.py

@ -0,0 +1,14 @@
#!/usr/bin/env python3
import re
import sys
ROLE_REGEX = r"^[_a-zA-Z][_a-zA-Z0-9]+$"
role_name = "{{ cookiecutter.role_name }}"
if not re.match(ROLE_REGEX, role_name):
print("ERROR: %s is not a valid Python module name!" % role_name)
# exits with status 1 to indicate failure
sys.exit(1)

6
tests/test_bake_project.py

@ -112,6 +112,12 @@ def test_make_help(cookies):
assert b"Make targets" in output
def test_bake_role_invalid_name(cookies):
# with pytest.raises(ZeroDivisionError):
# bake_in_temp_dir(cookies, extra_context={"role_name": "foo-bar"})
bake_in_temp_dir(cookies, extra_context={"role_name": "foo-bar"})
def test_bake_role(cookies):
with bake_in_temp_dir(cookies) as result:
assert result.exit_code == 0

{{cookiecutter.project_slug}}/.yamllint → {{ cookiecutter.role_name }}/.yamllint

{{cookiecutter.project_slug}}/Makefile → {{ cookiecutter.role_name }}/Makefile

@ -8,7 +8,7 @@ help:
################################################################################
#
# Molecule logic
# Molecule logic FOO
#
################################################################################
.PHONY: status lint converge test clean

{{cookiecutter.project_slug}}/README.md → {{ cookiecutter.role_name }}/README.md

@ -1,7 +1,7 @@
{{ cookiecutter.project_name }}
{{ cookiecutter.ansible_namespace }}.{{ cookiecutter.ansible_collection }}.{{ cookiecutter.role_name }}
=========
{{ cookiecutter.project_short_description }}
{{ cookiecutter.role_short_description }}
Requirements
------------
@ -31,7 +31,8 @@ Including an example of how to use your role (for instance, with variables passe
```
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
- role: {{ cookiecutter.ansible_namespace }}.{{ cookiecutter.ansible_collection }}.{{ cookiecutter.role_name }}
vars: {}
```
License

{{cookiecutter.project_slug}}/meta/main.yml → {{ cookiecutter.role_name }}/meta/main.yml

@ -1,7 +1,7 @@
---
galaxy_info:
author: {{ cookiecutter.full_name }}
description: {{ cookiecutter.project_short_description }}
description: {{ cookiecutter.role_short_description }}
license: Apache-2.0
min_ansible_version: 2.1

7
{{ cookiecutter.role_name }}/molecule/default/converge.yml

@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include {{ cookiecutter.role_name }} role"
include_role:
name: "{{ cookiecutter.role_name }}"

{{cookiecutter.project_slug}}/molecule/default/molecule.yml → {{ cookiecutter.role_name }}/molecule/default/molecule.yml

{{cookiecutter.project_slug}}/molecule/default/tests/test_role.py → {{ cookiecutter.role_name }}/molecule/default/tests/test_role.py

{{cookiecutter.project_slug}}/molecule/default/verify.yml → {{ cookiecutter.role_name }}/molecule/default/verify.yml

{{cookiecutter.project_slug}}/tests/inventory → {{ cookiecutter.role_name }}/tests/inventory

{{cookiecutter.project_slug}}/tests/test.yml → {{ cookiecutter.role_name }}/tests/test.yml

@ -2,4 +2,4 @@
- hosts: localhost
remote_user: root
roles:
- role: "{{ cookiecutter.project_slug }}"
- role: "{{ cookiecutter.role_name }}"

7
{{cookiecutter.project_slug}}/molecule/default/converge.yml

@ -1,7 +0,0 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include {{ cookiecutter.project_slug }}"
include_role:
name: "{{ cookiecutter.project_slug }}"

2
{{cookiecutter.project_slug}}/tasks/main.yml

@ -1,2 +0,0 @@
---
# tasks file for bar
Loading…
Cancel
Save