summaryrefslogtreecommitdiffstats
path: root/roles/contiv/tasks/netmaster.yml
blob: cc52d3a43e323fd1adccab411cfbf792566797ad (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
---
- include: netmaster_firewalld.yml
  when: has_firewalld

- include: netmaster_iptables.yml
  when: not has_firewalld and has_iptables

- name: Netmaster | Check is /etc/hosts file exists
  stat:
    path: /etc/hosts
  register: hosts

- name: Netmaster | Create hosts file if it is not present
  file:
    path: /etc/hosts
    state: touch
  when: not hosts.stat.exists

- name: Netmaster | Build hosts file
  lineinfile:
    dest: /etc/hosts
    regexp: .*netmaster$
    line: "{{ hostvars[item]['ansible_' + netmaster_interface].ipv4.address }} netmaster"
    state: present
  when: hostvars[item]['ansible_' + netmaster_interface].ipv4.address is defined
  with_items: "{{ groups['masters'] }}"

- name: Netmaster | Create netmaster symlinks
  file:
    src: "{{ contiv_current_release_directory }}/{{ item }}"
    dest: "{{ bin_dir }}/{{ item }}"
    state: link
  with_items:
    - netmaster
    - netctl

- name: Netmaster | Copy environment file for netmaster
  template:
    src: netmaster.env.j2
    dest: /etc/default/netmaster
    mode: 0644
  notify: restart netmaster

- name: Netmaster | Ensure contiv_config_dir exists
  file:
    path: "{{ contiv_config_dir }}"
    recurse: yes
    state: directory

- name: Netmaster | Setup contiv.json config for the cni plugin
  template:
    src: contiv.cfg.master.j2
    dest: "{{ contiv_config_dir }}/contiv.json"
  notify: restart netmaster

- name: Netmaster | Copy systemd units for netmaster
  template:
    src: netmaster.service
    dest: /etc/systemd/system/netmaster.service
  notify: reload systemd

- name: Netmaster | Enable Netmaster
  service:
    name: netmaster
    enabled: yes

- name: Netmaster | Start Netmaster
  service:
    name: netmaster
    state: started
  register: netmaster_started

- include: aci.yml
  when: contiv_fabric_mode == "aci"

- include: default_network.yml
  when: contiv_default_network == true