blob: ec8abbec8da16642704b117749e7790e1092ef1d [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:
12 - pkg: python-pip
13
14libvirt-bin:
15 service.running:
16 - watch:
17 - file: /etc/libvirt/qemu.conf
18
19cgroup:
20 file.append:
21 - name: /etc/libvirt/qemu.conf
Your Name8ba54822017-05-12 12:17:39 +000022 - source: salt://baremetal_simulator/files/qemu-cgroup.conf
Your Name8324a3a2017-05-12 10:47:21 +000023
Your Name8324a3a2017-05-12 10:47:21 +000024default_pool:
25 cmd.run:
26 - name: virsh pool-define-as --name default dir --target /var/lib/libvirt/images && virsh pool-autostart default && virsh pool-start default
27 - unless: virsh pool-info default
28
29/var/log/ironic-bm-logs/:
30 file.directory:
31 - makedirs: true
32
33deploy_ramdisk:
34 file.managed:
35 - name: {{ baremetal_simulator.http_root }}/{{ baremetal_simulator.deploy_ramdisk_file }}
36 - source: {{ baremetal_simulator.deploy_ramdisk_ref }}
37 - skip_verify: true
38
39deploy_kernel:
40 file.managed:
41 - name: {{ baremetal_simulator.http_root }}/{{ baremetal_simulator.deploy_kernel_file }}
42 - source: {{ baremetal_simulator.deploy_kernel_ref }}
43 - skip_verify: true
44
45{%- if baremetal_simulator.cirros_image_ref is defined %}
46
47{{ baremetal_simulator.cirros_image_name }}_file:
48 file.managed:
49 - name: {{ baremetal_simulator.http_root }}/{{ baremetal_simulator.cirros_image_name }}
50 - source: {{ baremetal_simulator.cirros_image_ref }}
51 - skip_verify: true
52
53{%- endif %}
54
Your Name902fb6b2017-06-21 15:34:36 +000055{%- for identity_name, nodes in bs_nodes.iteritems() %}
Your Name8324a3a2017-05-12 10:47:21 +000056 {%- for node in nodes %}
57
58disk_create_node{{ loop.index }}:
59 cmd.run:
60 - name: virsh vol-create-as default {{ node.name }}.qcow2 --capacity {{ node.properties.local_gb }}G --format qcow2
61 - unless: test -f /var/lib/libvirt/images/{{ node.name }}.qcow2
62
63vm_{{ node.name }}_present:
64 cmd.run:
65 - name: virsh undefine {{ node.name }} && sleep 1; virsh define /tmp/{{ node.name }}.xml
66 - onchanges:
67 - file: /tmp/{{ node.name }}.xml
68
69/tmp/{{ node.name }}.xml:
70 file.managed:
71 - source: salt://baremetal_simulator/files/vm.xml
72 - template: jinja
73 - defaults:
74 node: {{ node }}
75
76vbcm_add_{{ node.name }}:
77 cmd.run:
78 - name: vbmc add {{ node.name }} --port {{ node.driver_info.ipmi_port }}
79 - unless: vbmc show {{ node.name }}
80
81vbmc_start_{{ node.name }}:
82 cmd.run:
83 - name: vbmc start {{ node.name }} > /dev/null 2>&1 && sleep 1
84 - unless: vbmc show {{ node.name }} | grep status |grep -q running
85
Your Name8324a3a2017-05-12 10:47:21 +000086{%- for port in node.ports %}
87
88{{ node.name }}_tap_device_{{ loop.index }}:
89 cmd.run:
90 - name: ip tuntap add dev tap-{{ node.name }}i{{ loop.index }} mode tap; ip link set dev tap-{{ node.name }}i{{ loop.index }} up
91 - unless: ip link show tap-{{ node.name }}i{{ loop.index }}
92
93{{ node.name }}_tap{{ loop.index }}_in_ovs:
94 openvswitch_port.present:
95 - name: tap-{{ node.name }}i{{ loop.index }}
Your Name8c482f22017-06-21 09:45:57 +000096 - bridge: br-simulator
Your Name8324a3a2017-05-12 10:47:21 +000097
Your Name8324a3a2017-05-12 10:47:21 +000098{%- endfor %}
99
100{%- endfor %}
101{%- endfor %}
102{%- endif %}