Closed ssasso closed 1 month ago
So you'd like extra config to be very last? I can try to fix that, but it will be a bit messy. Right now, we append the plugin config to the extra config. Prepending wouldn't work unless we define plugin dependencies (which we could) as it would turn around the plugin order
In any case, the final order is computed somewhere close to Ansible output module to deal with the crappy way Ansible implements loops.
Ok, I will deal with it, no problem.
And will deal with ansible loop odd-ity (which in any case has a different order for igw01 and igw02)
Can't reproduce your behavior. This is the order in which the extra configs would be executed for me (from group_vars/custom_configs/topology.yml
):
netlab_custom_config:
- extra-igw02.j2
- extra-igw01.j2
- bgp.session
- bgp.policy
Still, the extra config should be applied after plugin config, so I'll fix that.
OK, I added the code that makes sure the plugin custom configs are execute before node custom configs. The plugin configs should execute before the node configs no matter what, the exact order of node config execution is unknown as I'm using sets and topological sort (where not everything is strictly comparable) and you know the sets are not ordered and topological sort can result in multiple "correct" orders.
Would still love to see your group_vars/custom_configs/topology.yml
(before pulling down the fix ;)
(sorry for the delay)
This is the content of the file when I opened this issue:
# Ansible inventory created from ['/root/TOPOLOGIES/bugs/extra_disorder/topology.yml', 'package:topology-defaults.yml']
#
netlab_custom_config:
- extra-igw02.j2
- extra-igw01.j2
- bgp.session
- bgp.policy
So the order here is respecting what you said... but ansible for whatever reason decided to use a different one :/
And this is the file with the latest dev:
# Ansible inventory created from ['/root/TOPOLOGIES/bugs/extra_disorder/topology.yml', 'package:topology-defaults.yml']
#
netlab_custom_config:
- bgp.session
- bgp.policy
- extra-igw02.j2
- extra-igw01.j2
Thanks for the follow-up information. In any case, we fixed the "plugins before custom configs" dilemma.
As for "Ansible will do stuff in whatever order it likes", I'm no longer surprised. FWIW: what Ansible version are you using?
root@hippo:~# ansible --version
ansible [core 2.13.13]
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.8.10 (default, Nov 22 2023, 10:22:35) [GCC 9.4.0]
jinja version = 3.1.4
libyaml = True
Thank you. I thought we fixed the reordering for good, particularly after I implemented the same tricks described in https://blog.ipspace.net/2022/03/ansible-reorder-list-values.html to custom configs.
On a more positive note, you're using a somewhat older release (corresponding to Ansible 6.x). I'm on 9.1 (Ansible core 2.16) and haven't experienced reordering (lately), so let's hope they got their **** together.
Given this topology extract:
I would have expected that the extra config defined at node level would have been execute at the end of other configurations.
Instead, I have a slightly different behavior for igw01 and igw02:
Will try to figure out what causes this "dis-order".