Sometimes it is necessary to reboot the accesspoints and if you don`t want to do it by hand let Ansible work for you :-)
The playbook collects ansible_facts and loop over the interfaces to find ports with the platform description “AIR-” in the CDP neighbors and execute the command “power inline never” afterwards it loops again over the interfaces and makes an “no power inline never”.
You can also use it for other devices like Cisco phones etc.
!! DO NOT STOP THE SCRIPT, IF YOU DO THAT YOU MUST ENABLE THE POWER OF THE INTERFACES MANUALLY
---
- hosts: devices
connection: network_cli
gather_facts: True
tasks:
- name: Disable power of AP interface
ios_config:
lines:
- power inline never
parents: interface {{ item.key }}
with_dict: "{{ ansible_facts.net_neighbors }}"
when: '"AIR-" in item.value[0].platform'
- name: Enable power of AP interface
ios_config:
lines:
- no power inline never
parents: interface {{ item.key }}
with_dict: "{{ ansible_facts.net_neighbors }}"
when: '"AIR-" in item.value[0].platform'
```