blob: 36247e6f80861a01d9d6b8a9ebfe2dbf4afe3cc7 [file] [log] [blame]
Your Name902fb6b2017-06-21 15:34:36 +00001{%- from "baremetal_simulator/map.jinja" import baremetal_simulator,bs_nodes with context %}
Your Name8324a3a2017-05-12 10:47:21 +00002{%- if baremetal_simulator.enabled %}
3
4simulator_pkgs:
5 pkg.installed:
6 - names: {{ baremetal_simulator.pkgs }}
7
8simulator_pip_pkgs:
9 pip.installed:
10 - names: {{ baremetal_simulator.pip_pkgs }}
11 - require:
Vasyl Saienko5a853fd2017-07-10 14:40:05 +030012 - simulator_pkgs
Your Name8324a3a2017-05-12 10:47:21 +000013
Vasyl Saienko64792aa2017-08-18 14:45:57 +030014{%- if baremetal_simulator.get('tor', {}).get('enabled', False) %}
15
16openvswitch-vtep-pkg:
17 pkg.installed:
18 - name: openvswitch-vtep
19
20openvswitch-vtep.init:
21 file.managed:
22 - name: /etc/init.d/openvswitch-vtep
23 - source: salt://baremetal_simulator/files/openvswitch/openvswitch-vtep.init
24 - require:
25 - openvswitch-vtep-pkg
26
27openvswitch-vtep.default:
28 file.managed:
29 - name: /etc/default/openvswitch-vtep
30 - source: salt://baremetal_simulator/files/openvswitch/openvswitch-vtep.default
31 - require:
32 - openvswitch-vtep-pkg
33
34openvswitch-vtep:
35 service.running:
36 - watch:
37 - file: /etc/init.d/openvswitch-vtep
38 - file: /etc/default/openvswitch-vtep
39 - require:
40 - openvswitch-vtep.init
41 - openvswitch-vtep.default
42
43br_simulator_ps_present:
44 cmd.run:
45 - name: vtep-ctl add-ps br-simulator
46 - unless: vtep-ctl ps-exists br-simulator
47
48br_simulator_vtep_tunnel:
49 cmd.run:
50 - name: vtep-ctl set Physical_Switch br-simulator tunnel_ips={{ baremetal_simulator.tor.tunnel_ips }}
51 - unless: vtep-ctl show br-baremetal | grep -q "tunnel_ips.*{{ baremetal_simulator.tor.tunnel_ips }}"
52 - require:
53 - br_simulator_ps_present
54
55br_simulator_vtep_management:
56 cmd.run:
57 - name: vtep-ctl set Physical_Switch br-simulator management_ips={{ baremetal_simulator.tor.tunnel_ips }}
58 - unless: vtep-ctl show br-baremetal | grep -q "management_ips.*{{ baremetal_simulator.tor.tunnel_ips }}"
59 - require:
60 - br_simulator_ps_present
61
62br_simulator_vtep:
63 cmd.run:
64 - name: /usr/share/openvswitch/scripts/ovs-vtep --log-file=/var/log/openvswitch/ovs-vtep.log --pidfile=/var/run/openvswitch/ovs-vtep.pid --detach br-simulator
65 - unless: ps xafu |grep -v grep |grep -q "ovs-vtep .* br-simulator"
66 - require:
67 - br_simulator_vtep_management
68 - br_simulator_vtep_tunnel
69
70{%- endif %}
71
Your Name8324a3a2017-05-12 10:47:21 +000072libvirt-bin:
73 service.running:
74 - watch:
75 - file: /etc/libvirt/qemu.conf
76
77cgroup:
78 file.append:
79 - name: /etc/libvirt/qemu.conf
Your Name8ba54822017-05-12 12:17:39 +000080 - source: salt://baremetal_simulator/files/qemu-cgroup.conf
Your Name8324a3a2017-05-12 10:47:21 +000081
Your Name8324a3a2017-05-12 10:47:21 +000082default_pool:
83 cmd.run:
84 - name: virsh pool-define-as --name default dir --target /var/lib/libvirt/images && virsh pool-autostart default && virsh pool-start default
85 - unless: virsh pool-info default
86
87/var/log/ironic-bm-logs/:
88 file.directory:
89 - makedirs: true
90
Your Name902fb6b2017-06-21 15:34:36 +000091{%- for identity_name, nodes in bs_nodes.iteritems() %}
Your Name8324a3a2017-05-12 10:47:21 +000092 {%- for node in nodes %}
93
94disk_create_node{{ loop.index }}:
95 cmd.run:
96 - name: virsh vol-create-as default {{ node.name }}.qcow2 --capacity {{ node.properties.local_gb }}G --format qcow2
97 - unless: test -f /var/lib/libvirt/images/{{ node.name }}.qcow2
98
99vm_{{ node.name }}_present:
100 cmd.run:
101 - name: virsh undefine {{ node.name }} && sleep 1; virsh define /tmp/{{ node.name }}.xml
102 - onchanges:
103 - file: /tmp/{{ node.name }}.xml
104
105/tmp/{{ node.name }}.xml:
106 file.managed:
107 - source: salt://baremetal_simulator/files/vm.xml
108 - template: jinja
109 - defaults:
110 node: {{ node }}
111
112vbcm_add_{{ node.name }}:
113 cmd.run:
114 - name: vbmc add {{ node.name }} --port {{ node.driver_info.ipmi_port }}
115 - unless: vbmc show {{ node.name }}
116
117vbmc_start_{{ node.name }}:
118 cmd.run:
119 - name: vbmc start {{ node.name }} > /dev/null 2>&1 && sleep 1
120 - unless: vbmc show {{ node.name }} | grep status |grep -q running
121
Your Name8324a3a2017-05-12 10:47:21 +0000122{%- for port in node.ports %}
123
124{{ node.name }}_tap_device_{{ loop.index }}:
125 cmd.run:
126 - name: ip tuntap add dev tap-{{ node.name }}i{{ loop.index }} mode tap; ip link set dev tap-{{ node.name }}i{{ loop.index }} up
127 - unless: ip link show tap-{{ node.name }}i{{ loop.index }}
128
129{{ node.name }}_tap{{ loop.index }}_in_ovs:
130 openvswitch_port.present:
131 - name: tap-{{ node.name }}i{{ loop.index }}
Your Name8c482f22017-06-21 09:45:57 +0000132 - bridge: br-simulator
Your Name8324a3a2017-05-12 10:47:21 +0000133
Your Name8324a3a2017-05-12 10:47:21 +0000134{%- endfor %}
135
136{%- endfor %}
137{%- endfor %}
138{%- endif %}