init.sls 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. #
  2. # Bird routing daemon
  3. #
  4. {%- set roles = salt['pillar.get']('nodes:' ~ grains['id'] ~ ':roles', []) %}
  5. include:
  6. - network.interfaces
  7. bird-repo:
  8. file.absent:
  9. - name: /etc/apt/sources.list.d/bird.list
  10. bird-pkg:
  11. pkg.installed:
  12. - name: bird
  13. # Make sure both services are enabled
  14. bird:
  15. service.running:
  16. - enable: True
  17. - running: True
  18. bird6:
  19. service.running:
  20. - enable: True
  21. - running: True
  22. # Reload commands for bird{,6} to be tied to files which should trigger reconfiguration
  23. bird-configure:
  24. cmd.wait:
  25. - name: /usr/sbin/birdc configure
  26. - watch: []
  27. bird6-configure:
  28. cmd.wait:
  29. - name: /usr/sbin/birdc6 configure
  30. - watch: []
  31. /etc/bird:
  32. file.directory:
  33. - mode: 750
  34. - user: bird
  35. - group: bird
  36. - require:
  37. - pkg: bird
  38. /etc/bird/bird.d:
  39. file.directory:
  40. - makedirs: true
  41. - mode: 755
  42. - user: root
  43. - group: bird
  44. - require:
  45. - file: /etc/bird
  46. /etc/bird/bird.conf:
  47. file.managed:
  48. - source: salt://bird/bird.conf
  49. - template: jinja
  50. proto: v4
  51. - require:
  52. - file: /etc/bird/bird.d
  53. - require_in:
  54. - service: bird
  55. - watch_in:
  56. - cmd: bird-configure
  57. - mode: 644
  58. - user: root
  59. - group: bird
  60. /etc/bird/bird6.d:
  61. file.directory:
  62. - makedirs: true
  63. - mode: 755
  64. - user: root
  65. - group: bird
  66. - require:
  67. - file: /etc/bird
  68. /etc/bird/bird6.conf:
  69. file.managed:
  70. - source: salt://bird/bird.conf
  71. - template: jinja
  72. proto: v6
  73. - require:
  74. - file: /etc/bird/bird6.d
  75. - watch_in:
  76. - cmd: bird6-configure
  77. - mode: 644
  78. - user: root
  79. - group: bird
  80. - require_in:
  81. - service: bird6
  82. #
  83. # External VRF / Routing table?
  84. #
  85. /etc/bird/bird.d/VRF_external.conf:
  86. file.managed:
  87. - source: salt://bird/VRF_external.conf
  88. - template: jinja
  89. proto: v4
  90. - watch_in:
  91. - cmd: bird-configure
  92. - require:
  93. - file: /etc/bird/bird.d
  94. - require_in:
  95. - service: bird
  96. /etc/bird/bird6.d/VRF_external.conf:
  97. file.managed:
  98. - source: salt://bird/VRF_external.conf
  99. - template: jinja
  100. proto: v6
  101. - watch_in:
  102. - cmd: bird6-configure
  103. - require:
  104. - file: /etc/bird/bird6.d
  105. - require_in:
  106. - service: bird6
  107. /etc/bird/bird.d/external.conf:
  108. file.absent
  109. /etc/bird/bird6.d/external.conf:
  110. file.absent
  111. #
  112. # IGP / OSPF
  113. #
  114. /etc/bird/bird.d/IGP.conf:
  115. file.managed:
  116. - source: salt://bird/IGP.conf
  117. - template: jinja
  118. proto: v4
  119. - watch_in:
  120. - cmd: bird-configure
  121. - require:
  122. - file: /etc/bird/bird.d
  123. - require_in:
  124. - service: bird
  125. /etc/bird/bird6.d/IGP.conf:
  126. file.managed:
  127. - source: salt://bird/IGP.conf
  128. - template: jinja
  129. proto: v6
  130. - watch_in:
  131. - cmd: bird6-configure
  132. - require:
  133. - file: /etc/bird/bird6.d
  134. - require_in:
  135. - service: bird6
  136. # Compatibility glue
  137. /etc/bird/bird6.d/IGP6.conf:
  138. file.absent:
  139. - watch_in:
  140. - cmd: bird-configure
  141. #
  142. # iBGP
  143. #
  144. /etc/bird/ff-policy.conf:
  145. file.managed:
  146. - source: salt://bird/ff-policy.conf
  147. - template: jinja
  148. proto: v4
  149. - watch_in:
  150. - cmd: bird-configure
  151. - require:
  152. - file: /etc/bird/bird.d
  153. - require_in:
  154. - service: bird
  155. /etc/bird/ff-policy6.conf:
  156. file.managed:
  157. - source: salt://bird/ff-policy.conf
  158. - template: jinja
  159. proto: v6
  160. - watch_in:
  161. - cmd: bird6-configure
  162. - require:
  163. - file: /etc/bird/bird6.d
  164. - require_in:
  165. - service: bird6
  166. /etc/bird/bird.d/ibgp.conf:
  167. file.managed:
  168. - source: salt://bird/ibgp.conf
  169. - template: jinja
  170. proto: v4
  171. - watch_in:
  172. - cmd: bird-configure
  173. - require:
  174. - file: /etc/bird/bird.d
  175. - require_in:
  176. - service: bird
  177. /etc/bird/bird6.d/ibgp.conf:
  178. file.managed:
  179. - source: salt://bird/ibgp.conf
  180. - template: jinja
  181. proto: v6
  182. - watch_in:
  183. - cmd: bird6-configure
  184. - require:
  185. - file: /etc/bird/bird6.d
  186. - require_in:
  187. - service: bird6
  188. #
  189. # FFRL-exit
  190. #
  191. {% if 'ffrl-exit' in roles %}
  192. /etc/bird/bird.d/ffrl.conf:
  193. file.managed:
  194. - source: salt://bird/ffrl.conf
  195. - template: jinja
  196. proto: v4
  197. - watch_in:
  198. - cmd: bird-configure
  199. - require:
  200. - file: /etc/bird/bird.d
  201. - require_in:
  202. - service: bird
  203. /etc/bird/bird6.d/ffrl.conf:
  204. file.managed:
  205. - source: salt://bird/ffrl.conf
  206. - template: jinja
  207. proto: v6
  208. - watch_in:
  209. - cmd: bird6-configure
  210. - require:
  211. - file: /etc/bird/bird6.d
  212. - require_in:
  213. - service: bird6
  214. /etc/bird/bird.d/bogon_unreach.conf:
  215. file.managed:
  216. - source: salt://bird/bogon_unreach.conf
  217. - template: jinja
  218. proto: v4
  219. - watch_in:
  220. - cmd: bird-configure
  221. - require:
  222. - file: /etc/bird/bird.d
  223. - require_in:
  224. - service: bird
  225. /etc/bird/bird6.d/bogon_unreach.conf:
  226. file.managed:
  227. - source: salt://bird/bogon_unreach.conf
  228. - template: jinja
  229. proto: v6
  230. - watch_in:
  231. - cmd: bird6-configure
  232. - require:
  233. - file: /etc/bird/bird6.d
  234. - require_in:
  235. - service: bird6
  236. {% else %}
  237. /etc/bird/bird.d/ffrl.conf:
  238. file.absent
  239. /etc/bird/bird6.d/ffrl.conf:
  240. file.absent
  241. /etc/bird/bird.d/bogon_unreach.conf:
  242. file.absent
  243. /etc/bird/bird6.d/bogon_unreach.conf:
  244. file.absent
  245. {% endif %}
  246. #
  247. # B.A.T.M.A.N. Gateway
  248. #
  249. {% if 'batman_gw' in roles %}
  250. /etc/bird/bird.d/mesh_routes.conf:
  251. file.managed:
  252. - source: salt://bird/mesh_routes.conf
  253. - template: jinja
  254. - watch_in:
  255. - cmd: bird-configure
  256. - require:
  257. - file: /etc/bird/bird.d
  258. - require_in:
  259. - service: bird
  260. /etc/bird/bird6.d/mesh_routes.conf:
  261. file.managed:
  262. - source: salt://bird/mesh_routes.conf
  263. - template: jinja
  264. - watch_in:
  265. - cmd: bird6-configure
  266. - require:
  267. - file: /etc/bird/bird6.d
  268. - require_in:
  269. - service: bird6
  270. {% else %}
  271. /etc/bird/bird.d/mesh_routes.conf:
  272. file.absent
  273. /etc/bird/bird6.d/mesh_routes.conf:
  274. file.absent
  275. {% endif %}
  276. #
  277. # L3 Access
  278. #
  279. {% if 'l3-access' in roles %}
  280. /etc/bird/bird.d/l3-access.conf:
  281. file.managed:
  282. - source: salt://bird/l3-access.conf
  283. - template: jinja
  284. - watch_in:
  285. - cmd: bird-configure
  286. - require:
  287. - file: /etc/bird/bird.d
  288. - require_in:
  289. - service: bird
  290. /etc/bird/bird6.d/l3-access.conf:
  291. file.managed:
  292. - source: salt://bird/l3-access.conf
  293. - template: jinja
  294. - watch_in:
  295. - cmd: bird6-configure
  296. - require:
  297. - file: /etc/bird/bird6.d
  298. - require_in:
  299. - service: bird6
  300. {% else %}
  301. /etc/bird/bird.d/l3-access.conf:
  302. file.absent
  303. /etc/bird/bird6.d/l3-access.conf:
  304. file.absent
  305. {% endif %}
  306. #
  307. # RAdvd (for B.A.T.M.A.N. Gateways / L3-Access)
  308. #
  309. {% if 'radv' in roles or 'l3-access' in roles or ('batman_gw' in roles and grains.id.startswith('gw')) %}
  310. /etc/bird/bird6.d/radv.conf:
  311. file.managed:
  312. - source: salt://bird/radv.conf
  313. - template: jinja
  314. - watch_in:
  315. - cmd: bird6-configure
  316. - require:
  317. - file: /etc/bird/bird6.d
  318. - require_in:
  319. - service: bird6
  320. {% else %}
  321. /etc/bird/bird6.d/radv.conf:
  322. file.absent:
  323. - watch_in:
  324. - cmd: bird6-configure
  325. {% endif %}