--- - hosts: localhost connection: local tasks: # Store Global variables. These are also used by other plays in this playbook - name: Store Global variables in localhost block: - set_fact: site_data: "{{ hostvars[groups[site][0]] }}" - set_fact: sw_group_name: "{{ site_data.sw_group_name }}" # Group for the Switches # This block will execute a set of different configurations via tasks - hosts: "{{ hostvars.localhost.sw_group_name }}" connection: local gather_facts: no tasks: - name: Configure Switch block: # Login to ArubaOS switches - name: Login include: aruba_task_lists/aos_switch/login_switch.yml # Configure ArubaOS switches using anycli rest option - name: anycli configure include: aruba_task_lists/aos_switch/anycli.yml command="{{item}}" with_items: - "configure terminal" - "vlan 233" # Variable uri_result contains the response from anycli task - name: Use AnyCli - show vlans include: aruba_task_lists/aos_switch/anycli.yml command="show vlans" # Decode output from anycli task - set_fact: rest_cli_output: "{{uri_result.json.result_base64_encoded| b64decode}}" # Check if newly created vlan 233 is in cli_output - debug: msg: "Vlan 233 was created" when: rest_cli_output.find("233") always: # Logout from ArubaOS Switch - name: Logout include: aruba_task_lists/aos_switch/logout_switch.yml