Merge "[state] virtual_init: Limit to mas01 on baremetal"
[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   - prereq:
45     - pkg: opendaylight
46
47 opendaylight:
48   pkg.installed:
49   - require:
50     - pkgrepo: opendaylight_repo
51   service.running:
52   - enable: true
53 {%- if grains['saltversioninfo'] >= [2017, 7] %}
54   - unmask: true
55 {%- endif %}
56   - watch:
57     - file: /opt/opendaylight/etc/jetty.xml
58     - file: /opt/opendaylight/bin/setenv
59     - ini: /opt/opendaylight/etc/org.apache.karaf.features.cfg
60     - ini: /opt/opendaylight/etc/org.ops4j.pax.web.cfg
61     - ini: /opt/opendaylight/etc/org.opendaylight.openflowplugin.cfg
62
63 /opt/opendaylight/etc/jetty.xml:
64   file.managed:
65   - source: salt://opendaylight/files/jetty.xml
66   - template: jinja
67   - user: odl
68   - group: odl
69
70 /opt/opendaylight/bin/setenv:
71   file.managed:
72   - source: salt://opendaylight/files/setenv.shell
73   - mode: 0755
74   - use:
75     - file: /opt/opendaylight/etc/jetty.xml
76
77 {% set features %}
78 {%- for f in server.karaf_features.itervalues() -%}
79 {{ f | join(',') }}{%- if not loop.last %},{%- endif %}
80 {%- endfor %}
81 {% endset %}
82
83 /opt/opendaylight/etc/org.apache.karaf.features.cfg:
84   ini.options_present:
85     - sections:
86         featuresBoot: {{ features }}
87
88 /opt/opendaylight/etc/org.ops4j.pax.web.cfg:
89   ini.options_present:
90     - sections:
91         org.ops4j.pax.web.listening.addresses: {{ server.odl_bind_ip }}
92         org.osgi.service.http.port: {{ server.odl_rest_port }}
93
94 /opt/opendaylight/etc/org.opendaylight.openflowplugin.cfg:
95   ini.options_present:
96     - sections:
97         is-statistics-polling-on: {{ server.stats_polling_enabled }}
98
99 {%- if server.get('router_enabled', false) %}
100 /opt/opendaylight/etc/custom.properties:
101   ini.options_present:
102     - sections:
103         ovsdb.l3.fwd.enabled: 'yes'
104         ovsdb.of.version: 1.3
105     - require:
106       - pkg: opendaylight
107     - watch_in:
108       - service: opendaylight
109 {%- endif %}
110
111 {%- if server.dhcp.enabled %}
112 /opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-dhcpservice-config.xml:
113   file.managed:
114   - source: salt://opendaylight/files/netvirt-dhcpservice-config.xml
115   - makedirs: true
116   - watch_in:
117     - service: opendaylight
118   - use:
119     - file: /opt/opendaylight/etc/jetty.xml
120 {%- endif %}
121
122 {%- if grains['cpuarch'] == 'aarch64' %}
123 opendaylight-leveldbjni:
124   pkg.installed
125 {%- endif %}
126
127 {%- endif %}