Skip to content

Commit

Permalink
Fixed ansible-lint issues + workflows (#16)
Browse files Browse the repository at this point in the history
# Pull Request Description
- Fixed all ansible-lint issues
- Added workflows (CI, Release Drafter, Publish to Galaxy)

## Change type
- [x] Bug fix (non-breaking change which fixes a specific issue)
- [ ] New feature (non-breaking change adding new functionality)
- [ ] Breaking change (fix or feature that potentially causes existing
functionality to fail)
- [x] Change that does not affect Ansible Role code (Github Actions
Workflow, Documentation, or similair)
  • Loading branch information
lukapetrovic-git authored Oct 9, 2024
1 parent 999a66b commit 4fc8648
Show file tree
Hide file tree
Showing 14 changed files with 277 additions and 113 deletions.
120 changes: 60 additions & 60 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,72 @@
name: Bug report
description: Report a bug!
title: "[BUG]: "
labels: ['bug']
labels: ["bug"]

body:
- type: markdown
attributes:
value: >
**Report a bug you found/experienced!**
- type: markdown
attributes:
value: >
**Report a bug you found/experienced!**
Please first check if the issue exists in the Issues tab.
Please first check if the issue exists in the Issues tab.
- type: textarea
attributes:
label: Summary
description: Write a brief explanation of the problem.
placeholder: >-
When running role xyz with variables xyz, xyz breaks...
validations:
required: true
- type: textarea
attributes:
label: Summary
description: Write a brief explanation of the problem.
placeholder: >-
When running role xyz with variables xyz, xyz breaks...
validations:
required: true

- type: textarea
attributes:
label: Ansible Version
description: >-
Paste verbatim output from `ansible --version` below.
render: console
placeholder: >-
ansible [core 2.15.8]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
jinja version = 3.0.3
libyaml = True
validations:
required: true
- type: textarea
attributes:
label: Ansible Version
description: >-
Paste verbatim output from `ansible --version` below.
render: console
placeholder: >-
ansible [core 2.15.8]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
jinja version = 3.0.3
libyaml = True
validations:
required: true

- type: textarea
attributes:
label: Repro Steps
description: >-
Describe steps to reproduce the problem.
- type: textarea
attributes:
label: Repro Steps
description: >-
Describe steps to reproduce the problem.
**HINT:** You can paste https://gist.github.com links for larger files.
value: |
Paste an example playbook/vars file below
validations:
required: true
**HINT:** You can paste https://gist.github.com links for larger files.
value: |
Paste an example playbook/vars file below
validations:
required: true

- type: textarea
attributes:
label: Expected Results
description: >-
Describe the expected result of running the steps above.
placeholder: >-
When I ran X, assuming Y I expected Z to happen.
validations:
required: true
- type: textarea
attributes:
label: Expected Results
description: >-
Describe the expected result of running the steps above.
placeholder: >-
When I ran X, assuming Y I expected Z to happen.
validations:
required: true

- type: textarea
attributes:
label: Actual Results
description: >-
Describe the actual result.
placeholder: >-
For example, paste Ansible Output here.
validations:
required: true
- type: textarea
attributes:
label: Actual Results
description: >-
Describe the actual result.
placeholder: >-
For example, paste Ansible Output here.
validations:
required: true
41 changes: 41 additions & 0 deletions .github/release_drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name-template: "$RESOLVED_VERSION"
tag-template: "$RESOLVED_VERSION"
categories:
- title: "Breaking"
lables:
- "major"
- "breaking"
- title: "Features"
labels:
- "feature"
- "enhancement"
- title: "Bug Fixes"
labels:
- "bug"
- "fix"
- title: "Documentation"
labels:
- "documentation"
- title: "Workflows"
labels:
- "workflow"
version-resolver:
major:
labels:
- "major"
- "breaking"
minor:
labels:
- "feature"
- "enhancement"
patch:
labels:
- "bug"
- "fix"
default: patch
change-template: "- $TITLE, by @$AUTHOR (#$NUMBER)"
template: |
# Changes
$CHANGES
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: CI

on:
pull_request:
branches:
- main
types: [opened, reopened, synchronize]


jobs:
yamllint:
name: YAML Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: Setup Python 3
uses: actions/[email protected]
with:
python-version: "3.x"

- name: Install deps
run: pip3 install yamllint

- name: Lint code
run: yamllint .

ansiblelint:
name: Ansible Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run ansible-lint
uses: ansible/ansible-lint@main
with:
args: "--profile production"
setup_python: "true"
requirements_file: "./requirements.yml"
22 changes: 22 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Release Drafter

permissions:
contents: write
pull-requests: read

on:
push:
branches:
- main

jobs:
draft_release:
name: Draft Release
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v6
with:
config-name: release_drafter.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Release to Ansible Galaxy

on:
release:
types: [published]

jobs:
release:
name: Ansible Galaxy Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: Setup Python 3
uses: actions/[email protected]
with:
python-version: "3.x"

- name: Install Ansible
run: pip3 install ansible-core

- name: Trigger a new import on Galaxy.
run: >-
ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }}
$(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2)
15 changes: 15 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
extends: default

