- So to get handlers to work properly you must put the handlers in a different "host" definition.
- hosts: all
roles:
- requires_switchd_restart
- hosts: all
roles:
- system_basics
- l2_tasks
- l3_tasks
## this works. switchd is started before interfaces are configured. ansible runs handlers | |
## if tasks are under a different "host" definition | |
--- | |
- hosts: all | |
tasks: | |
- name: get facts | |
cumulus_facts: | |
- name: create groups based on platform-detect str. Can use groups_vars/productname for variables | |
group_by: key={{ productname }} | |
- name: debug speed_40g value for the platform | |
debug: msg="{{ cumulus_ports.speed_40g|default([]) }}" | |
- name: debug speed 4x10g value for the platform | |
debug: msg="{{ cumulus_ports.speed_4_by_10g|default([]) }}" | |
- name: > | |
actual cl_ports call that will be in playbook. | |
Notice it covers all 4 port types and puts defaults where needed | |
if variable is blank module will use speed setting defined in existing ports.conf | |
it covers switches that don't have ports.conf too as well. it will do nothing. | |
cl_ports: | |
speed_40g: "{{ cumulus_ports.speed_40g|default([]) }}" | |
speed_10g: "{{ cumulus_ports.speed_10g|default([]) }}" | |
speed_4_by_10g: "{{ cumulus_ports.speed_4_by_10g|default([]) }}" | |
speed_40g_div_4: "{{ cumulus_ports.speed_40g_div_4|default([]) }}" | |
notify: restart switchd | |
- name: install license | |
cl_license: src='http://192.168.0.1/{{ansible_hostname}}.lic' | |
notify: restart switchd | |
handlers: | |
- name: restart switchd | |
service: name=switchd state=restarted | |
# ansible says that handlers apply on a certain block of commands | |
# you can see it works fine in a [host] block | |
# does it also work in role setting? | |
- hosts: all | |
tasks: | |
- name: config an interface | |
cl_interface: name=br0 bridgeports='swp1-2' applyconfig=yes |