---
- name: Gather EOS configuration
  eos_command:
    commands: 'show running-config all | exclude \.\*'
    provider: "{{ provider|default(omit) }}"
    auth_pass: "{{ auth_pass|default(omit) }}"
    authorize: "{{ authorize|default(omit) }}"
    host: "{{ host|default(omit) }}"
    password: "{{ password|default(omit) }}"
    port: "{{ port|default(omit) }}"
    transport: 'cli'
    use_ssl: "{{ use_ssl|default(omit) }}"
    username: "{{ username|default(omit) }}"
  register: output

- name: Save EOS configuration
  set_fact:
    base_config: "{{ output.result[0] }}"

- name: Configure Arista EOS interfaces
  eos_template:
    src: interface.j2
    include_defaults: true
    config: "{{ base_config | default(omit) }}"
    auth_pass: "{{ auth_pass | default(omit) }}"
    authorize: "{{ authorize | default(omit) }}"
    host: "{{ host | default(omit) }}"
    password: "{{ password | default(omit) }}"
    port: "{{ port | default(omit) }}"
    provider: "{{ provider | default(omit) }}"
    transport: 'cli'
    use_ssl: "{{ use_ssl | default(omit) }}"
    username: "{{ username | default(omit) }}"
  when: interfaces is defined and item.name|mandatory
  with_items: "{{ interfaces }}"

---
- name: Gather EOS configuration
  eos_command:
    commands: 'show running-config all'
    provider: "{{ provider|default(omit) }}"
    auth_pass: "{{ auth_pass|default(omit) }}"
    authorize: "{{ authorize|default(omit) }}"
    host: "{{ host|default(omit) }}"
    password: "{{ password|default(omit) }}"
    port: "{{ port|default(omit) }}"
    transport: 'cli'
    use_ssl: "{{ use_ssl|default(omit) }}"
    username: "{{ username|default(omit) }}"
  register: output
  no_log: "{{ no_log|default(true) }}"
  when: base_config is not defined

- name: Save EOS configuration
  set_fact:
    base_config: "{{ output.stdout[0] }}"
  no_log: "{{ no_log|default(true) }}"
  when: base_config is not defined

- name: Configure Arista EOS interfaces
  eos_template:
    src: interface.j2
    include_defaults: true
    config: "{{ base_config | default(omit) }}"
    auth_pass: "{{ auth_pass | default(omit) }}"
    authorize: "{{ authorize | default(omit) }}"
    host: "{{ host | default(omit) }}"
    password: "{{ password | default(omit) }}"
    port: "{{ port | default(omit) }}"
    provider: "{{ provider | default(omit) }}"
    transport: 'cli'
    use_ssl: "{{ use_ssl | default(omit) }}"
    username: "{{ username | default(omit) }}"
  when: interfaces is defined and item.name|mandatory
  with_items: "{{ interfaces }}"

Update get/save EOS config tasks
Update get/save EOS config tasks
