Your Name | 902fb6b | 2017-06-21 15:34:36 +0000 | [diff] [blame] | 1 | {%- from "baremetal_simulator/map.jinja" import baremetal_simulator,bs_nodes with context %} |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 2 | {%- if baremetal_simulator.enabled %} |
| 3 | |
| 4 | simulator_pkgs: |
| 5 | pkg.installed: |
| 6 | - names: {{ baremetal_simulator.pkgs }} |
| 7 | |
| 8 | simulator_pip_pkgs: |
| 9 | pip.installed: |
| 10 | - names: {{ baremetal_simulator.pip_pkgs }} |
| 11 | - require: |
Vasyl Saienko | 5a853fd | 2017-07-10 14:40:05 +0300 | [diff] [blame] | 12 | - simulator_pkgs |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 13 | |
Vasyl Saienko | 64792aa | 2017-08-18 14:45:57 +0300 | [diff] [blame] | 14 | {%- if baremetal_simulator.get('tor', {}).get('enabled', False) %} |
| 15 | |
| 16 | openvswitch-vtep-pkg: |
| 17 | pkg.installed: |
| 18 | - name: openvswitch-vtep |
| 19 | |
| 20 | openvswitch-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 | |
| 27 | openvswitch-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 | |
| 34 | openvswitch-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 | |
| 43 | br_simulator_ps_present: |
| 44 | cmd.run: |
| 45 | - name: vtep-ctl add-ps br-simulator |
| 46 | - unless: vtep-ctl ps-exists br-simulator |
| 47 | |
| 48 | br_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 | |
| 55 | br_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 | |
| 62 | br_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 | |
Your Name | bea2f08 | 2017-12-04 12:13:28 +0000 | [diff] [blame^] | 70 | brphyv_in_ovs: |
| 71 | openvswitch_port.present: |
| 72 | - name: brphyv |
| 73 | - bridge: br-simulator |
| 74 | |
Vasyl Saienko | 64792aa | 2017-08-18 14:45:57 +0300 | [diff] [blame] | 75 | {%- endif %} |
| 76 | |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 77 | libvirt-bin: |
| 78 | service.running: |
| 79 | - watch: |
| 80 | - file: /etc/libvirt/qemu.conf |
| 81 | |
| 82 | cgroup: |
| 83 | file.append: |
| 84 | - name: /etc/libvirt/qemu.conf |
Your Name | 8ba5482 | 2017-05-12 12:17:39 +0000 | [diff] [blame] | 85 | - source: salt://baremetal_simulator/files/qemu-cgroup.conf |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 86 | |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 87 | default_pool: |
| 88 | cmd.run: |
| 89 | - name: virsh pool-define-as --name default dir --target /var/lib/libvirt/images && virsh pool-autostart default && virsh pool-start default |
| 90 | - unless: virsh pool-info default |
| 91 | |
| 92 | /var/log/ironic-bm-logs/: |
| 93 | file.directory: |
| 94 | - makedirs: true |
| 95 | |
Your Name | 902fb6b | 2017-06-21 15:34:36 +0000 | [diff] [blame] | 96 | {%- for identity_name, nodes in bs_nodes.iteritems() %} |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 97 | {%- for node in nodes %} |
| 98 | |
| 99 | disk_create_node{{ loop.index }}: |
| 100 | cmd.run: |
| 101 | - name: virsh vol-create-as default {{ node.name }}.qcow2 --capacity {{ node.properties.local_gb }}G --format qcow2 |
| 102 | - unless: test -f /var/lib/libvirt/images/{{ node.name }}.qcow2 |
| 103 | |
| 104 | vm_{{ node.name }}_present: |
| 105 | cmd.run: |
| 106 | - name: virsh undefine {{ node.name }} && sleep 1; virsh define /tmp/{{ node.name }}.xml |
| 107 | - onchanges: |
| 108 | - file: /tmp/{{ node.name }}.xml |
| 109 | |
| 110 | /tmp/{{ node.name }}.xml: |
| 111 | file.managed: |
| 112 | - source: salt://baremetal_simulator/files/vm.xml |
| 113 | - template: jinja |
| 114 | - defaults: |
| 115 | node: {{ node }} |
| 116 | |
| 117 | vbcm_add_{{ node.name }}: |
| 118 | cmd.run: |
| 119 | - name: vbmc add {{ node.name }} --port {{ node.driver_info.ipmi_port }} |
| 120 | - unless: vbmc show {{ node.name }} |
| 121 | |
| 122 | vbmc_start_{{ node.name }}: |
| 123 | cmd.run: |
| 124 | - name: vbmc start {{ node.name }} > /dev/null 2>&1 && sleep 1 |
| 125 | - unless: vbmc show {{ node.name }} | grep status |grep -q running |
| 126 | |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 127 | {%- for port in node.ports %} |
| 128 | |
| 129 | {{ node.name }}_tap_device_{{ loop.index }}: |
| 130 | cmd.run: |
| 131 | - name: ip tuntap add dev tap-{{ node.name }}i{{ loop.index }} mode tap; ip link set dev tap-{{ node.name }}i{{ loop.index }} up |
| 132 | - unless: ip link show tap-{{ node.name }}i{{ loop.index }} |
| 133 | |
| 134 | {{ node.name }}_tap{{ loop.index }}_in_ovs: |
| 135 | openvswitch_port.present: |
| 136 | - name: tap-{{ node.name }}i{{ loop.index }} |
Your Name | 8c482f2 | 2017-06-21 09:45:57 +0000 | [diff] [blame] | 137 | - bridge: br-simulator |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 138 | |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 139 | {%- endfor %} |
| 140 | |
| 141 | {%- endfor %} |
| 142 | {%- endfor %} |
| 143 | {%- endif %} |