ansible-lint | Best practices checker | DevOps library

 by   ansible-community Python Version: v6.0.0 License: GPL-3.0

kandi X-RAY | ansible-lint Summary

kandi X-RAY | ansible-lint Summary

ansible-lint is a Python library typically used in Devops, Ansible applications. ansible-lint has no bugs, it has no vulnerabilities, it has a Strong Copyleft License and it has medium support. However ansible-lint build file is not available. You can install using 'pip install ansible-lint' or download it from GitHub, PyPI.

Best practices checker for Ansible
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              ansible-lint has a medium active ecosystem.
              It has 2721 star(s) with 448 fork(s). There are 67 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 64 open issues and 609 have been closed. On average issues are closed in 118 days. There are 2 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of ansible-lint is v6.0.0

            kandi-Quality Quality

              ansible-lint has 0 bugs and 0 code smells.

            kandi-Security Security

              ansible-lint has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              ansible-lint code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              ansible-lint is licensed under the GPL-3.0 License. This license is Strong Copyleft.
              Strong Copyleft licenses enforce sharing, and you can use them when creating open source projects.

            kandi-Reuse Reuse

              ansible-lint releases are available to install and integrate.
              Deployable package is available in PyPI.
              ansible-lint has no build file. You will be need to create the build yourself to build the component from source.
              It has 10652 lines of code, 601 functions and 150 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed ansible-lint and discovered the below as its top functions. This is intended to give you an instant insight into ansible-lint implemented functionality, and help decide if they suit your requirements.
            • Returns the CLI command line arguments .
            • Executes a syntax check on a given lintable .
            • Reports failures to the list .
            • Merges values from configuration to cli config .
            • Check the presence of the ansible CLI module .
            • Requests to install a collection .
            • Retrieves a list of task handlers for a given child type .
            • Installs the galaxy role .
            • Normalize task .
            • Installs the specified requirement .
            Get all kandi verified functions for this library.

            ansible-lint Key Features

            No Key Features are available at this moment for ansible-lint.

            ansible-lint Examples and Code Snippets

            localops,Testing
            Shelldot img1Lines of Code : 40dot img1License : Permissive (MIT)
            copy iconCopy
            ~/projects/localops/test$ ./test-playbook.sh ../user/ansible-lint.yaml
            WARNING  Overriding detected file kind 'yaml' with 'playbook' for given positional argument: user/ansible-lint.yaml
            Static code check found no errors
            Testing ubuntu-18.04
            
            PLAY [a  
            Molecule Wrapper,Usage
            Shelldot img2Lines of Code : 24dot img2License : Permissive (MIT)
            copy iconCopy
            ./moleculew test
            
            Additional options:
              --ansible VERSION          Use the specified version of Ansible
              --docker-lib VERSION       Use the specified version of the Python Docker
                                         library
              --molecule VERSION         Use   
            Ansible development environment,Code
            HTMLdot img3Lines of Code : 6dot img3no licencesLicense : No License
            copy iconCopy
            # See if your code meets all rules.
            ansible-lint .
            # Test all scenarios.
            molecule test
            # Test a specific scenario.
            molecule test --scenario-name fedora-latest
              
            Installing Ansible Python package on Windows
            Pythondot img4Lines of Code : 59dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            FROM alpine:3.7
            
            ENV ANSIBLE_VERSION=2.5.4
            
            ENV BUILD_PACKAGES \
                    bash \
                    curl \
                    tar \
                    nano \
                    openssh-client \
                    sshpass \
                    git \
                    python \
                    py-boto \
                    py-dateutil \
             
            copy iconCopy
            └── default
                ├── dependency
                ├── create
                ├── prepare
                └── converge
            
            └── default
                ├── lint
                ├── dependency
                ├── cleanup
                ├── destroy
                ├── syntax
                ├── create
                ├── prepare
                ├── conve
            How to log in molecule?
            Pythondot img6Lines of Code : 23dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            ---
            dependency:
              name: galaxy
            driver:
              name: docker
            lint:
              name: yamllint
            platforms:
              - name: instance
                image: centos:7
            provisioner:
              name: ansible
              lint:
                name: ansible-lint
            scenario:
              name: default
            verifier:
              name: testinfr

            Community Discussions

            QUESTION

            How can I use the ruamel.yaml rtsc mode?
            Asked 2022-Mar-04 at 20:10

            I've been working on creating a YAML re-formatter based on ruamel.yaml (which you can see here). I'm currently using version 0.17.20.

            Cleaning up comments and whitespace has been difficult. I want to:

            • ensure there is only one space before the # for EOL comments
            • align full line comments with the key or item immediately following
            • remove duplicate blank lines so there is at most one blank line

            To get closer to achieving that, I have a custom Emitter class where I extend write_comment to adjust the comments just before writing with super().write_comment(...). However, the Emitter does not know about which key or item comes next because comments are generally attached as post comments.

            As I've studied the ruamel.yaml code to figure out how to do this, I found the rtsc mode (Round Trip Split Comments) which looks fantastic because it separates EOLComment, BlankLineComment and FullLineComment instead of lumping them together.

            From what I can tell, the Parser and Scanner have been adjusted to capture the comments. So, loading is (mostly?) implemented with this "NEWCMNT" implementation. But Emitter.write_comment expects CommentToken instead of comment line numbers, so dumping does not work yet.

            If I update my Emitter.write_comment method, is that enough to finish dumping? Or what else might be necessary? In one of my tries, I ran into a sys.exit in ScannedComments.assign_eol() - what else is needed to finish that?

            PS: I wouldn't normally ask how to collaborate on StackOverflow, but this is not a bug report or a feature request, and I'm trying/failing to use a new (undocumented) feature, so I'm filing this here instead of sourceforge.

            ...

            ANSWER

            Answered 2022-Mar-04 at 20:10

            rtsc is work in progress cq work started but unfinished. It's internals will almost certainly change.

            Two of the three points you indicate can relatively easy be implemented:

            • set the column of each comment to 0 ( by recursively going over a loaded data structure similar to here ) if the column is before the position of the end of the value on a line, you'll get one space between the value and the column

            • at the same time doing the recursion in the previous point. Take each comment value and do something like:

            Source https://stackoverflow.com/questions/71354698

            QUESTION

            Add `git remote add usptream` to repositories but using Ansible
            Asked 2021-Dec-29 at 18:44

            I have an Ansible 2.9.27 and I am trying to add upstream remote for git repositories which I previously cloned with Ansible. Let's assume that already cloned repositories are located in /home/user/Documents/github/ directory and I want to add upstream remote for them (git remote add upstream for each repo).

            The task looks like this:

            ...

            ANSWER

            Answered 2021-Dec-29 at 18:44

            Since what you want to achieve is not (yet...) taken in charge by the git module, this is a very legitimate use of command.

            In such cases, it is possible to silence the specific rule in ansible lint for that specific task.

            To go a bit further, your changed_when: false clause looks a bit like a quick and dirty fix to silence the no-changed-when rule and can be enhanced in conjunction with a failed_when clause to detect cases where the remote already exists.

            Here is how I would write that task to be idempotent, documented and passing all needed lint rules:

            Source https://stackoverflow.com/questions/70522682

            QUESTION

            A prettier way to handle spaces with enters in YAML
            Asked 2021-Dec-22 at 09:35

            This is more of a styling question. I have this ugly piece of code:

            ...

            ANSWER

            Answered 2021-Dec-21 at 20:51

            However, I can't use breaks, e.g. > or | since that will include spaces in the end result, and the code will error.

            That is actually only an half true statement.
            You can combine it with the whitespace control mechanism of Jinja to remove those unneeded whitespaces.

            Basically, adding a dash to the opening or the closing of an expression blocks do trim the extraneous whitespace or carriage return before or after it.

            Given:

            Source https://stackoverflow.com/questions/70441129

            QUESTION

            Gitlab - Separating CI from Deployment
            Asked 2021-Oct-14 at 19:21

            We are currently using Jenkins, and planning to migrate to Gitlab. We actually have 2 Jenkinsfiles in each repo, 1 is setup as a Multibranch pipeline and runs on all changes. Its is the merge check, that runs all the various linting, tests, building the docker containers etc. The second Jenkinsfile is only ran manually from Jenkins, it takes in all the various input parameters and it deploys the code. Which is mostly coming in from say, the linted Ansible/Terraform and selecting a docker image that would have already been built via the CI side of things.

            I know gitlab doesnt support this model, but this project is already MVP'd so re-working how the dev's combined their logic and deployment code together is probably not going to happen.

            Is it possibly, in 1 gitlab-ci.yml file to say run these jobs on merge/pushes and only run this on manual deployment .

            e.g.

            ...

            ANSWER

            Answered 2021-Oct-14 at 19:21

            There are multiple options to achieve your goal with minimized configuration effort:

            1. Working with private jobs and use inheritance or references for easier configuration - doable in one file
            2. Extract parts into child pipelines for easier usage
            reduced Configuration in one File

            I assume you most hate that you have to redefine the rules for your jobs. There are two ways how you can reduce those duplication.

            Inheritance

            Can reduce a lot of duplication, but can also cause problems, with unintended side behaviour.

            Source https://stackoverflow.com/questions/69571566

            QUESTION

            Can anyone see what I am doing wrong in the ansible playbook?
            Asked 2021-Jun-23 at 02:35

            Got the following odd error with ansible lint and I can't for the life of me figure out what we did wrong, it's probably something incredibly stupid but there you go.

            ...

            ANSWER

            Answered 2021-Jun-23 at 02:35

            That's a known issue with ansible-lint; upgrading to a more recent version such as 5.0.12 will make that go away. If it doesn't for your case, you can either comment on that issue or open a regression at which time you should provide the versions you are using

            Source https://stackoverflow.com/questions/68091008

            QUESTION

            Ansible best practice for unsafe variables?
            Asked 2021-May-19 at 09:27

            Is there a better solution than this?

            ...

            ANSWER

            Answered 2021-May-19 at 09:27

            You should just be able to use ansible filters to acheive what you're trying to do - in particular, have a look at the regex_replace filter - see https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#searching-strings-with-regular-expressions

            In your example, you can write

            Source https://stackoverflow.com/questions/67596658

            QUESTION

            Encountering an error decoupling tasks and vars from playbooks via roles
            Asked 2020-Dec-21 at 07:46

            To start, I have a basic ansible directory structure for roles.

            In the [ansible] directory:

            ...

            ANSWER

            Answered 2020-Dec-21 at 07:46

            Q: "gui_utils/tasks/main.yml:4 (couldn't resolve module/action 'tasks'."

            A: Remove the keyword tasks from ansible/gui_utils/tasks/main.yml. The task import_tasks is already in the tasks section of the playbook

            Source https://stackoverflow.com/questions/65387848

            QUESTION

            Ansible Lint trailing space
            Asked 2020-Oct-05 at 21:34

            I have performed ansible lint check on the below yml code, even though there is no trailing spaces, I'm receiving trailing whitespace warning for the indentation that has been given. Can you advice on how that can be overcome

            ...

            ANSWER

            Answered 2020-Oct-05 at 21:34

            I'll make wild guesses here (and will remove my answer if I'm totally wrong):

            • Your file has CRLF line endings (i.e. windows style line endings)
            • You are running ansible-lint < 4.0.0

            If my guesses are correct, you are suffering from a bug which has been fixed.

            Upgrade ansible-lint and your problem should go away:

            Source https://stackoverflow.com/questions/64139102

            QUESTION

            Run ansible-lint through subdirectories within a gitlab role
            Asked 2020-Sep-04 at 14:56

            I am trying to add a validation step to a gitlab repo holding a single ansible role (with no playbook). The structure of the role looks like :

            • .gitlab-ci.yml
            • tasks/
            • templates/
            • files/
            • vars/
            • handlers/

            With the gitlab-ci looking like :

            ...

            ANSWER

            Answered 2020-Sep-04 at 14:30

            You should certainly be able to pass multiple YAML files as arguments to ansible-lint. I have version 4.1.1a0, and I'm able to use it like this, for example:

            Source https://stackoverflow.com/questions/63742610

            QUESTION

            `git clone` fails for role in private git repo when running `ansible-galaxy install -r requirements.yml`
            Asked 2020-Jul-21 at 10:05

            I have added a .gitlab-ci.yml to my private project. One of the steps is to get a role from a private gitlab repo. However this fails with

            ...

            ANSWER

            Answered 2020-Jul-21 at 10:05

            Running the same command ansible-galaxy install -r requirements.yml on my machine runs fine.

            That means you have the right public/private key in ~/.ssh/id_rsa on your machine, and you are executing it locally with your account.

            If you copy it in your GitLab step, make sure to check the rights, and possible the passphrase and known_hosts, as in here or in the documentation:

            Source https://stackoverflow.com/questions/62967790

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install ansible-lint

            You can install using 'pip install ansible-lint' or download it from GitHub, PyPI.
            You can use ansible-lint like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/ansible-community/ansible-lint.git

          • CLI

            gh repo clone ansible-community/ansible-lint

          • sshUrl

            git@github.com:ansible-community/ansible-lint.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular DevOps Libraries

            ansible

            by ansible

            devops-exercises

            by bregman-arie

            core

            by dotnet

            semantic-release

            by semantic-release

            Carthage

            by Carthage

            Try Top Libraries by ansible-community

            molecule

            by ansible-communityPython

            ara

            by ansible-communityPython

            ansible-bender

            by ansible-communityPython

            ansible-consul

            by ansible-communityHTML

            ansible-vault

            by ansible-communityHTML