init.sls 7.1 KB

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