Merge "[lab-config] Use Pharos submodule by default"
[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 %}
19       - http_proxy: {{ system.proxy.keyserver.http }}
20 {%- endif %}
21 {%- if system.proxy.keyserver.https is defined %}
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/nitrogen/ubuntu xenial main
33   - file: /etc/apt/sources.list.d/odl-team-ubuntu-nitrogen-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 /opt/opendaylight/etc/jetty.xml:
53   file.managed:
54   - source: salt://opendaylight/files/jetty.xml
55   - template: jinja
56   - user: odl
57   - group: odl
58
59 /opt/opendaylight/bin/setenv:
60   file.managed:
61   - source: salt://opendaylight/files/setenv.shell
62   - mode: 0755
63   - use:
64     - file: /opt/opendaylight/etc/jetty.xml
65
66 {% set features %}
67 {%- for f in server.karaf_features.itervalues() -%}
68 {{ f | join(',') }}{%- if not loop.last %},{%- endif %}
69 {%- endfor %}
70 {% endset %}
71
72 /opt/opendaylight/etc/org.apache.karaf.features.cfg:
73   ini.options_present:
74     - sections:
75         featuresBoot: {{ features }}
76
77 /opt/opendaylight/etc/org.ops4j.pax.web.cfg:
78   ini.options_present:
79     - sections:
80         org.ops4j.pax.web.listening.addresses: {{ server.odl_bind_ip }}
81
82 {%- if server.get('router_enabled', false) %}
83 /opt/opendaylight/etc/custom.properties:
84   ini.options_present:
85     - sections:
86         ovsdb.l3.fwd.enabled: 'yes'
87         ovsdb.of.version: 1.3
88     - require:
89       - pkg: opendaylight
90     - watch_in:
91       - service: opendaylight
92 {%- endif %}
93
94 {%- endif %}