Git Product home page Git Product logo

docker-ansible-lint's Introduction

Docker image for ansible-lint

Tag License

lint build nightly

All #awesome-ci Docker images

ansible-lint ansible awesome-ci bandit black checkmake eslint file-lint gofmt goimports golint jsonlint kubeval linkcheck mypy php-cs-fixer phpcbf phpcs phplint pycodestyle pydocstyle pylint terraform-docs terragrunt-fmt terragrunt yamlfmt yamllint

View Dockerfiles on GitHub.

Available Architectures: amd64, i386, arm64

Tiny Alpine-based multistage-build dockerized version of ansible-lint[1]. The image is built nightly against the latest stable version of ansible-lint and pushed to Dockerhub.

[1] Official project: https://github.com/ansible/ansible-lint

Docker

Rolling releaess

The following Docker image tags are rolling releases and are built and updated every night.

nightly

Docker Tag Git Ref Ansible Lint Flavour Available Architectures
latest master latest default amd64, i386, arm64
alpine master latest Alpine amd64, i386, arm64
6 master 6.x.x default amd64, i386, arm64
alpine-6 master 6.x.x Alpine amd64, i386, arm64
5 master 5.x.x default amd64, i386, arm64
alpine-5 master 5.x.x Alpine amd64, i386, arm64

Point in time releases

The following Docker image tags are built once and can be used for reproducible builds. Its version never changes so you will have to update tags in your pipelines from time to time in order to stay up-to-date.

build

Docker Tag Git Ref Ansible Lint Flavour Available Architectures
latest-0.7 tag: 0.7 latest default amd64, i386, arm64
alpine-latest-0.7 tag: 0.7 latest Alpine amd64, i386, arm64
6-0.7 tag: 0.7 6.x.x default amd64, i386, arm64
alpine-6-0.7 tag: 0.7 6.x.x Alpine amd64, i386, arm64
5-0.7 tag: 0.7 5.x.x default amd64, i386, arm64
alpine-5-0.7 tag: 0.7 5.x.x Alpine amd64, i386, arm64

📂 Docker mounts

The working directory inside the Docker container is /data/ and should be mounted locally to the root of your project where your .ansible-lint config file is located.

💻 Usage

Display usage

# Single playbook
docker run --rm -v $(pwd):/data cytopia/ansible-lint playbook.yml

# All playbooks via wildcard
docker run --rm -v $(pwd):/data cytopia/ansible-lint *.yml

# Single role (run from within the role's root)
docker run --rm -v "$(pwd)":"/data/$(basename "$(pwd)" )" -e ANSIBLE_ROLES_PATH="/data" cytopia/ansible-lint "/data/$(basename "$(pwd)" )/tests/test.yml"

GitLabCI

GitLabCI requires a shell entrypoint to be specified. See here for details: Issue #14.

default:
  image:
    name: cytopia/ansible-lint:latest
    entrypoint: ["/bin/sh", "-c"]

stages:
  - lint

ansible-linter:
  stage: lint
  script:
    - ansible-lint *.yaml
  only:
    - merge_requests
    - master

🔄 Related #awesome-ci projects

Docker images

Save yourself from installing lot's of dependencies and pick a dockerized version of your favourite linter below for reproducible local or remote CI tests:

GitHub DockerHub Type Description
awesome-ci aci-hub-img Basic Tools for git, file and static source code analysis
file-lint flint-hub-img Basic Baisc source code analysis
linkcheck linkcheck-hub-img Basic Search for URLs in files and validate their HTTP status code
ansible ansible-hub-img Ansible Multiple versions and flavours of Ansible
ansible-lint alint-hub-img Ansible Lint Ansible
gofmt gfmt-hub-img Go Format Go source code [1]
goimports gimp-hub-img Go Format Go source code [1]
golint glint-hub-img Go Lint Go code
eslint elint-hub-img Javascript Lint Javascript code
jsonlint jlint-hub-img JSON Lint JSON files [1]
kubeval kubeval-hub-img K8s Lint Kubernetes files
checkmake cm-hub-img Make Lint Makefiles
phpcbf pcbf-hub-img PHP PHP Code Beautifier and Fixer
phpcs pcs-hub-img PHP PHP Code Sniffer
phplint plint-hub-img PHP PHP Code Linter [1]
php-cs-fixer pcsf-hub-img PHP PHP Coding Standards Fixer
bandit bandit-hub-img Python A security linter from PyCQA
black black-hub-img Python The uncompromising Python code formatter
mypy mypy-hub-img Python Static source code analysis
pycodestyle pycs-hub-img Python Python style guide checker
pydocstyle pyds-hub-img Python Python docstyle checker
pylint pylint-hub-img Python Python source code, bug and quality checker
terraform-docs tfdocs-hub-img Terraform Terraform doc generator (TF 0.12 ready) [1]
terragrunt tg-hub-img Terraform Terragrunt and Terraform
terragrunt-fmt tgfmt-hub-img Terraform terraform fmt for Terragrunt files [1]
yamlfmt yfmt-hub-img Yaml Format Yaml files [1]
yamllint ylint-hub-img Yaml Lint Yaml files

