init.sls 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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. - watch_in:
  240. - cmd: bird-configure
  241. /etc/bird/bird6.d/ffrl.conf:
  242. file.absent:
  243. - watch_in:
  244. - cmd: bird6-configure
  245. /etc/bird/bird.d/bogon_unreach.conf:
  246. file.absent:
  247. - watch_in:
  248. - cmd: bird-configure
  249. /etc/bird/bird6.d/bogon_unreach.conf:
  250. file.absent:
  251. - watch_in:
  252. - cmd: bird6-configure
  253. {% endif %}
  254. #
  255. # B.A.T.M.A.N. Gateway
  256. #
  257. {% if 'batman_gw' in roles %}
  258. /etc/bird/bird.d/mesh_routes.conf:
  259. file.managed:
  260. - source: salt://bird/mesh_routes.conf
  261. - template: jinja
  262. - watch_in:
  263. - cmd: bird-configure
  264. - require:
  265. - file: /etc/bird/bird.d
  266. - require_in:
  267. - service: bird
  268. /etc/bird/bird6.d/mesh_routes.conf:
  269. file.managed:
  270. - source: salt://bird/mesh_routes.conf
  271. - template: jinja
  272. - watch_in:
  273. - cmd: bird6-configure
  274. - require:
  275. - file: /etc/bird/bird6.d
  276. - require_in:
  277. - service: bird6
  278. {% else %}
  279. /etc/bird/bird.d/mesh_routes.conf:
  280. file.absent:
  281. - watch_in:
  282. - cmd: bird-configure
  283. /etc/bird/bird6.d/mesh_routes.conf:
  284. file.absent:
  285. - watch_in:
  286. - cmd: bird6-configure
  287. {% endif %}
  288. #
  289. # L3 Access
  290. #
  291. {% if 'l3-access' in roles %}
  292. /etc/bird/bird.d/l3-access.conf:
  293. file.managed:
  294. - source: salt://bird/l3-access.conf
  295. - template: jinja
  296. - watch_in:
  297. - cmd: bird-configure
  298. - require:
  299. - file: /etc/bird/bird.d
  300. - require_in:
  301. - service: bird
  302. /etc/bird/bird6.d/l3-access.conf:
  303. file.managed:
  304. - source: salt://bird/l3-access.conf
  305. - template: jinja
  306. - watch_in:
  307. - cmd: bird6-configure
  308. - require:
  309. - file: /etc/bird/bird6.d
  310. - require_in:
  311. - service: bird6
  312. {% else %}
  313. /etc/bird/bird.d/l3-access.conf:
  314. file.absent:
  315. - watch_in:
  316. - cmd: bird-configure
  317. /etc/bird/bird6.d/l3-access.conf:
  318. file.absent:
  319. - watch_in:
  320. - cmd: bird6-configure
  321. {% endif %}
  322. #
  323. # RAdvd (for B.A.T.M.A.N. Gateways / L3-Access)
  324. #
  325. {% if 'radv' in roles or 'l3-access' in roles or ('batman_gw' in roles and grains.id.startswith('gw')) %}
  326. /etc/bird/bird6.d/radv.conf:
  327. file.managed:
  328. - source: salt://bird/radv.conf
  329. - template: jinja
  330. - watch_in:
  331. - cmd: bird6-configure
  332. - require:
  333. - file: /etc/bird/bird6.d
  334. - require_in:
  335. - service: bird6
  336. {% else %}
  337. /etc/bird/bird6.d/radv.conf:
  338. file.absent:
  339. - watch_in:
  340. - cmd: bird6-configure
  341. {% endif %}