Comments (6)
My first guess would be that it is dependent on the order of variable/task resolution in Ansible. IIRC, before Ansible touches the tasks in any way, all variables are resolved first, including lookups.
In the test_fail.yml
playbook, the lookup is resolved by Ansible too late, it wants to run all tasks at this point. Not sure what's exactly happening there, you could add a register to that task and debug the output.
In the test_success.yml
playbook, Ansible first resolves the play variables, so it has a chance to properly perform the lookup. Next, the task already has the correct path from the lookup so Ansible can process it and include other tasks as you expect.
Remember, that in DebOps, all lookups using custom hooks are performed on the role level, not on the playbook level. IIRC this has its own rules regarding variable/task resolution by Ansible, and that's the reason these lookups work in the roles.
from debops-tools.
The same issue appear if hook called from debops.users role. It was the first things I tried. This example was my attempt to create simplified version.
Here is updated example that based on roles: https://www.dropbox.com/s/n2z14b0a35i1j77/debops-test_1.zip?dl=0
As I understand it is impossible to call another role from hook, right? So, the only way to split code called in hook that I see is to use includes. What happens: lookup itself work fine and include code from hook (post_main), but if hook itself has include task - include will be ignored (no error messages :( ). So, include from inside hook doesn't work (including case when hook was called from role), but all tasks from hook prior to this include task will work as expected.
I will be glad for any solution/example where hook code spitted into several files. I will appreciate If you point me to any example code where such splitted hook demonstrated. Thanks.
from debops-tools.
You're correct, the lookup plugins aren't recursive, so includes present in the included task list won't work. Fixing that would probably require copying at least some code from Ansible that handles include parsing and I think this is outside of the scope of these plugins.
You cannot include other roles using lookup plugins as well, this is meant only for task lists. The task_src
lookup plugin was meant to be used to "inject" 2-3 tasks from a file somewhere, in a case where you don't want to write a custom role that replaces the one you are trying to "augment". From your case it seems that you want to extend debops.users
beyond what task_src
does, so I would just write a replacement debops.users
role and put it in the DebOps project directory, in ansible/roles/
. That way it should "mask" the default debops.users
and let you easily do what you want.
from debops-tools.
I see. I am not realized that it is possible to "mask" default roles. That solution will work for me too. Probably will need to merge changes from time to time, but it is ok. Thanks!!
from debops-tools.
@vshalts Great. One of the core ideas of DebOps is that roles and playbooks are "read-only" to allow updates using git
, therefore there should always be a way to allow user customization. Using roles_path
variable to "mask" roles with your own custom ones is one such method of doing that. It's not always perfect, especially when you access things outside of the role itself, so I try not to do that and use different methods to pass data between roles.
from debops-tools.
I'll try my best :) Thanks for suggestion!!
from debops-tools.
Related Issues (20)
- Check code signatures
- Move `debops.keyring` Python module into this repo
- Refactor Python modules
- Signed PyPI releases
- debops-update: fails when ansible_managed contains variables
- Document subcommands
- Please enlighten me how to workaround this particular failure I noted HOT 12
- MS Windows Support? HOT 5
- Update http://debops.org/ to https://debops.org/ in repo description HOT 1
- README randomly lists 1 out of 3 dependencies
- provide a commented example config of how to use template_src HOT 1
- debops-padlock unusable with encfs > 1.9 HOT 6
- Raspbian detected as Debian HOT 4
- debops-update has no --dry-run argument HOT 2
- Debops inserts faulty Ansible ppa sources into sources.list HOT 1
- ERROR! Unexpected Exception: invalid syntax (profile_tasks.py, line 68)
- Broken Link for "Getting Started Guide" HOT 3
- wrong pathes for lookup_plugins in ansible.cfg HOT 5
- quoting directories with spaces in ansible.cfg breaks with 2.7 HOT 6
- Bootstrap: Variables from group_vars/all/bootstrap.yml not getting picked up HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from debops-tools.