|
199 | 199 | config: "{{ vlan_interfaces | from_yaml }}" |
200 | 200 | state: replaced |
201 | 201 |
|
| 202 | + - name: Configure DCB settings |
| 203 | + when: "'dcb_configuration' in switch_vars" |
| 204 | + block: |
| 205 | + |
| 206 | + - name: Configure forwarding classes and classifiers |
| 207 | + when: "'classifiers' in switch_vars['dcb_configuration']" |
| 208 | + block: |
| 209 | + - name: Configure forwarding classes |
| 210 | + vars: |
| 211 | + forwarding_class_config: | |
| 212 | + {% for classifier in switch_vars['dcb_configuration'][ |
| 213 | + 'classifiers'] %} |
| 214 | + {% for fc in classifier['forwarding_classes'] %} |
| 215 | + - set class-of-service forwarding-classes class |
| 216 | + {{ fc.class_name }} queue-num {{ fc.queue_num }} |
| 217 | + {% endfor %} |
| 218 | + {% endfor %} |
| 219 | + junipernetworks.junos.junos_config: |
| 220 | + lines: "{{ forwarding_class_config | from_yaml }}" |
| 221 | + |
| 222 | + - name: Configure classifiers |
| 223 | + vars: |
| 224 | + classifier_config: | |
| 225 | + {% for classifier in switch_vars['dcb_configuration'][ |
| 226 | + 'classifiers'] %} |
| 227 | + {% for fc in classifier['forwarding_classes'] %} |
| 228 | + - set class-of-service classifiers {{ classifier.type }} |
| 229 | + {{ classifier.name }} forwarding-class |
| 230 | + {{ fc.class_name }} loss-priority |
| 231 | + {{ fc.loss_priority }} code-points {{ fc.code_points }} |
| 232 | + {% endfor %} |
| 233 | + {% endfor %} |
| 234 | + junipernetworks.junos.junos_config: |
| 235 | + lines: "{{ classifier_config | from_yaml }}" |
| 236 | + |
| 237 | + - name: Configure forwarding class sets |
| 238 | + vars: |
| 239 | + forwarding_class_set_config: | |
| 240 | + {% for fc_set in switch_vars['dcb_configuration'][ |
| 241 | + 'forwarding_class_sets'] | default([]) %} |
| 242 | + {% for class in fc_set.classes %} |
| 243 | + - > |
| 244 | + set class-of-service forwarding-class-sets |
| 245 | + {{ fc_set.set_name }} class {{ class.class_name }} |
| 246 | + {% endfor %} |
| 247 | + {% endfor %} |
| 248 | + junipernetworks.junos.junos_config: |
| 249 | + lines: "{{ forwarding_class_set_config | from_yaml }}" |
| 250 | + |
| 251 | + - name: Configure schedulers |
| 252 | + vars: |
| 253 | + scheduler_config: | |
| 254 | + {% for scheduler in switch_vars['dcb_configuration'][ |
| 255 | + 'schedulers'] | default([]) %} |
| 256 | + - > |
| 257 | + set class-of-service schedulers {{ scheduler.name }} |
| 258 | + priority {{ scheduler.priority }} |
| 259 | + transmit-rate {{ scheduler.transmit_rate }} |
| 260 | + - > |
| 261 | + set class-of-service schedulers {{ scheduler.name }} |
| 262 | + shaping-rate percent {{ scheduler.shaping_rate_percent }} |
| 263 | + {% endfor %} |
| 264 | + junipernetworks.junos.junos_config: |
| 265 | + lines: "{{ scheduler_config | from_yaml }}" |
| 266 | + |
| 267 | + - name: Configure scheduler maps |
| 268 | + vars: |
| 269 | + scheduler_map_config: | |
| 270 | + {% for map in switch_vars['dcb_configuration'][ |
| 271 | + 'scheduler_maps'] | default([]) %} |
| 272 | + {% for fc in map.forwarding_classes %} |
| 273 | + - > |
| 274 | + set class-of-service scheduler-maps {{ map.name }} |
| 275 | + forwarding-class {{ fc }} |
| 276 | + scheduler {{ map.scheduler }} |
| 277 | + {% endfor %} |
| 278 | + {% endfor %} |
| 279 | + junipernetworks.junos.junos_config: |
| 280 | + lines: "{{ scheduler_map_config | from_yaml }}" |
| 281 | + |
| 282 | + - name: Configure traffic control profiles |
| 283 | + vars: |
| 284 | + traffic_control_profile_config: | |
| 285 | + {% for profile in switch_vars['dcb_configuration'][ |
| 286 | + 'traffic_control_profiles'] | default([]) %} |
| 287 | + - set class-of-service traffic-control-profiles |
| 288 | + {{ profile.profile_name }} |
| 289 | + scheduler-map {{ profile.scheduler_map }} |
| 290 | + guaranteed-rate {{ profile.guaranteed_rate }} |
| 291 | + {% if profile.shaping_rate_percent is defined %} |
| 292 | + - set class-of-service traffic-control-profiles |
| 293 | + {{ profile.profile_name }} |
| 294 | + shaping-rate percent {{ profile.shaping_rate_percent }} |
| 295 | + {% endif %} |
| 296 | + {% endfor %} |
| 297 | + junipernetworks.junos.junos_config: |
| 298 | + lines: "{{ traffic_control_profile_config | from_yaml }}" |
| 299 | + |
| 300 | + - name: Configure DCB settings for interfaces |
| 301 | + when: "'interfaces' in switch_vars['dcb_configuration']" |
| 302 | + block: |
| 303 | + |
| 304 | + - name: Apply DCBX configuration to interfaces |
| 305 | + junipernetworks.junos.junos_config: |
| 306 | + lines: |
| 307 | + - "set protocols dcbx interface {{ item.interface }}" |
| 308 | + loop: "{{ switch_vars['dcb_configuration']['interfaces'] }}" |
| 309 | + when: item.interface is defined |
| 310 | + |
| 311 | + - name: Apply classifier to interfaces |
| 312 | + vars: |
| 313 | + classifier_name: "{{ switch_vars['dcb_configuration'][ |
| 314 | + 'classifiers'][0]['name'] }}" |
| 315 | + junipernetworks.junos.junos_config: |
| 316 | + lines: |
| 317 | + - "set class-of-service interfaces {{ item.interface }} |
| 318 | + unit 0 classifiers ieee-802.1 {{ classifier_name }}" |
| 319 | + loop: "{{ switch_vars['dcb_configuration']['interfaces'] }}" |
| 320 | + when: item.interface is defined and |
| 321 | + classifier_name is defined |
| 322 | + |
| 323 | + - name: Apply fcs and tcp to interfaces |
| 324 | + vars: |
| 325 | + interface_config_lines: | |
| 326 | + {% for profile in switch_vars['dcb_configuration'][ |
| 327 | + 'traffic_control_profiles'] %} |
| 328 | + - set class-of-service interfaces {{ item.interface }} |
| 329 | + forwarding-class-set {{ profile.forwarding_class_set }} |
| 330 | + output-traffic-control-profile |
| 331 | + {{ profile.profile_name }} |
| 332 | + {% endfor %} |
| 333 | + junipernetworks.junos.junos_config: |
| 334 | + lines: "{{ interface_config_lines | from_yaml }}" |
| 335 | + loop: "{{ switch_vars['dcb_configuration']['interfaces'] }}" |
| 336 | + when: item.interface is defined |
| 337 | + |
202 | 338 | - name: Save configuration |
203 | 339 | junipernetworks.junos.junos_config: |
204 | 340 | confirm_commit: true |
|
0 commit comments