Skip to content
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

Refactor(eos_designs): Move debug vars dump to action plugin instead of it's own task #4540

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,22 @@ def run(self, tmp: Any = None, task_vars: dict | None = None) -> dict:
profiler = cProfile.Profile()
profiler.enable()

hostname = task_vars["inventory_hostname"]

if self._task.args.get("debug_vars") is True and (debug_vars_file := self._task.args.get("debug_vars_file")):
carlbuchmann marked this conversation as resolved.
Show resolved Hide resolved
# Dump all hostvars to a file.
write_file(yaml.dump(task_vars["hostvars"][hostname], Dumper=AnsibleDumper, indent=2, sort_keys=False, width=2147483647), debug_vars_file)

if self._task.args.get("structured_config") is False:
# Not creating structured config
return result

eos_designs_custom_templates = self._task.args.get("eos_designs_custom_templates", [])
filename = str(self._task.args.get("dest", ""))
file_mode = str(self._task.args.get("mode", "0o664"))
template_output = self._task.args.get("template_output", False)
validation_mode = self._task.args.get("validation_mode")

hostname = task_vars["inventory_hostname"]

task_vars["switch"] = get(task_vars, f"avd_switch_facts..{hostname}..switch", separator="..", default={})

# Read ansible variables and perform templating to support inline jinja2
Expand Down
14 changes: 4 additions & 10 deletions ansible_collections/arista/avd/roles/eos_designs/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,17 @@
check_mode: false
run_once: true

- name: Generate YAML file with hostvars (only for debugging)
when: avd_eos_designs_debug | arista.avd.default(false)
ansible.builtin.template:
src: debug/generate-debug-vars.j2
dest: "{{ structured_dir }}/{{ inventory_hostname }}-debug-vars.yml"
mode: "0o664"
delegate_to: localhost
changed_when: false

- name: Generate device configuration in structured format
when: avd_eos_designs_structured_config | arista.avd.default(true)
when: avd_eos_designs_structured_config | arista.avd.default(true) or avd_eos_designs_debug | arista.avd.default(false)
arista.avd.eos_designs_structured_config:
eos_designs_custom_templates: "{{ eos_designs_custom_templates | arista.avd.default([]) }}"
dest: "{{ structured_dir }}/{{ inventory_hostname }}.{{ avd_structured_config_file_format }}"
# cprofile_file: "structured-{{inventory_hostname}}.prof"
template_output: true
validation_mode: "{{ avd_data_validation_mode }}"
structured_config: "{{ avd_eos_designs_structured_config | arista.avd.default(true) }}"
debug_vars: "{{ avd_eos_designs_debug | arista.avd.default(false) }}"
debug_vars_file: "{{ structured_dir }}/{{ inventory_hostname }}-debug-vars.yml"
delegate_to: localhost
check_mode: false
register: structured_config
Expand Down

This file was deleted.

Loading