ansible | radically simple IT automation platform | DevOps library

 by   ansible Python Version: 9.0.0rc1 License: GPL-3.0

kandi X-RAY | ansible Summary

kandi X-RAY | ansible Summary

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

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems.

            kandi-support Support

              ansible has a highly active ecosystem.
              It has 57697 star(s) with 23418 fork(s). There are 1941 watchers for this library.
              There were 4 major release(s) in the last 6 months.
              There are 645 open issues and 30866 have been closed. On average issues are closed in 347 days. There are 310 open pull requests and 0 closed requests.
              It has a negative sentiment in the developer community.
              The latest version of ansible is 9.0.0rc1

            kandi-Quality Quality

              ansible has 0 bugs and 0 code smells.

            kandi-Security Security

              ansible has 2 vulnerability issues reported (0 critical, 0 high, 2 medium, 0 low).
              ansible code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              ansible 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 releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              ansible saves you 1647488 person hours of effort in developing the same functionality from scratch.
              It has 701196 lines of code, 24946 functions and 3494 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed ansible and discovered the below as its top functions. This is intended to give you an instant insight into ansible implemented functionality, and help decide if they suit your requirements.
            • Run AnsibleModule
            • Return an error message about the required library
            • Convert obj to text
            • Spawn the daemon
            • Create a symlink
            • Convert obj to bytes
            • Ensures that the file is present in the destination
            • Sets the mode of the given path
            • Recursively change ownership of a directory
            • Run a wrapped module
            • Construct a rule string
            • Enforces the host state
            • Determine if this file is unarchived
            • List all files in the archive
            • Convert a permstr to octal mode
            • Return CRC32 for a given path
            • Get service tools
            • Get the status of the service
            • Recursively change the owner of a directory
            • Enable the service
            • Return distro release info
            • Runs Ansible module
            • Create a new user
            • Construct the rule
            • Enforce the state of a host
            • Set the mode of a file or a diff
            • Enable the service
            • Modify usermod
            • Ensures that a file exists
            • Modify the user
            • Enable new service
            • Ensure a symlink exists
            • Start the daemon
            • Create a user
            Get all kandi verified functions for this library.

            ansible Key Features

            No Key Features are available at this moment for ansible.

            ansible Examples and Code Snippets

            Returns true if a unique path matches the given ansible solution .
            javadot img1Lines of Code : 14dot img1License : Permissive (MIT License)
            copy iconCopy
            public static boolean uniquePaths(int m , int n , int ans) {
                    int []dp = new int[n];
                    for (int i=1; i  
            Ansible playbook loop only calling final loop
            Pythondot img2Lines of Code : 11dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
                - name: Generate Switch Configurations
                    dest_dir: /home/usr/complete_config/{{ project_name }}
                    switch_device_name: '{{ device_name|lower }}-{{ site_abbrev|lower }}-{{ item.installation_floor }}{{ "%02d" | for
            Iterate over a nested YAML Object Tree
            Pythondot img3Lines of Code : 149dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            ├── filter_plugins
            │   └──
            └── playbook.yml
            class FilterModule(object):
                def __init__(self):
                def filters(self):
                    return {
            Ansible parsing a JSON Object
            Pythondot img4Lines of Code : 17dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
                  - /Manager/tes/objects/bew/13
                  completedTime: 2022-03-16T...
                  createdTime: 2022....
            "{{ result_job.json.affectedResources.0 }}"
            Ansible parsing a JSON Object
            Pythondot img5Lines of Code : 21dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            "msg": {
                   "affectedResources": [
                "completedTime": "2022-03-16T..."
                "createdTime": "2022...."
            # Navigate to the appropriate element in the JSON object
            copy iconCopy
            - hosts: localhost
              gather_facts: no
                json: "{{ lookup('file', './file2.json') | from_json }}"
                - name: display
                    msg: "{{ }} -> {{ cpath[0]['server-start'][2]['java-home'] }}"
            Ansible variable is defined, yet default filter still gets processed
            Pythondot img7Lines of Code : 53dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            - name: Three
                second_test_var: >-
                      if test_var is defined 
                      else groups | my_custom_filter_plugin("should not execute") 
            - hosts: localhost
            CLI Command result to json using Ansible
            Pythondot img8Lines of Code : 37dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            shell> cat hosts
            shell> cat playbook.yml
            - name: Playbook
              hosts: all
              gather_facts: false
              - set_fact:
                      - TABLE_vrf:
            Ansible Firewalld Module Not Found
            Pythondot img9Lines of Code : 2dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            ansible-galaxy collection install ansible.posix
            Ansible version sort filter error - AttributeError: 'map' object has no attribute 'pop'
            Pythondot img10Lines of Code : 4dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            l = map(str, l)
            l = list(map(str, l))

            Community Discussions


            Ansible playbook loop from site yaml or template?
            Asked 2022-Apr-01 at 14:16

            I'm trying to use my Ansible playbook to call upon a site YAML reference to create a filename that increment for multiple switches. What am I doing wrong? I believe the playbook is pulling from the host YAML?

            Format: --.txt

            e.g.: with two switches:

            • swi-lon-101.txt
            • swi-lon-202.txt




            Answered 2022-Mar-31 at 18:39

            So, you do need a loop in order to set this fact, otherwise, you are trying to access a installation_floor on a list, which cannot be.

            You will also face an issue with the id of your items in switch_stacks, as 01 is an int and will end up displayed as 1, simply. So you either need to declare those as string, or to pad them with a format filter.

            So, you end up with this task:



            Line too long: Ansible lint
            Asked 2022-Mar-28 at 18:27

            This is my ansible code



            Answered 2022-Mar-28 at 15:22

            If you want to obey the lint line length rule, you need to split your url on several lines.

            > is the yaml folded scalar block indicator: new lines will be replaced by spaces. This is not what you want.

            The best solution here is to use a double quoted flow scalar where you can escape new lines so that they are not converted to white spaces, e.g.:



            Ansible update variable in function
            Asked 2022-Mar-15 at 14:40

            I made a playbook with two task

            The first task is for getting all the directories in the selected directory.
            The second task is for deleting the directories. But, I only want to delete a directory if the list length is longer than two.



            Answered 2022-Mar-15 at 14:40

            This won't be possible, once a module is executed, the result is saved in the variable and won't dynamically change with the state of the node.

            What you should do instead is to limit the list you are looping on with a slice notation to exclude the three last items of the said list: files[:-3].

            So, your task deleting files would look like this:



            Can I specify that an argument can't be used with a specific choice in Ansible module spec?
            Asked 2022-Mar-12 at 16:17

            I'm looking for a way of specifying that a module argument can't be used if another argument has a certain value. You can specify required_if to require an argument if another argument has a specific value but I need the opposite. Something that's conceptually similar to mutually_exclusive and might be called forbidden_if.

            I'm developing a module that creates a login for an SQL server. It can either be a SQL login that's specific to the server or a Windows log in that uses the domain controller. For an SQL login you must specify a password for but you can't for Windows as this is set by the domain controller. Logins have an identifier (SID) that may be specified by the user for SQL logins but can't be for Window.

            Although it's a Powershell module for a Windows host I'll use Python examples because that's what the documentation is in.

            This is the spec for a module that creates an SQL login



            Answered 2022-Mar-12 at 16:17

            I don't see a solution to your problem without coding the test:



            Ansible: how to achieve idempotence with tasks that append files on host (w/o reverting to initial state)
            Asked 2022-Mar-02 at 14:22

            I am having a hard time getting to know how to create Ansible roles that are following the best practices according to documentation. The following use-case which I am looking at is e.g. enabling Filebeat on host. Filebeat can be configured by placing a module definition in /etc/filebeat/modules.d folder.

            It works fine when I am adding modules. Idempotence is working, everytime, on each run of the role (playbook), a given set of modules is enabled.

            But what I should do when I decide that a given module is not longer needed? I remove it from role, rerun a playbook, so that all other modules are enabled. But: the previous run enabled a module that I am not installing directly with role after changes. So my server state is still altered in a way that is different than the role is imposing itself.

            My question is: should I take care of removing modules before I apply them so I always start from, let's say, fresh state?




            Answered 2022-Mar-02 at 11:07


            Ansible: Show last X output lines
            Asked 2022-Jan-26 at 00:00

            Is there a way to output only the last 5 lines of an Ansible shell output, for example?
            Maybe using loops?




            Answered 2022-Jan-26 at 00:00


            Ansible, how to set a global fact using roles?
            Asked 2022-Jan-24 at 20:03

            I'm trying to use Ansible to deploy a small k3s cluster with just two server nodes at the moment. Deploying the first server node, which I refer to as "master" is easy to set up with Ansible. However, setting up the second server node, which I refer to as "node" is giving me a challenge because I need to pull the value of the node-token from the master and use it to call the k3s install command on the "node" vm.

            I'm using Ansible roles, and this is what my playbook looks like:



            Answered 2022-Jan-24 at 20:03

            If you set the variable for master only it's not available for other hosts, e.g.



            I compiled R from source and it doesn't find certificates
            Asked 2022-Jan-14 at 17:25

            I am deploying multiple R versions on multiple virtual desktops. I've built 3.6.3 and 4.1.2 R from source on Ubuntu 18.04.3 LTS. None of them finds the system-wide file in /etc/R or the system certificates in /usr/share/ca-certificates. However R (3.4.4) installed with APT has no such problems. I used Ansible, but for the sake of this question I reproduced the deployment for one host with a shell script.



            Answered 2022-Jan-14 at 17:25

            Finally I found the solution:

            Since both system has the arch and OS. I cross copied the R compiled installations between them. The R which was compiled on the problematic system, but was run on the correct one gave the warnings below after the calling of the install.packages("renv", repos="")



            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:



            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:



            AWX all jobs stop processing and hang indefinitely -- why
            Asked 2021-Dec-21 at 14:42

            We've had a working Ansible AWX instance running on v5.0.0 for over a year, and suddenly all jobs stop working -- no output is rendered. They will start "running" but hang indefinitely without printing out any logging.

            The AWX instance is running in a docker compose container setup as defined here:


            Standard troubleshooting such as restarting of containers, host OS, etc. hasn't helped. No configuration changes in either environment.

            Upon debugging an actual playbook command, we observe that the command to run a playbook from the UI is like the below:

            ssh-agent sh -c ssh-add /tmp/awx_11021_0fmwm5uz/artifacts/11021/ssh_key_data && rm -f /tmp/awx_11021_0fmwm5uz/artifacts/11021/ssh_key_data && ansible-playbook -vvvvv -u ubuntu --become --ask-vault-pass -i /tmp/awx_11021_0fmwm5uz/tmppo7rcdqn -e @/tmp/awx_11021_0fmwm5uz/env/extravars playbook.yml

            That's broken down into three commands in sequence:

            1. ssh-agent sh -c ssh-add /tmp/awx_11021_0fmwm5uz/artifacts/11021/ssh_key_data
            2. rm -f /tmp/awx_11021_0fmwm5uz/artifacts/11021/ssh_key_data
            3. ansible-playbook -vvvvv -u ubuntu --become --ask-vault-pass -i /tmp/awx_11021_0fmwm5uz/tmppo7rcdqn -e @/tmp/awx_11021_0fmwm5uz/env/extravars playbook.yml

            You can see in part 3, the -vvvvv is the debugging argument -- however, the hang is happening on command #1. Which has nothing to do with ansible or AWX specifically, but it's not going to get us much debugging info.

            I tried doing an strace to see what is going on, but for reasons given below, it is pretty difficult to follow what it is actually hanging on. I can provide this output if it might help.


            So one natural question with command #1 -- what is 'ssh_key_data'?

            Well it's what we set up to be the Machine credential in AWX (an SSH key) -- it hasn't changed in a while and it works just fine when used in a direct SSH command. It's also apparently being set up by AWX as a file pipe:

            prw------- 1 root root 0 Dec 10 08:29 ssh_key_data

            Which starts to explain why it could be potentially hanging (if nothing is being read in from the other side of the pipe).

            Running a normal ansible-playbook from command line (and supplying the SSH key in a more normal way) works just fine, so we can still deploy, but only via CLI right now -- it's just AWX that is broken.


            So the question then becomes "why now"? And "how to debug"? I have checked the health of awx_postgres, and verified that indeed the Machine credential is present in an expected format (in the main_credential table). I have also verified that can use ssh-agent on the awx_task container without the use of that pipe keyfile. So it really seems to be this piped file that is the problem -- but I haven't been able to glean from any logs where the other side of the pipe (sender) is supposed to be or why they aren't sending the data.



            Answered 2021-Dec-13 at 04:21

            Had the same issue starting this Friday in the same timeframe as you. Turned out that Crowdstrike (falcon sensor) Agent was the culprit. I'm guessing they pushed a definition update that is breaking or blocking fifo pipes. When we stopped the CS agent, AWX started working correctly again, with no issues. See if you are running a similar security product.


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


            No vulnerabilities reported

            Install ansible

            You can install using 'pip install ansible' or download it from GitHub, PyPI.
            You can use ansible 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.


            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
          • PyPI

            pip install ansible

          • CLONE
          • HTTPS


          • CLI

            gh repo clone ansible/ansible

          • sshUrl


          • 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


            by ansible


            by bregman-arie


            by dotnet


            by semantic-release


            by Carthage

            Try Top Libraries by ansible


            by ansiblePython


            by ansibleShell


            by ansiblePython


            by ansiblePython


            by ansiblePython