Build in opendaylight service mask
[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:
36   pkg.installed:
37   - require:
38     - pkgrepo: opendaylight_repo
39   - require_in:
40     - file: /opt/opendaylight/etc/jetty.xml
41     - file: /opt/opendaylight/bin/setenv
42     - ini: /opt/opendaylight/etc/org.apache.karaf.features.cfg
43     - ini: /opt/opendaylight/etc/org.ops4j.pax.web.cfg
44   service.running:
45   - enable: true
46   - watch:
47     - file: /opt/opendaylight/etc/jetty.xml
48     - file: /opt/opendaylight/bin/setenv
49     - ini: /opt/opendaylight/etc/org.apache.karaf.features.cfg
50     - ini: /opt/opendaylight/etc/org.ops4j.pax.web.cfg
51
52 # TODO: use service.masked state once salt get updated to 2017.7.0+
53 service.mask:
54   module.run:
55   - m_name: opendaylight
56   - require_in:
57     - pkg: opendaylight
58
59 /opt/opendaylight/etc/jetty.xml:
60   file.managed:
61   - source: salt://opendaylight/files/jetty.xml
62   - template: jinja
63   - user: odl
64   - group: odl
65
66 /opt/opendaylight/bin/setenv:
67   file.managed:
68   - source: salt://opendaylight/files/setenv.shell
69   - mode: 0755
70   - use:
71     - file: /opt/opendaylight/etc/jetty.xml
72
73 {% set features %}
74 {%- for f in server.karaf_features.itervalues() -%}
75 {{ f | join(',') }}{%- if not loop.last %},{%- endif %}
76 {%- endfor %}
77 {% endset %}
78
79 /opt/opendaylight/etc/org.apache.karaf.features.cfg:
80   ini.options_present:
81     - sections:
82         featuresBoot: {{ features }}
83
84 /opt/opendaylight/etc/org.ops4j.pax.web.cfg:
85   ini.options_present:
86     - sections:
87         org.ops4j.pax.web.listening.addresses: {{ server.odl_bind_ip }}
88         org.osgi.service.http.port: {{ server.odl_rest_port }}
89
90 {%- if server.get('router_enabled', false) %}
91 /opt/opendaylight/etc/custom.properties:
92   ini.options_present:
93     - sections:
94         ovsdb.l3.fwd.enabled: 'yes'
95         ovsdb.of.version: 1.3
96     - require:
97       - pkg: opendaylight
98     - watch_in:
99       - service: opendaylight
100 {%- endif %}
101
102 {%- endif %}