* Improve host_group_vars efficiency:
* normalize the basedir with `os.path.realpath()` once and cache it
* cache missing paths/files
* reduce the calls to `isinstance`
Add a couple more general improvements in vars/plugins.py get_vars_from_path():
* call `PluginLoader.all()` once for vars plugins and reload specific
plugins subsequently
* don't reload legacy/builtin vars plugins that are not enabled
Add a test for host_group_vars and legacy plugin loading
Co-authored-by: Matt Davis <mrd@redhat.com>
* changelog
* Add a new is_stateless attribute to the vars plugin baseclass
update integration tests to be quieter and use the same test pattern
Fix deprecation and adjust test that didn't catch the issue (deprecation only occured when the value was False)
move realpath cache to host_group_vars (do not smuggle call state as instance data)
refactor under a single 'if cache:' statement
Call os.path.isdir instead of always calling os.path.exists first. Just call os.path.exists to differentiate between missing and non-directory.
remove call to super(VarsModule, self).get_vars()
use the entity name as the cache key instead of variable location
Remove isinstance checks and use a class attribute just in case any plugins are subclassing Host/Group
Replace startswith by checking index 0 of the name instead, since host/group names are required
* rename is_stateless to cache_instance to make it more clear what it does
* add plugin instance cache using the path to plugin loader
reduce loading stage option if a new instance isn't created
don't require a known subdir on PluginLoader instantiation for backwards
compatibility
rename attribute again
contain reading from/initializing cached instances to a plugin loader method
* Deprecate v2 vars plugins
* Refactor to use the cache in existing plugin loader methods
Rename the attribute again
Refactor host_group_vars with requested changes
Make changelog a bugfixes fragment
Add a deprecation fragment for v2 vars plugins.
Add type hints
* unbreak group_vars
* Apply suggestions from code review
* misc tweaks
* always cache instance by both requested and resolved FQ name
* add lru_cache to stage calculation to avoid repeated config consultation
* handle KeyError from missing stage option
---------
Co-authored-by: Matt Davis <mrd@redhat.com>
(cherry picked from commit
|
2 years ago | |
|---|---|---|
| .azure-pipelines | 2 years ago | |
| .github | 2 years ago | |
| bin | 4 years ago | |
| changelogs | 2 years ago | |
| hacking | 2 years ago | |
| lib/ansible | 2 years ago | |
| licenses | 4 years ago | |
| packaging | 2 years ago | |
| test | 2 years ago | |
| .cherry_picker.toml | 8 years ago | |
| .git-blame-ignore-revs | 3 years ago | |
| .gitattributes | 5 years ago | |
| .gitignore | 3 years ago | |
| .mailmap | 8 years ago | |
| COPYING | 3 years ago | |
| MANIFEST.in | 2 years ago | |
| README.md | 2 years ago | |
| pyproject.toml | 2 years ago | |
| requirements.txt | 2 years ago | |
| setup.cfg | 2 years ago | |
| setup.py | 4 years ago | |
README.md
Ansible
Ansible is a radically simple IT automation system. It handles configuration management, application deployment, cloud provisioning, ad-hoc task execution, network automation, and multi-node orchestration. Ansible makes complex changes like zero-downtime rolling updates with load balancers easy. More information on the Ansible website.
Design Principles
- Have an extremely simple setup process with a minimal learning curve.
- Manage machines quickly and in parallel.
- Avoid custom-agents and additional open ports, be agentless by leveraging the existing SSH daemon.
- Describe infrastructure in a language that is both machine and human friendly.
- Focus on security and easy auditability/review/rewriting of content.
- Manage new remote machines instantly, without bootstrapping any software.
- Allow module development in any dynamic language, not just Python.
- Be usable as non-root.
- Be the easiest IT automation system to use, ever.
Use Ansible
You can install a released version of Ansible with pip or a package manager. See our
installation guide for details on installing Ansible
on a variety of platforms.
Power users and developers can run the devel branch, which has the latest
features and fixes, directly. Although it is reasonably stable, you are more likely to encounter
breaking changes when running the devel branch. We recommend getting involved
in the Ansible community if you want to run the devel branch.
Get Involved
- Read Community Information for all kinds of ways to contribute to and interact with the project, including mailing list information and how to submit bug reports and code to Ansible.
- Join a Working Group, an organized community devoted to a specific technology domain or platform.
- Submit a proposed code update through a pull request to the
develbranch. - Talk to us before making larger changes to avoid duplicate efforts. This not only helps everyone know what is going on, but it also helps save time and effort if we decide some changes are needed.
- For a list of email lists, IRC channels and Working Groups, see the Communication page
Coding Guidelines
We document our Coding Guidelines in the Developer Guide. We particularly suggest you review:
Branch Info
- The
develbranch corresponds to the release actively under development. - The
stable-2.Xbranches correspond to stable releases. - Create a branch based on
develand set up a dev environment if you want to open a PR. - See the Ansible release and maintenance page for information about active branches.
Roadmap
Based on team and community feedback, an initial roadmap will be published for a major or minor version (ex: 2.7, 2.8). The Ansible Roadmap page details what is planned and how to influence the roadmap.
Authors
Ansible was created by Michael DeHaan and has contributions from over 5000 users (and growing). Thanks everyone!
Ansible is sponsored by Red Hat, Inc.
License
GNU General Public License v3.0 or later
See COPYING to see the full text.