Skip to content

Commit

Permalink
Clean up templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Qalthos committed Sep 11, 2024
1 parent 22ec7f1 commit d60c7e2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/ansible_creator/resources/common/gitignore/__meta__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# {{ scm_org|capitalize }} {{ scm_project|capitalize }} Ansible Project
# {{ namespace|capitalize }} {{ collection_name|capitalize }} Ansible Project

## Included content/ Directory Structure

Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_creator/resources/playbook_project/site.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
- name: Example playbook
hosts: localhost
roles:
- role: {{ scm_org }}.{{ scm_project }}.run
- role: {{ namespace }}.{{ collection_name }}.run
4 changes: 0 additions & 4 deletions src/ansible_creator/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 = ""

0 comments on commit d60c7e2

Please sign in to comment.