rules:
line-length:
max: 150
level: warning
comments:
min-spaces-from-content: 1
comments-indentation: disable
braces:
max-spaces-inside: 1
octal-values:
forbid-implicit-octal: true
forbid-explicit-octal: true
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Path on the master node where to save Cilium config that gets passed to Cilium CLI on install/config change
cilium_config_file_path: "/home/{{ ansible_user }}/cilium-config.yml"

Expand Down Expand Up @@ -200,7 +201,6 @@ cilium_rollout_pods_on_update: false
# Install required Gateway Api CRDS
# https://docs.cilium.io/en/stable/network/servicemesh/gateway-api/gateway-api/
cilium_install_gw_api_crds: false

# Gateway API CRDs version to install
# Required when cilium_install_gw_api_crds is set to true
# cilium 1.13.x - 0.5.1
Expand Down
3 changes: 3 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
collections: []
roles: []
33 changes: 17 additions & 16 deletions tasks/hubble_cli.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
- block:
- name: determine latest hubble cli version
---
- name: Set Hubble version variable
when: cilium_hubble_cli_version is not defined or cilium_hubble_cli_version == None
block:
- name: Determine latest Hubble CLI version
ansible.builtin.uri:
url: https://raw.githubusercontent.com/cilium/hubble/main/stable.txt
return_content: true
register: cilium_hubble_latest_version

- name: set hubble desired version variable
- name: Set Hubble desired version variable
ansible.builtin.set_fact:
cilium_hubble_cli_version: "{{ cilium_hubble_latest_version.content | trim }}"
when: cilium_hubble_cli_version is not defined or cilium_hubble_cli_version == None

- name: check if hubble cli binary exists
- name: Check if Hubble CLI binary exists
ansible.builtin.stat:
path: "{{ cilium_hubble_cli_bin_path }}"
register: cilium_hubble_cli_check

- name: check hubble cli version
ansible.builtin.shell:
cmd: "{{ cilium_hubble_cli_bin_path }} version"
- name: Check Hubble CLI version
ansible.builtin.command: "{{ cilium_hubble_cli_bin_path }} version"
failed_when: false
changed_when: false
register: cilium_hubble_cli_existing_version

- block:
- name: set hubble cli architecture var
- name: Install Hubble CLI
when: not cilium_hubble_cli_check.stat.exists or cilium_hubble_cli_version[1:] not in cilium_hubble_cli_existing_version.stdout
block:
- name: Set Hubble CLI architecture var
ansible.builtin.set_fact:
cilium_hubble_arch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}"

- name: download hubble cli
- name: Download Hubble CLI
ansible.builtin.unarchive:
src: "https://github.com/cilium/hubble/releases/download/{{ cilium_hubble_cli_version }}/hubble-linux-{{ cilium_hubble_arch }}.tar.gz"
dest: /tmp
remote_src: true
mode: 0755
mode: "0755"

- name: copy hubble cli binary into place.
- name: Copy Hubble CLI binary into place.
ansible.builtin.copy:
src: "/tmp/hubble"
dest: "{{ cilium_hubble_cli_bin_path }}"
mode: 0755
mode: "0755"
remote_src: true
become: true
when: cilium_hubble_cli_check.stat.exists == false or cilium_hubble_cli_version[1:] not in cilium_hubble_cli_existing_version.stdout

Loading

0 comments on commit 4fc8648

Please sign in to comment.