-
Notifications
You must be signed in to change notification settings - Fork 51
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
Inventory fix #259
base: devel
Are you sure you want to change the base?
Inventory fix #259
Conversation
@@ -2,15 +2,12 @@ | |||
|
|||
{% for group_key in aap_setup_prep_inv_nodes %} | |||
|
|||
{%if group_key in groups %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change, believe this would break the entire template, can you share how its breaking versus the examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sean-m-sullivan thank you for the review. It wasn't broken till now because the change in PR 8363732 is not yet included in current release i.e. 2.5.2.
Here is the code to test this one
variables.yml
(not a complete one, just including the important ones for testing this)
aap_setup_prep_inv_nodes:
automationcontroller:
ctr1.example.com:
ctr2.example.com:
database:
db.example.com:
aap_setup_prep_inv_vars:
automationcontroller:
node_type: hybrid
ignore_preflight_errors: true
database:
ignore_preflight_errors: true
all:
pg_database: "awx"
pg_username: "awx"
pg_sslmode: "prefer"
receptor_listener_port: 27199
inventory.j2
(part of the snippet from the actual code)
{% for group_key in aap_setup_prep_inv_nodes %}
{%if group_key in groups %}
[{{ group_key }}]
{% for node_key in aap_setup_prep_inv_nodes[group_key] %}
{{ node_key }}{% if aap_setup_prep_inv_nodes[group_key][node_key] is defined %} {{ aap_setup_prep_inv_nodes[group_key][node_key] }}{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
pr_test.yml
(playbook to test on localhost)
---
- hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Populate AAP setup.sh inventory file from template
ansible.builtin.template:
src: inventory.j2
dest: inventory
mode: "640"
- Run the code to test
# ansible-playbook -i localhost, -e "@vars.yml" pr_test.yml
This will result in a inventory
file created with empty content because of the if
jinja2 conditional.
- Remove the
if
andendif
jinja conditional from theinventory.j2
and re-run the test to check the inventory file creation.
What does this PR do?
Fixes the incorrect inventory generation when the user provided group names don't match with the expected groups in
aap_setup_prep_inv_nodes
variable.How should this be tested?
Automated tests are preferred, but not always doable - especially for infrastructure. Include commands to run your new feature, and also post-run commands to validate that it worked. (please use code blocks to format code samples)
All details regarding this is provided in Issue #258
Is there a relevant Issue open for this?
Provide a link to any open issues that describe the problem you are solving.
resolves #258
Other Relevant info, PRs, etc
This PR is basically reverting the code changed in 8363732