Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
Add Linting (#162)
Browse files Browse the repository at this point in the history
* Add pre-commit config

* Automatic pre-commit changes

* Add .cache

This is generated by ansible-lint runs

* Ignore role-name conventions

* Fix ansible-lint pipefail

* Fix ansible-lint unnamed-task

* ansible-lint fix command-instead-of-shell

* ansible-lint fix empty-string-compare

* ansible-lint fix literal-compare

* ansible-lint fix var-spacing

* ansible-lint fix no-changed-when

* ansible-lint fix no-handler

* ansible-lint fix risky-file-permissions

* pre-commit fix check-executables-have-shebangs

* pre-commit fix line ending

* ansible-lint fix yaml truthy values

* ansible-lint yamllint more fixes

* Add (untested) Github Action for ansible-lint

* Bump Workflow ansible-lint version

Maybe this helps?

* Fix find/replace and other remarks from review

Squash me!
  • Loading branch information
mulbc authored Aug 2, 2021
1 parent 0e11e4d commit 325e4f7
Show file tree
Hide file tree
Showing 97 changed files with 951 additions and 1,208 deletions.
2 changes: 2 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skip_list:
- role-name
50 changes: 50 additions & 0 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Ansible Lint # feel free to pick your own name

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
# Important: This sets up your GITHUB_WORKSPACE environment variable
- uses: actions/checkout@v2

- name: Lint Ansible Playbook
# replace "master" with any valid ref
uses: ansible/ansible-lint-action@master
env:
ANSIBLE_ROLES_PATH: ./app/roles
with:
# [required]
# Paths to ansible files (i.e., playbooks, tasks, handlers etc..)
# or valid Ansible directories according to the Ansible role
# directory structure.
# If you want to lint multiple ansible files, use the following syntax
# targets: |
# playbook_1.yml
# playbook_2.yml
targets: "./app"
# [optional]
# Arguments to be passed to the ansible-lint

# Options:
# -q quieter, although not silent output
# -p parseable output in the format of pep8
# --parseable-severity parseable output including severity of rule
# -r RULESDIR specify one or more rules directories using one or
# more -r arguments. Any -r flags override the default
# rules in ansiblelint/rules, unless -R is also used.
# -R Use default rules in ansiblelint/rules in addition to
# any extra
# rules directories specified with -r. There is no need
# to specify this if no -r flags are used
# -t TAGS only check rules whose id/tags match these values
# -x SKIP_LIST only check rules whose id/tags do not match these
# values
# --nocolor disable colored output
# --exclude=EXCLUDE_PATHS
# path to directories or files to skip. This option is
# repeatable.
# -c C Specify configuration file to use. Defaults to ".ansible-lint"
# args: "-q"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ data
venv
devel.env
data.tgz
.cache
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: detect-aws-credentials
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: trailing-whitespace
- repo: https://github.com/ansible-community/ansible-lint.git
rev: master
hooks:
- id: ansible-lint
entry: env ANSIBLE_ROLES_PATH=./app/roles ansible-lint --force-color
files: \.(yaml|yml)$
9 changes: 9 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
rules:
comments:
require-starting-space: true
ignore-shebangs: true
min-spaces-from-content: 1
line-length:
max: 200
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: false
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ RUN rpm -i /app/tmp/ilorest-3.0.1-7.x86_64.rpm; \

ENTRYPOINT ["/app/bin/entry.sh"]
CMD ["/app/bin/run.sh"]

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ and automated deployment tools. We are looking to bring OpenShift everywhere,
even to the edge.

![Cluster Install](https://raw.githubusercontent.com/project-faros/assets/master/demos/install/8-cluster.gif)

1 change: 0 additions & 1 deletion app/bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ if [ ! -e /data/config.sh ]; then
cp /data.skel/config.sh /data/config.sh
fi
mkdir -p /data/ansible

4 changes: 2 additions & 2 deletions app/collections/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
collections:
- name: ansible-posix-1.1.1.tar.gz
version: 1.1.1
- name: ansible-posix-1.1.1.tar.gz
version: 1.1.1
1 change: 1 addition & 0 deletions app/inventory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
from collections import defaultdict
import ipaddress
Expand Down
1 change: 1 addition & 0 deletions app/lib/ansible/callback/my_dense.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# sourced from dense callback plugin in Ansible 2.9

from __future__ import (absolute_import, division, print_function)
Expand Down
1 change: 1 addition & 0 deletions app/lib/ansible/callback/post_message.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

Expand Down
1 change: 1 addition & 0 deletions app/lib/ansible/callback/save_stats.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

Expand Down
1 change: 1 addition & 0 deletions app/lib/ansible/filter/ClusterOpCheck.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
TARGET = {
'Degraded': ['False'],
'Progressing': ['False'],
Expand Down
1 change: 1 addition & 0 deletions app/lib/python/conftui.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import json
Expand Down
4 changes: 2 additions & 2 deletions app/playbooks/apply.d/host-records/cockpit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

- name: Add Management Links to Cockpit
hosts: bastion_hosts
gather_facts: no
become: yes
gather_facts: false
become: true

tasks:
- name: create cockpit links to cluster node management
Expand Down
15 changes: 7 additions & 8 deletions app/playbooks/apply.d/host-records/dhcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

- name: Configure Cluster Node DHCP records
hosts: cluster
gather_facts: no
gather_facts: false
serial: 1

roles:
- name: dhcp

- name: Configure Management DHCP records
hosts: cluster:!virtual
gather_facts: no
gather_facts: false
serial: 1

roles:
Expand All @@ -23,7 +23,7 @@

- name: Configure extra DHCP records
hosts: localhost
gather_facts: no
gather_facts: false
serial: 1

vars:
Expand All @@ -44,7 +44,7 @@

- name: Configure ignored MAC Addresses
hosts: localhost
gather_facts: no
gather_facts: false
serial: 1

vars:
Expand All @@ -58,18 +58,17 @@
vars:
dhcp_name: "{{ node.name }}"
dhcp_mac_address: "{{ node.mac }}"
dhcp_ignore: yes
dhcp_ignore: true
loop: "{{ ignored_macs }}"
loop_control:
loop_var: node

- name: Check for orphaned dhcp entries
hosts: bastion
gather_facts: no
become: yes
gather_facts: false
become: true

roles:
- name: dhcp-verify
dhcp_verify_ignored: "{{ ignored_macs | from_json | json_query('[*].name') }}"
dhcp_verify_records: "{{ lookup('inventory_hostnames', 'cluster,management').split(',') + extra_nodes | json_query('[*].name') }}"

23 changes: 11 additions & 12 deletions app/playbooks/apply.d/host-records/dns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- name: Configure Cluster Node DNS Records
hosts: cluster
gather_facts: no
gather_facts: false
serial: 1

vars:
Expand All @@ -16,7 +16,7 @@

- name: Configure Cluster Node Management DNS Records
hosts: cluster:!virtual
gather_facts: no
gather_facts: false
serial: 1

vars:
Expand All @@ -30,7 +30,7 @@

- name: Configure Bastion DNS entries
hosts: bastion_hosts
gather_facts: no
gather_facts: false
serial: 1

vars:
Expand All @@ -42,7 +42,7 @@

- name: Configure Load Balanced DNS entries
hosts: loadbalancer
gather_facts: no
gather_facts: false
serial: 1

vars:
Expand All @@ -52,19 +52,19 @@
roles:
- name: dns
dns_hostname: "api"
dns_reverse: no
dns_reverse: false
- name: dns
dns_hostname: "api-int"
dns_reverse: no
dns_reverse: false
- name: dns
dns_hostname: "*.apps"
dns_reverse: no
dns_reverse: false
- name: dns
dns_hostname: "loadbalancer"

- name: Configure etcd DNS entries
hosts: control_plane
gather_facts: no
gather_facts: false
serial: 1

vars:
Expand All @@ -74,15 +74,15 @@
roles:
- name: dns
dns_hostname: "etcd-{{ cp_node_id }}"
dns_reverse: no
dns_reverse: false
- name: dns
dns_hostname: "_etcd-server-ssl.tcp"
dns_type: 'SRV'
dns_type: "SRV"
dns_value: "0 10 2380 etcd-{{ cp_node_id }}.{{ cluster_name }}.{{ cluster_domain }}."

- name: Configure extra DNS records
hosts: localhost
gather_facts: no
gather_facts: false
serial: 1

vars:
Expand All @@ -99,4 +99,3 @@
loop: "{{ extra_nodes }}"
loop_control:
loop_var: node

4 changes: 2 additions & 2 deletions app/playbooks/apply.d/router/create_router.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

- name: Configure layer 3 routing and network services
hosts: wan
gather_facts: no
become: yes
gather_facts: false
become: true

roles:
- name: router
Expand Down
1 change: 1 addition & 0 deletions app/playbooks/config.d/cluster/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
from conftui import (Configurator, ParameterCollection, Parameter,
Expand Down
1 change: 1 addition & 0 deletions app/playbooks/config.d/proxy/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from conftui import (Configurator, ParameterCollection, Parameter,
ListDictParameter, PasswordParameter,
Expand Down
Loading

0 comments on commit 325e4f7

Please sign in to comment.