summaryrefslogtreecommitdiff
path: root/roles/uvok_bird/tasks/main.yml
blob: 4c9390d8d47a456e2b127dde6e5e4b2be006c5b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
# tasks file for uvok_bird
- name: Ensure route/table definitions exists
  ansible.builtin.file:
    path: '{{ uvok_bird_route_file }}'
    state: touch
    mode: '0750'
    owner: 'root'
    group: 'root'
    modification_time: preserve
    access_time: preserve
- name: Add route/table definitions
  lineinfile:
    path: '{{ uvok_bird_route_file }}'
    state: present
    search_string: "150"
    line: "150\tas{{ uvok_bird_opts.clear_as }}"
- name: Add route/table definitions
  lineinfile:
    path: '{{ uvok_bird_route_file }}'
    state: present
    search_string: "100"
    line: "100\tas{{ uvok_bird_opts.clear_as }}_out"
- name: Install routing software
  package:
    name:
      - bird2
    state: present
- name: Ensure bird config directory exists
  ansible.builtin.file:
    path: '{{ uvok_bird_opts.config_dir }}'
    state: directory
    mode: '0750'
    owner: 'bird'
    group: 'bird'
- name: Ensure bird log directory exists
  ansible.builtin.file:
    path: '/var/log/bird/'
    state: directory
    mode: '0750'
    owner: 'bird'
    group: 'bird'
- name: Install common templates
  template:
    src: '{{ item.src }}'
    dest: '{{ item.dest }}'
    mode: '0640'
    owner: 'bird'
    group: 'bird'
  loop:
    - { src: 'bird.conf.j2', dest: '{{ uvok_bird_opts.config_dir }}/bird.conf' }
    - { src: 'defines.conf.j2', dest: '{{ uvok_bird_opts.config_dir }}/defines.conf' }
  notify: configure bird
- name: Copy remaining common files
  copy:
    src: files/{{ item }}
    dest: '{{ uvok_bird_opts.config_dir }}/{{ item }}'
    mode: '0640'
    owner: 'bird'
    group: 'bird'
  loop:
    - "common.conf"
    - "logging.conf"
  notify: configure bird
- name: Install clearnet templates
  template:
    src: '{{ item.src }}'
    dest: '{{ item.dest }}'
    mode: '0640'
    owner: 'bird'
    group: 'bird'
  when:
    - uvok_bird_opts.clearnet
  loop:
    - { src: 'clearnet.conf.j2', dest: '{{ uvok_bird_opts.config_dir }}/clearnet.conf' }
    - { src: 'clear_defines.conf.j2', dest: '{{ uvok_bird_opts.config_dir }}/clear_defines.conf' }
    - { src: 'clear_rpki.conf.j2', dest: '{{ uvok_bird_opts.config_dir }}/clear_rpki.conf' }
  notify: configure bird
- name: Copy remaining clearnet files
  ansible.posix.synchronize:
    src: 'files/'
    dest: '{{ uvok_bird_opts.config_dir }}'
    recursive: true
    archive: false
    compress: false
    checksum: true
    rsync_opts:
      - '--chown=bird:bird'
      - '--chmod=0640'
      - '--include=*/'
      - '--include=clear*.conf'
      - '--exclude=*'
  when:
    - uvok_bird_opts.clearnet
  notify: configure bird
- name: Ensure bird peer directory exists
  ansible.builtin.file:
    path: '{{ uvok_bird_opts.config_dir }}/clear_peers/'
    state: directory
    mode: '0750'
    owner: 'bird'
    group: 'bird'
  when:
    - uvok_bird_opts.clearnet
- name: Remove clearnet config files
  ansible.builtin.file:
    path: '{{ item }}'
    state: absent
  loop:
    - '{{ uvok_bird_opts.config_dir }}/clearnet.conf'
    - '{{ uvok_bird_opts.config_dir }}/clear_defines.conf'
    - '{{ uvok_bird_opts.config_dir }}/clear_functions.conf'
  when:
    - not uvok_bird_opts.clearnet