All,
I am trying to refactor my playbook to run an ios command across a group of 
hosts... My challenge is that the command is specific to individual hosts 
in the group. As it stands, my playbook initial task is ran against all 
hosts in my group and looping over every item in my list. My intent is to 
run the ios command that pertains to the host and not have to have several 
plays or tasks in 1 playbook. Is that possible? Below is my inventory list 
and playbook. Feedback would be greatly appreciated!

[ios]
Til_INET_EDC-2-WDC_7kb_Core.xxx.org
Til-Site-RTR-1
Til-Site-RTR-2
Til-Site-RTR-3
Til-Site-SW1
Til-Site-SW2
Til-Stratix-5700
Til-Stratix-8000
Til-Stratix-8300
NIS-Til-4506
Til-WDC-Core
Til_INET_WDC-2-WDC_7ka_Core.xxx.org

--------------------------------------------------------------------------------
---
- name: Restore ios base configs on Til Devices
  hosts: ios
  gather_facts: no
  vars_files:
    - vault/variables.yml

  tasks:
    - name: Restore base configs
      ios_command:
        commands:
          - command: 'configure replace {{ item }}'
            prompt: '[no]'
            answer: y
      with_items:
        - nvram:Til-EDC-INET_base
        - nvram:Til-Site-RTR-1_base
        - nvram:Til-Site-RTR-2_base
        - nvram:Til-Site-RTR-3_base
        - nvram:Til-Site-SW1_base
        - nvram:Til-Site-SW2_base
        - nvram:Til-Stratix-5700_base
        - nvram:Til-Stratix-8000_base
        - nvram:Til-Stratix-8300_base
        - nvram:NIS-TIL-4506_base
        - nvram:Til-WDC-Core_base
        - nvram:WDC-TIL-INET_base
      register: result
      tags: ios

    - name: Copy running-config to startup-config
      ios_config:
        save_when: always

    - name: Print output
      debug:
        var: result

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ca7c5105-d99f-4aa7-a7a2-6badc786dd84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to