generated from 39services/ansible_collection_39systems.template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 112f4a3
Showing
20 changed files
with
665 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
skip_list: | ||
- "var-naming[no-role-prefix]" # Allow _ and __ internal vars | ||
- run-once[task] # This check is broken | ||
|
||
# Exclude downloaded roles and collections from linting | ||
exclude_paths: | ||
- collections/** | ||
- roles/** | ||
- changelogs | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
# This workflow requires a GALAXY_API_KEY secret present in the GitHub | ||
# repository or organization. | ||
|
||
name: CI | ||
|
||
"on": | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "roles/template/**" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
molecule: | ||
runs-on: ubuntu-20.04 | ||
name: Molecule test "template" role | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
# - name: "Free Disk Space." | ||
# uses: jlumbroso/free-disk-space@main | ||
# with: | ||
# tool-cache: true | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies. | ||
working-directory: roles/template | ||
run: pip3 install -r requirements.txt | ||
|
||
- name: Install Ansible dependencies. | ||
run: ansible-galaxy install -r requirements.yml | ||
|
||
- name: Install Ansible dependencies specific to role. | ||
working-directory: roles/template | ||
run: ansible-galaxy install -r requirements.yml | ||
|
||
- name: Run molecule | ||
working-directory: roles/template | ||
run: "molecule test" | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
# Run this relative to the collection root | ||
# ./copy-role-template.sh example | ||
|
||
export role_name=$1 | ||
|
||
cp .github/workflow-templates/ansible-role-template.yml .github/workflows/ansible-role-$role_name.yml | ||
|
||
sed -i "s/template/$role_name/g" .github/workflows/ansible-role-$role_name.yml | ||
|
||
echo "Workflow for $role_name created" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
# This workflow requires a GALAXY_API_KEY secret present in the GitHub | ||
# repository or organization. | ||
|
||
name: Import to Galaxy | ||
'on': | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "galaxy.yml" | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
galaxy-import: | ||
name: Import to Galaxy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the codebase. | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get version from "galaxy.yml". | ||
id: version | ||
run: echo "collection_version=$(yq '.version' galaxy.yml)" >> "$GITHUB_ENV" | ||
|
||
- name: Check if tag already exists | ||
uses: mukunku/[email protected] | ||
id: check-tag | ||
with: | ||
tag: '${{ env.collection_version }}' | ||
|
||
- name: Set up Python 3. | ||
if: "${{ steps.check-tag.outputs.exists == 'false' }}" | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install Ansible. | ||
if: "${{ steps.check-tag.outputs.exists == 'false' }}" | ||
run: pip3 install ansible-core | ||
|
||
- name: Trigger a new import on Galaxy. | ||
if: "${{ steps.check-tag.outputs.exists == 'false' }}" | ||
run: >- | ||
ansible-galaxy collection build && | ||
ansible-galaxy collection publish --api-key ${{ secrets.GALAXY_API_KEY }} $(ls -t *.tar.gz | head -n 1) | ||
- name: Add tag. | ||
if: "${{ steps.check-tag.outputs.exists == 'false' }}" | ||
uses: anothrNick/[email protected] # Don't use @master unless you're happy to test the latest version | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CUSTOM_TAG: ${{ env.collection_version }} | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
# Editors | ||
.idea/ | ||
.vscode/ | ||
|
||
# Credentials | ||
**/kubeconfig.yaml | ||
.*vault* | ||
|
||
# Terraform | ||
**/.terraform/* | ||
*.tfstate | ||
*.tfstate.* | ||
.terraform.lock.hcl | ||
|
||
# Ansible | ||
/tests/output/ | ||
/changelogs/.plugin-cache.yaml | ||
output/ | ||
.collection_root/* | ||
|
||
**/collections/** | ||
!**/collections/requirements.yml | ||
!/**/.gitkeep | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.venv | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
args: [--markdown-linebreak-ext=md] | ||
- id: end-of-file-fixer | ||
- id: check-added-large-files | ||
- id: check-yaml | ||
files: .*\.(yaml|yml)$ | ||
args: [--unsafe] | ||
- id: check-json | ||
- id: check-xml | ||
- id: check-toml | ||
- id: check-case-conflict | ||
- id: check-merge-conflict | ||
- id: detect-private-key | ||
- id: check-shebang-scripts-are-executable | ||
- id: check-executables-have-shebangs | ||
- id: check-added-large-files | ||
|
||
- repo: https://github.com/ansible/ansible-lint | ||
rev: v6.17.0 | ||
hooks: | ||
- id: ansible-lint | ||
files: \.(yaml|yml)$ | ||
entry: sh -c 'python3 -m pip install -r requirements.txt; python3 -m ansiblelint -v --force-color' | ||
|
||
... |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 diademiemi | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Ansible Collection - diademiemi.template | ||
======================================== | ||
Documentation for the collection template. | ||
|
||
Contents | ||
======== | ||
|
||
Roles | ||
------ | ||
Role | Description | CI Status | ||
--- | --- | --- | ||
<!-- [diademiemi.template.EXAMPLE](./roles/template/) | Install EXAMPLE | [![Molecule test](https://github.com/diademiemi/ansible_collection_diademiemi.template/actions/workflows/ansible-role-EXAMPLE.yml/badge.svg)](https://github.com/diademiemi/ansible_collection_diademiemi.template/actions/workflows/ansible-role-EXAMPLE.yml) --> | ||
|
||
Click on the role to see the README for that role. | ||
|
||
Collection Structure | ||
-------------- | ||
|
||
This collection makes use of my [Ansible Role Template repository](https://github.com/diademiemi/ansible_role_%74emplate.git). The `add-role.sh` script downloads this Template and generates a new role with the name specified. If a `molecule/default/molecule.yml` file is present, it will be ran with GitHub Actions. | ||
<!-- I use %74 here to encode to a "t" so it doesnt get recursively replaced. The .git causes a redirect so you end up at the right URL :)--> | ||
|
||
Usage: | ||
```bash | ||
export NEW_ROLE_NAME="new_role" | ||
./add-role.sh ${NEW_ROLE_NAME} | ||
``` | ||
|
||
Using Template | ||
-------------- | ||
To use this template for a new role, run | ||
|
||
|
||
```bash | ||
export NEW_ROLE_NAME="NEW_NAME" | ||
export GITHUB_USER="diademiemi" | ||
export GALAXY_API_KEY="YOUR_API_KEY" | ||
|
||
find . -type f -exec sed -i "s/diademiemi/${GITHUB_USER}/g" {} + # Do not run this more than once | ||
find . -type f -exec sed -i "s/template/${NEW_ROLE_NAME}/g" {} + # Do not run this more than once | ||
|
||
# Assumes repo is named ansible_role_${NEW_ROLE_NAME} | ||
gh secret set GALAXY_API_KEY -R ${GITHUB_USER}/ansible_collection_${GITHUB_USER}.${NEW_COLLECTION_NAME} -a actions -b ${GALAXY_API_KEY} | ||
|
||
# Remove this section from README.md | ||
sed -i "/Using Template/Q" README.md | ||
``` | ||
|
||
This is also provided as a script as `replace.sh`. |
Oops, something went wrong.