New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to not import host variables in to AWX when sourcing inventory from SCM #1280
Comments
What is the reason you would like it to behave that way? |
|
cc @AlanCoding Re: #991 - that is a different issue, we would not solve it this way. For the first item... can you provide more detail on the setup/structure of your inventory and playbook repo? |
I poked at this recently, and I would claim that the behavior reported in #991 has nothing to do with inventory updates. The problem is that we run inventory through a JSON pipeline. The standard does not support certain types in certain places (like integer keys). Even if you assumed that we solved this in inventory updates (which would be a very backwards thing to do first), then the playbooks still won't be using the accurate types.
It sounds like you might have discovered this already. Even if you entered in the types you wanted into the UI manually as YAML, I don't expect they would be reflected in your playbook correctly. Because, again, using JSON carries with it fundamental data type constraints. Now, there might be some interesting cases where vars are defined in both the inventory folder and the playbook folder, and I would certainly test and triage those vars precedence issues if we knew exactly what we were looking at. |
ensure correct auth and system configuration forms are loaded
@AlanCoding with AWX, variables defined in inventory folders (from a project) become dynamic inventory variables due to Using AWX and static inventory (from a project), it should be possible to bypass |
The extra layer of
This is just now how AWX is designed. You could possibly hack your config to point the inventory to some file in your project source (for the playbook), but doing so would break the linkage between the Ansible host & the DB host, and this will break a lot, because it was not designed to work this way. Maybe you could add in a vars manager plugin (inside the project source), so that the vars are altered instead of the inventory content itself. |
Any further thoughts on allowing this as a simple check box when creating inventories? I'm trying to avoid the need to create multiple inventories each time I may need to do some development testing where I'm changing variables belonging to hosts (either via ini files or yaml files e.g. inventory/SITE/group_vars/all.yaml) If I could just import the list of hosts and groups they belong to without their variables I don't need to duplicate inventories. This would also work well with the new prompt for project feature that was added in AWX 7.0.0 |
^ You should be able to use variables sourced from |
So I'm currently using the Alternative dir layout as per the Ansible best practices documentation https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html I'm not sure that even if I moved my group vars from I'd rather not do this anyway. Is it a lot of work not to stop the import of vars? |
Why do you think you need this? I have so-far failed to construct a story in my head where this makes sense as a solution to a problem. If you need different variables for various hosts for jobs using different source trees, then you have playbook adjacent variables. If you don't, then that's fine. But I'm reading that you're not trying to apply different playbook-source-dependent variables but for some reason, you want host and group vars from the inventory content gone. That's not an end goal, and I don't see any end goal that it would aid in achieving. |
Under some conditions - the inventory source is set to update on launch. It's an SCM source and shares the same project with the job template. In those narrow conditions this is an agreeable expectation. |
The best solution would be for the AWX inventory to not import variables from an SCM source. That way the SCM project branch is correctly respected even when the branch is overridden. This also allows the AWX inventory variables to be treated with a higher precedence so that they can represent values needed to run the project in the AWX environment and not just plain ansible. Also, this would add support for vaulted files in the project which isn't allowed right now. The work required is limited to reworking the SCM inventory source and wouldn't affect the rest of AWX. |
ISSUE TYPE
COMPONENT NAME
SUMMARY
Add option to not import host variables in to AWX when sourcing inventory from SCM
ENVIRONMENT
STEPS TO REPRODUCE
I would like the option for AWX to not import any varibles from SCM so when Ansible is run it continues to use variables inside the project folder.
The text was updated successfully, but these errors were encountered: