Merge "[opendaylight] Support built-in DHCP service"
[fuel.git] / mcp / salt-formulas / salt-formula-opendaylight / opendaylight / server.sls
1 ##############################################################################
2 # Copyright (c) 2017 Mirantis Inc. and others.
3 # All rights reserved. This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
6 # http://www.apache.org/licenses/LICENSE-2.0
7 ##############################################################################
8 {% from "opendaylight/map.jinja" import server with context %}
9 {% from "linux/map.jinja" import system with context %}
10
11 {%- if server.enabled %}
12
13 opendaylight_repo_key:
14   cmd.run:
15     - name: "apt-key adv --keyserver keyserver.ubuntu.com --recv 44C05248"
16 {%- if system.proxy is defined and system.proxy.pkg is defined %}
17     - env:
18 {%- if system.proxy.pkg.http is defined %}
19       - http_proxy: {{ system.proxy.pkg.http }}
20 {%- endif %}
21 {%- if system.proxy.pkg.https is defined %}
22       - https_proxy: {{ system.proxy.pkg.https }}
23 {%- endif %}
24 {%- endif %}
25
26 opendaylight_repo:
27   pkgrepo.managed:
28   # NOTE(armband): PPA handling behind proxy broken, define it explicitly
29   # https://github.com/saltstack/salt/pull/45224
30   # - ppa: {{ server.repo }}
31   - human_name: opendaylight-ppa
32   - name: deb http://ppa.launchpad.net/odl-team/{{ server.version }}/ubuntu xenial main
33   - file: /etc/apt/sources.list.d/odl-team-ubuntu-{{ server.version }}-xenial.list
34
35 {%- if grains['saltversioninfo'] < [2017, 7] %}
36 service.mask:
37   module.run:
38   - m_name: opendaylight
39 {%- else %}
40 opendaylight_service_mask:
41   service.masked:
42   - name: opendaylight
43 {%- endif %}
44
45 opendaylight:
46   pkg.installed:
47   - require:
48     - pkgrepo: opendaylight_repo
49   service.running:
50   - enable: true
51 {%- if grains['saltversioninfo'] >= [2017, 7] %}
52   - unmask: true
53 {%- endif %}
54   - watch:
55     - file: /opt/opendaylight/etc/jetty.xml
56     - file: /opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-dhcpservice-config.xml
57     - file: /opt/opendaylight/bin/setenv
58     - ini: /opt/opendaylight/etc/org.apache.karaf.features.cfg
59     - ini: /opt/opendaylight/etc/org.ops4j.pax.web.cfg
60
61 /opt/opendaylight/etc/jetty.xml:
62   file.managed:
63   - source: salt://opendaylight/files/jetty.xml
64   - template: jinja
65   - user: odl
66   - group: odl
67
68 /opt/opendaylight/bin/setenv:
69   file.managed:
70   - source: salt://opendaylight/files/setenv.shell
71   - mode: 0755
72   - use:
73     - file: /opt/opendaylight/etc/jetty.xml
74
75 {% set features %}
76 {%- for f in server.karaf_features.itervalues() -%}
77 {{ f | join(',') }}{%- if not loop.last %},{%- endif %}
78 {%- endfor %}
79 {% endset %}
80
81 /opt/opendaylight/etc/org.apache.karaf.features.cfg:
82   ini.options_present:
83     - sections:
84         featuresBoot: {{ features }}
85
86 /opt/opendaylight/etc/org.ops4j.pax.web.cfg:
87   ini.options_present:
88     - sections:
89         org.ops4j.pax.web.listening.addresses: {{ server.odl_bind_ip }}
90         org.osgi.service.http.port: {{ server.odl_rest_port }}
91
92 {%- if server.get('router_enabled', false) %}
93 /opt/opendaylight/etc/custom.properties:
94   ini.options_present:
95     - sections:
96         ovsdb.l3.fwd.enabled: 'yes'
97         ovsdb.of.version: 1.3
98     - require:
99       - pkg: opendaylight
100     - watch_in:
101       - service: opendaylight
102 {%- endif %}
103
104 /opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-dhcpservice-config.xml:
105   file.managed:
106   - source: salt://opendaylight/files/netvirt-dhcpservice-config.xml
107   - use:
108     - file: /opt/opendaylight/etc/jetty.xml
109
110 {%- if grains['cpuarch'] == 'aarch64' %}
111 opendaylight-leveldbjni:
112   pkg.installed
113 {%- endif %}
114
115 {%- endif %}