From a84cfd5c319b5012b92b636ff401674ace675a9a Mon Sep 17 00:00:00 2001 From: Matthew Emes Date: Thu, 12 Sep 2024 12:35:18 -0700 Subject: [PATCH 1/3] chore: Update pre-commit plugins and action Updates the plugins and ansible-lint; many, many errors now to be cleaned up. Also includes updates for all python dependencies. --- .github/workflows/pre-commit.yml | 29 ++++++++++++++++------------ .gitignore | 1 + .pre-commit-config.yaml | 33 +++++++++++++++++++++++--------- requirements-dev.txt | 20 +++++++++---------- requirements.txt | 9 +++++---- 5 files changed, 57 insertions(+), 35 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 889aacc..c2d5d33 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -1,6 +1,6 @@ -# These github actions will update Terraform section(s) of README(s), and -# perform linting using pre-commit. +# These github actions will perform linting using pre-commit. # yamllint disable rule:line-length +# spell-checker: disable --- name: pre-commit @@ -8,22 +8,27 @@ name: pre-commit on: pull_request: push: - branches: [main] + branches-ignore: + - main + +permissions: + contents: read + pull-requests: read jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Install terraform-docs - run: | - sudo curl -sL --output - https://github.com/terraform-docs/terraform-docs/releases/download/v0.16.0/terraform-docs-v0.16.0-linux-amd64.tar.gz | tar xzf - -C /usr/local/bin - sudo chmod 0755 /usr/local/bin/terraform-docs + - uses: actions/checkout@v4 - name: install talisman run: | - sudo curl -sLo /usr/local/bin/talisman https://github.com/thoughtworks/talisman/releases/download/v1.29.4/talisman_linux_amd64 + sudo curl -sLo /usr/local/bin/talisman https://github.com/thoughtworks/talisman/releases/download/v1.32.0/talisman_linux_amd64 sudo chmod 0755 /usr/local/bin/talisman - - uses: actions/setup-python@v4.5.0 + - name: Install terraform-docs + run: | + sudo sh -c 'curl -sL https://github.com/terraform-docs/terraform-docs/releases/download/v0.18.0/terraform-docs-v0.18.0-linux-amd64.tar.gz | tar xzf - -C /usr/local/bin' + sudo chmod 0755 /usr/local/bin/terraform-docs + - uses: actions/setup-python@v5 with: - python-version: '3.10' - - uses: pre-commit/action@v3.0.0 + python-version: '3.12' + - uses: pre-commit/action@v3.0.1 diff --git a/.gitignore b/.gitignore index d884763..5249315 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ kubeconfig* # Ignore any pytest caches .pytest_cache +__pycache__ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4927d12..593f144 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,24 +2,37 @@ --- repos: - repo: https://github.com/adrienverge/yamllint - rev: v1.31.0 + rev: v1.35.1 hooks: - id: yamllint files: \.(yml|yaml|talismanrc)$ - types: [file, yaml] + types: + - file + - yaml entry: yamllint --strict - repo: https://github.com/ansible/ansible-lint - rev: v6.15.0 + rev: v24.9.0 hooks: - id: ansible-lint - repo: https://github.com/antonbabenko/pre-commit-terraform - rev: v1.77.3 + rev: v1.95.0 hooks: - id: terraform_fmt - id: terraform_docs - args: ['--args=--sort-by=required --hide=providers'] + args: + - '--args=--sort-by=required --hide=providers' + - repo: https://github.com/compilerla/conventional-pre-commit + rev: v3.4.0 + hooks: + - id: conventional-pre-commit + stages: + - commit-msg + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.10.0.1 + hooks: + - id: shellcheck - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: - id: check-executables-have-shebangs - id: check-json @@ -27,11 +40,13 @@ repos: - id: check-xml - id: detect-private-key - id: end-of-file-fixer - - id: pretty-format-json - args: [--autofix] + - id: no-commit-to-branch + args: + - -b + - main - id: trailing-whitespace - repo: https://github.com/thoughtworks/talisman - rev: 'v1.30.2' + rev: v1.32.0 hooks: - id: talisman-commit entry: cmd --githook pre-commit diff --git a/requirements-dev.txt b/requirements-dev.txt index a61dd46..13ac60b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,12 +1,12 @@ # Additional python packages for hacking on the solution -ansible-lint==6.15.0 -black==23.3.0 -isort==5.12.0 -molecule==5.0.0 -molecule-plugins==23.4.0 -pre-commit==3.2.2 -pylint==2.17.2 -pytest==7.3.1 -pytest-cov==4.0.0 -pytest-testinfra==7.0.0 +ansible-lint==24.9.0 +black==24.8.0 +isort==5.13.2 +molecule==24.9.0 +molecule-plugins==23.5.3 +pre-commit==3.8.0 +pylint==3.2.7 +pytest==8.3.3 +pytest-cov==5.0.0 +pytest-testinfra==10.1.1 -r requirements.txt diff --git a/requirements.txt b/requirements.txt index 69353ac..01d6b04 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,10 @@ # lab-config required packages # see also ansible/requirements.yml for Ansible galaxy packages -ansible==7.4.0 +ansible==10.4.0 pyghmi==1.5.61 -hvac==1.1.0 +hvac==2.3.0 jmespath==1.0.1 -kubernetes==26.1.0 +jwcrypto==1.4.2 +kubernetes==30.1.0 passlib==1.7.4 -netaddr==0.8.0 +netaddr==1.3.0 From e31eb625a342112d2775f201a826be39d08e18b8 Mon Sep 17 00:00:00 2001 From: Matthew Emes Date: Thu, 12 Sep 2024 12:38:57 -0700 Subject: [PATCH 2/3] docs: README and other docs --- .vscode/settings.json | 7 ++- CHANGELOG.md | 0 CODE_OF_CONDUCT.md | 132 ++++++++++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 34 +++++++++++ README.md | 9 +++ version.txt | 0 6 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 README.md create mode 100644 version.txt diff --git a/.vscode/settings.json b/.vscode/settings.json index 4e5e652..5dbbad3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -28,6 +28,7 @@ "dpkg", "dvswitch", "elrepo", + "endfor", "esxi", "fileignoreconfig", "firewalld", @@ -36,7 +37,9 @@ "gpgkey", "hashi", "hashicorp", + "hostvars", "hugepages", + "ifname", "ignoreerrors", "ipaddr", "ipmi", @@ -85,6 +88,7 @@ "rpcbind", "runc", "sbin", + "selectattr", "selinux", "smbd", "storageclass", @@ -102,7 +106,8 @@ "vmgmt", "vmware", "vnet", - "vsphere" + "vsphere", + "wontfix" ], "yaml.schemas": { "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/ansible-lint-config.json": "/.ansible-lint" diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..35b5167 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,132 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[INSERT CONTACT METHOD]. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..f56d4f2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,34 @@ +# How to contribute + +Contributions are welcome to this repo, but we do have a few guidelines for +contributors. + +## Open an issue and pull request for changes + +All submissions, including those from project members, are required to go through +review. We use [GitHub Pull Requests](https://help.github.com/articles/about-pull-requests/) +for this workflow, which should be linked with an issue for tracking purposes. +A GitHub action will be run against your PR to ensure code standards have been +applied. + +[pre-commit] is used to ensure that all files have consistent formatting and to +avoid committing secrets. + +1. Install [pre-commit] in a virtual python environment or globally: see [instructions](https://pre-commit.com/#installation) +2. Fork and clone this repo +3. Install pre-commit hook to git + + E.g. + + ```shell + pip install -r requirements-dev.txt + pre-commit install --hook-type commit-msg --hook-type pre-commit + ``` + +4. Create a new branch for changes +5. Commit and push changes for PR + + The hook will ensure that `pre-commit` will be run against all staged changes + during `git commit`. + +[pre-commit]: https://pre-commit.com/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..aa5af8a --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# lab-config + +![GitHub release](https://img.shields.io/github/v/release/memes/lab-config?sort=semver) +![Maintenance](https://img.shields.io/maintenance/yes/2024) +[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md) + +The scripts and playbooks I use for lab setup. + +> TODO @memes - add content diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..e69de29 From 42d809b1daf51ad80bb95f29d09efe0709fe82df Mon Sep 17 00:00:00 2001 From: Matthew Emes Date: Thu, 12 Sep 2024 12:40:44 -0700 Subject: [PATCH 3/3] chore: Additional GitHub actions for releases --- .github/workflows/release-please.yml | 23 ++++++++++++++++++++ .github/workflows/stale.yml | 32 ++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .github/workflows/release-please.yml create mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..aa638aa --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,23 @@ +# spell-checker: disable +--- +name: release-please + +# yamllint disable-line rule:truthy +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - name: Release Please + uses: GoogleCloudPlatform/release-please-action@v4.1.3 + with: + release-type: simple + token: ${{ secrets.RELEASE_PLEASE_TOKEN }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..8f2aa7f --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,32 @@ +# Stale issue and PR workflow +--- +name: stale + +# yamllint disable-line rule:truthy +on: + schedule: + - cron: '30 1 * * *' + +permissions: + issues: write + pull-requests: write + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v9 + with: + days-before-stale: 30 + days-before-close: 7 + days-before-pr-close: -1 + stale-issue-message: > + This issue has been automatically marked as stale because it has not + had recent activity. It will be closed if no further activity + occurs. + Thank you for your contributions. + close-issue-label: wontfix + close-issue-message: > + This issue has been automatically closed because it has been marked + as stale for 7 days with no activity. Thank you for your + contributions.