From d60c7e22e6a95484e2370170b3d3eea8968e6b09 Mon Sep 17 00:00:00 2001 From: Kate Case Date: Wed, 11 Sep 2024 11:20:03 -0400 Subject: [PATCH] Clean up templates --- .../resources/common/gitignore/__meta__.yml | 6 +++--- .../resources/playbook_project/README.md.j2 | 2 +- .../project_org/project_repo/README.md.j2 | 16 ++++++++-------- .../project_repo/roles/run/README.md.j2 | 8 ++++---- .../resources/playbook_project/site.yml.j2 | 2 +- src/ansible_creator/types.py | 4 ---- 6 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/ansible_creator/resources/common/gitignore/__meta__.yml b/src/ansible_creator/resources/common/gitignore/__meta__.yml index 342da9c0..c7698a6d 100644 --- a/src/ansible_creator/resources/common/gitignore/__meta__.yml +++ b/src/ansible_creator/resources/common/gitignore/__meta__.yml @@ -14,6 +14,6 @@ playbook_project: !collections/ansible_collections !collections/requirements.yml collections/ansible_collections/* - !collections/ansible_collections/{{ scm_org}} - collections/ansible_collections/{{ scm_org }}/* - !collections/ansible_collections/{{ scm_org }}/{{ scm_project }} + !collections/ansible_collections/{{ namespace}} + collections/ansible_collections/{{ namespace }}/* + !collections/ansible_collections/{{ namespace }}/{{ collection_name }} diff --git a/src/ansible_creator/resources/playbook_project/README.md.j2 b/src/ansible_creator/resources/playbook_project/README.md.j2 index 2d2f052a..ae86c66f 100644 --- a/src/ansible_creator/resources/playbook_project/README.md.j2 +++ b/src/ansible_creator/resources/playbook_project/README.md.j2 @@ -1,4 +1,4 @@ -# {{ scm_org|capitalize }} {{ scm_project|capitalize }} Ansible Project +# {{ namespace|capitalize }} {{ collection_name|capitalize }} Ansible Project ## Included content/ Directory Structure diff --git a/src/ansible_creator/resources/playbook_project/collections/ansible_collections/project_org/project_repo/README.md.j2 b/src/ansible_creator/resources/playbook_project/collections/ansible_collections/project_org/project_repo/README.md.j2 index 62f6b816..d868e9c3 100644 --- a/src/ansible_creator/resources/playbook_project/collections/ansible_collections/project_org/project_repo/README.md.j2 +++ b/src/ansible_creator/resources/playbook_project/collections/ansible_collections/project_org/project_repo/README.md.j2 @@ -1,6 +1,6 @@ -# {{ scm_org|capitalize }} {{ scm_project|capitalize }} Collection +# {{ namespace|capitalize }} {{ collection_name|capitalize }} Collection -This repository contains the `{{ scm_org }}.{{ scm_project }}` Ansible Collection. +This repository contains the `{{ namespace }}.{{ collection_name }}` Ansible Collection. ## Tested with Ansible @@ -12,31 +12,31 @@ Some modules and plugins require external libraries. Please check the requiremen ## Included content -Please check the included content on the [Ansible Galaxy page for this collection](https://galaxy.ansible.com/{{ scm_org }}/{{ scm_project }}). +Please check the included content on the [Ansible Galaxy page for this collection](https://galaxy.ansible.com/{{ namespace }}/{{ collection_name }}). ## Using this collection ``` - ansible-galaxy collection install {{ scm_org }}.{{ scm_project }} + ansible-galaxy collection install {{ namespace }}.{{ collection_name }} ``` You can also include it in a `requirements.yml` file and install it via `ansible-galaxy collection install -r requirements.yml` using the format: ```yaml collections: - - name: {{ scm_org }}.{{ scm_project }} + - name: {{ namespace }}.{{ collection_name }} ``` To upgrade the collection to the latest available version, run the following command: ```bash -ansible-galaxy collection install {{ scm_org }}.{{ scm_project }} --upgrade +ansible-galaxy collection install {{ namespace }}.{{ collection_name }} --upgrade ``` -You can also install a specific version of the collection, for example, if you need to downgrade when something is broken in the latest version (please report an issue in this repository). Use the following syntax where `X.Y.Z` can be any [available version](https://galaxy.ansible.com/{{ scm_org }}/{{ scm_project }}): +You can also install a specific version of the collection, for example, if you need to downgrade when something is broken in the latest version (please report an issue in this repository). Use the following syntax where `X.Y.Z` can be any [available version](https://galaxy.ansible.com/{{ namespace }}/{{ collection_name }}): ```bash -ansible-galaxy collection install {{ scm_org }}.{{ scm_project }}:==X.Y.Z +ansible-galaxy collection install {{ namespace }}.{{ collection_name }}:==X.Y.Z ``` See [Ansible Using Collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for more details. diff --git a/src/ansible_creator/resources/playbook_project/collections/ansible_collections/project_org/project_repo/roles/run/README.md.j2 b/src/ansible_creator/resources/playbook_project/collections/ansible_collections/project_org/project_repo/roles/run/README.md.j2 index 1baea755..75ff1c57 100644 --- a/src/ansible_creator/resources/playbook_project/collections/ansible_collections/project_org/project_repo/roles/run/README.md.j2 +++ b/src/ansible_creator/resources/playbook_project/collections/ansible_collections/project_org/project_repo/roles/run/README.md.j2 @@ -1,4 +1,4 @@ -{{ scm_org|capitalize }}.{{ scm_project|capitalize }} Run Role +{{ namespace|capitalize }}.{{ collection_name|capitalize }} Run Role ======================== A brief description of the role is here. @@ -27,20 +27,20 @@ Including an example of how to use your role (for instance, with variables passe - name: Execute tasks on servers hosts: servers roles: - - role: {{ scm_org }}.{{ scm_project }}.run + - role: {{ namespace }}.{{ collection_name }}.run run_x: 42 ``` Another way to consume this role would be: ```yaml -- name: Initialize the run role from {{ scm_org }}.{{ scm_project }} +- name: Initialize the run role from {{ namespace }}.{{ collection_name }} hosts: servers gather_facts: false tasks: - name: Trigger invocation of run role ansible.builtin.include_role: - name: {{ scm_org }}.{{ scm_project }}.run + name: {{ namespace }}.{{ collection_name }}.run vars: run_x: 42 ``` diff --git a/src/ansible_creator/resources/playbook_project/site.yml.j2 b/src/ansible_creator/resources/playbook_project/site.yml.j2 index 4089a8b8..922bfbb2 100644 --- a/src/ansible_creator/resources/playbook_project/site.yml.j2 +++ b/src/ansible_creator/resources/playbook_project/site.yml.j2 @@ -2,4 +2,4 @@ - name: Example playbook hosts: localhost roles: - - role: {{ scm_org }}.{{ scm_project }}.run + - role: {{ namespace }}.{{ collection_name }}.run diff --git a/src/ansible_creator/types.py b/src/ansible_creator/types.py index 23e735a0..44d05571 100644 --- a/src/ansible_creator/types.py +++ b/src/ansible_creator/types.py @@ -25,8 +25,6 @@ class TemplateData: dev_file_name: The unique name entry in devfile. namespace: The namespace of the collection. recommended_extensions: A list of recommended VsCode extensions. - scm_org: The organization of the source control management. - scm_project: The project of the source control management. """ additions: dict[str, dict[str, dict[str, str | bool]]] = field(default_factory=dict) @@ -39,5 +37,3 @@ class TemplateData: recommended_extensions: Sequence[str] = field( default_factory=lambda: GLOBAL_TEMPLATE_VARS["RECOMMENDED_EXTENSIONS"], ) - scm_org: str = "" - scm_project: str = ""