init.sls 7.9 KB

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