[1] Uses a shell wrapper to add enhanced functionality not available by original project.

Makefiles

Visit cytopia/makefiles for dependency-less, seamless project integration and minimum required best-practice code linting for CI. The provided Makefiles will only require GNU Make and Docker itself removing the need to install anything else.

📄 License

MIT License

Copyright (c) 2019 cytopia

docker-ansible-lint's People

Contributors

adaamz avatar cytopia avatar dependabot[bot] avatar sgasse avatar wesley-dean-flexion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

docker-ansible-lint's Issues

Does not work with GitLab CI

Trying to use this on GitLab CI:

.gitlab-ci.yml

ansible-lint:
  image: cytopia/ansible-lint
  stage: lint
  script:
    - ansible-lint -R -x idempotency,ANSIBLE0010 *.yml --nocolor

Output from GitLab CI:

WARNING: Couldn't open sh - No such file or directory

Missing jmespath

I have some Ansible that uses json_query, and when I run ansible-lint in a cytopia/ansible-lint container, I get the following error:

WARNING  Listing 2 violation(s) that are fatal
d=856173;https://ansible-lint.readthedocs.io/rules/jinja/1;91mjinja[invalid]: You need to install "jmespath" prior to running json_query filter

Per the message above, this occurs because jmespath is not on the image.

In my GitLab CI/CD pipeline before running ansible-lint, I'm able to install jmespath via pip with the following before_script:

  before_script:
    - /usr/bin/python3 -m pip install jmespath

Since it is needed for some linting, can jmespath be pre-installed in the image?

Latest ansible-lint image causes CI breakage

Hi, I'm running this in a private GitLab project's CI, but here's what I see (it's been running just fine for a little over a year without issues nightly until last night):

Executing "step_script" stage of the job script
00:07
Using docker image sha256:ac519d2d1dce79826ecc5c6afda2ecb07048978eac8b1fd4f1a8bc50b6017f11 for cytopia/ansible-lint:latest with digest cytopia/ansible-lint@sha256:4c4f8165b8ee9f88f173fa1[23](https://gitlab.cern.ch/scipp/pixels/orchestration/-/jobs/25365080#L23)d85c108031d21e1074d0c76728aecf99ba8a401 ...
$ ansible-lint playbooks/*.yml
Traceback (most recent call last):
  File "/usr/bin/ansible-lint", line 8, in <module>
    sys.exit(_run_cli_entrypoint())
  File "/usr/lib/python3.10/site-packages/ansiblelint/__main__.py", line 314, in _run_cli_entrypoint
    sys.exit(main(sys.argv))
  File "/usr/lib/python3.10/site-packages/ansiblelint/__main__.py", line 194, in main
    app = get_app(offline=options.offline)
  File "/usr/lib/python3.10/site-packages/ansiblelint/app.py", line 3[29](https://gitlab.cern.ch/scipp/pixels/orchestration/-/jobs/25365080#L29), in get_app
    app.runtime.prepare_environment(install_local=True, offline=offline)
  File "/usr/lib/python3.10/site-packages/ansible_compat/runtime.py", line [34](https://gitlab.cern.ch/scipp/pixels/orchestration/-/jobs/25365080#L34)0, in prepare_environment
    self.install_requirements(req_file, retry=retry)
  File "/usr/lib/python3.10/site-packages/ansible_compat/runtime.py", line 294, in install_requirements
    run = self.exec(cmd, retry=retry)
  File "/usr/lib/python3.10/site-packages/ansible_compat/runtime.py", line 150, in exec
    result = run_func(
  File "/usr/lib/python3.10/subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.10/subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1845, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ansible-galaxy'

Any ideas how to fix this?

Failing builds

Builds for docker-ansible-lint 6.x have been failing since February. ansible-lint development got more active recently so it would be useful to have up to date images.

Unable to run ansible-lint without options

One should be able to run this like so:
docker run --rm -v $(pwd):/data cytopia/ansible-lint

... in which case ansible-lint will scan the directory recursively. But it defaults to an argument of --version and outputs:

ansible-lint 4.2.0

Would like to get rid of the default --version argument.

Supported architectures?

Running into an odd failure when trying to use this docker image, but I suspect it's because I'm using the arm32v7 architecture.

Could you possibly document what architectures are supported for this docker image on dockerhub/in the README?

Docker Hub image is outdated

D:~ $ docker pull cytopia/ansible-lint:5
5: Pulling from cytopia/ansible-lint
Digest: sha256:c9eeefaac0b8928d551fb909fe7dd31796fb55af047ef118b04070cade7a1069
Status: Image is up to date for cytopia/ansible-lint:5
docker.io/cytopia/ansible-lint:5
D:~ $ docker run -it  cytopia/ansible-lint:5 --version
Failed to guess project directory using git:
ansible-lint 5.1.3 using ansible 2.11.5
D:~ $

And latest 5.x.x version of ansible-lint is currently 5.4.0: https://pypi.org/project/ansible-lint/#history

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.