Guest User

Untitled

a guest
Nov 11th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. ---
  2. # Demo ACI Playbook
  3. - name: Configuring Example Tenant with VRF , BD , APP , EPG + Static Bindings with REST
  4. hosts: apic1
  5. connection: local
  6. gather_facts: no
  7.  
  8.  
  9. tasks:
  10. - name: Build a list of VLANs
  11. vars:
  12. count: '2230'
  13. set_fact:
  14. fact_count: '{{ fact_count|default([])|union([count]) }}'
  15. with_sequence: start={{vlan.start}} end={{vlan.end}} stride=1
  16.  
  17. - name: Create Tenant
  18. aci_tenant:
  19. hostname: "{{ apic_host }}"
  20. username: "{{ apic_username }}"
  21. password: "{{ apic_password }}"
  22. tenant: "{{ tenant }}"
  23. description: "Tenant configured by Abdul via Ansible"
  24. validate_certs: no
  25. state: present
  26.  
  27.  
  28. - name: Create VRF
  29. aci_vrf:
  30. hostname: "{{ apic_host }}"
  31. username: "{{ apic_username }}"
  32. password: "{{ apic_password }}"
  33. tenant: "{{ tenant }}"
  34. vrf: "{{ vrf }}"
  35. description: "VRF configured by Abdul via Ansible"
  36. validate_certs: no
  37. state: present
  38.  
  39.  
  40. - name: Create App Profile
  41. aci_ap:
  42. hostname: "{{ apic_host }}"
  43. username: "{{ apic_username }}"
  44. password: "{{ apic_password }}"
  45. tenant: "{{ tenant }}"
  46. ap: "{{ app_profile }}"
  47. description: "App Profile configured by Abdul via Ansible"
  48. validate_certs: no
  49. state: present
  50.  
  51.  
  52. - name: Create BD
  53. aci_bd:
  54. hostname: "{{ apic_host }}"
  55. username: "{{ apic_username }}"
  56. password: "{{ apic_password }}"
  57. tenant: "{{ tenant }}"
  58. vrf: "{{ vrf }}"
  59. bd: "bd-net{{item}}"
  60. description: "BD configured by Abdul via Ansible"
  61. enable_routing: yes
  62. arp_flooding: yes
  63. l2_unknown_unicast: flood
  64. validate_certs: no
  65. state: present
  66. with_sequence: start={{vlan.start}} end={{vlan.end}} stride=1
  67.  
  68. - name: Create BD Subnet
  69. aci_bd_subnet:
  70. hostname: "{{ apic_host }}"
  71. username: "{{ apic_username }}"
  72. password: "{{ apic_password }}"
  73. tenant: "{{ tenant }}"
  74. bd: "bd-net22{{item}}"
  75. gateway: "172.16.{{item}}.252"
  76. mask: "{{ bd.mask }}"
  77. scope: "private"
  78. description: "BD Subnet configured by Abdul via Ansible"
  79. validate_certs: no
  80. state: present
  81. with_sequence: start={{subnet.start}} end={{subnet.end}} stride=1
  82.  
  83. - name: Create EPG
  84. aci_epg:
  85. hostname: "{{ apic_host }}"
  86. username: "{{ apic_username }}"
  87. password: "{{ apic_password }}"
  88. tenant: "{{ tenant }}"
  89. ap: "{{ app_profile }}"
  90. epg: "epg-net{{item}}"
  91. bd: "bd-net{{item}}"
  92. description: "EPG configured by Abdul via Ansible"
  93. validate_certs: no
  94. state: present
  95. with_sequence: start={{vlan.start}} end={{vlan.end}} stride=1
  96.  
  97. - name: Bind Physical Domain to EPG
  98. aci_epg_to_domain:
  99. hostname: "{{ apic_host }}"
  100. username: "{{ apic_username }}"
  101. password: "{{ apic_password }}"
  102. tenant: "{{ tenant }}"
  103. ap: "{{ app_profile }}"
  104. epg: "epg-net{{item}}"
  105. domain: "{{ epg.domain }}"
  106. domain_type: phys
  107. validate_certs: no
  108. state: present
  109. with_sequence: start={{vlan.start}} end={{vlan.end}} stride=1
  110.  
  111. - name: Add Static Binding of port 1 to EPG using Rest Module
  112. aci_rest:
  113. hostname: "{{ apic_host }}"
  114. username: "{{ apic_username }}"
  115. password: "{{ apic_password }}"
  116. path: /api/node/mo/uni/tn-{{tenant}}/ap-{{app_profile}}/epg-epg-net{{item[0]}}.json
  117. method: post
  118. content:
  119. {
  120. "fvRsPathAtt": {
  121. "attributes": {
  122. "encap": "vlan-{{item[0]}}",
  123. "tDn": "{{ item[1] }}"
  124. }
  125. }
  126. }
  127. validate_certs: no
  128. with_nested:
  129. - "{{count}}"
  130. - "{{epg.ports}}"
Add Comment
Please, Sign In to add comment