Merge "Bring in Tacker salt formula"
[fuel.git] / mcp / salt-formulas / 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.keyserver is defined %}
17     - env:
18 {%- if system.proxy.keyserver.http is defined and grains['dns']['nameservers'][0] in system.proxy.keyserver.http %}
19       - http_proxy: {{ system.proxy.keyserver.http }}
20 {%- endif %}
21 {%- if system.proxy.keyserver.https is defined and grains['dns']['nameservers'][0] in system.proxy.keyserver.https %}
22       - https_proxy: {{ system.proxy.keyserver.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 opendaylight_service_mask:
36   service.masked:
37   - name: opendaylight
38
39 opendaylight:
40   pkg.installed:
41   - require:
42     - pkgrepo: opendaylight_repo
43   - require_in:
44     - file: /opt/opendaylight/etc/jetty.xml
45     - file: /opt/opendaylight/bin/setenv
46     - ini: /opt/opendaylight/etc/org.apache.karaf.features.cfg
47     - ini: /opt/opendaylight/etc/org.ops4j.pax.web.cfg
48   service.running:
49   - enable: true
50   - unmask: true
51   - watch:
52     - file: /opt/opendaylight/etc/jetty.xml
53     - file: /opt/opendaylight/bin/setenv
54     - ini: /opt/opendaylight/etc/org.apache.karaf.features.cfg
55     - ini: /opt/opendaylight/etc/org.ops4j.pax.web.cfg
56
57 /opt/opendaylight/etc/jetty.xml:
58   file.managed:
59   - source: salt://opendaylight/files/jetty.xml
60   - template: jinja
61   - user: odl
62   - group: odl
63
64 /opt/opendaylight/bin/setenv:
65   file.managed:
66   - source: salt://opendaylight/files/setenv.shell
67   - mode: 0755
68   - use:
69     - file: /opt/opendaylight/etc/jetty.xml
70
71 {% set features %}
72 {%- for f in server.karaf_features.itervalues() -%}
73 {{ f | join(',') }}{%- if not loop.last %},{%- endif %}
74 {%- endfor %}
75 {% endset %}
76
77 /opt/opendaylight/etc/org.apache.karaf.features.cfg:
78   ini.options_present:
79     - sections:
80         featuresBoot: {{ features }}
81
82 /opt/opendaylight/etc/org.ops4j.pax.web.cfg:
83   ini.options_present:
84     - sections:
85         org.ops4j.pax.web.listening.addresses: {{ server.odl_bind_ip }}
86         org.osgi.service.http.port: {{ server.odl_rest_port }}
87
88 {%- if server.get('router_enabled', false) %}
89 /opt/opendaylight/etc/custom.properties:
90   ini.options_present:
91     - sections:
92         ovsdb.l3.fwd.enabled: 'yes'
93         ovsdb.of.version: 1.3
94     - require:
95       - pkg: opendaylight
96     - watch_in:
97       - service: opendaylight
98 {%- endif %}
99
100 {%- if grains['cpuarch'] == 'aarch64' %}
101 opendaylight-leveldbjni:
102   pkg.installed
103 {%- endif %}
104
105 {%- endif %}