|
| 1 | +tosca_definitions_version: cloudify_dsl_1_3 |
| 2 | + |
| 3 | +imports: |
| 4 | + - http://www.getcloudify.org/spec/cloudify/5.0.0/types.yaml |
| 5 | + - plugin:cloudify-utilities-plugin |
| 6 | + - plugin:cloudify-fabric-plugin |
| 7 | + - plugin:cloudify-libvirt-plugin |
| 8 | + |
| 9 | +inputs: |
| 10 | + |
| 11 | + fortigate_image: |
| 12 | + type: string |
| 13 | + description: > |
| 14 | + fortigate boot image. |
| 15 | +
|
| 16 | + user_data: |
| 17 | + type: string |
| 18 | + description: > |
| 19 | + user data |
| 20 | + default: | |
| 21 | + config system global |
| 22 | + set alias "FGVM001234567890" |
| 23 | + set hostname "FGVM001234567890" |
| 24 | + set timezone 04 |
| 25 | + end |
| 26 | + config system interface |
| 27 | + edit port1 |
| 28 | + set mode dhcp |
| 29 | + append allowaccess ssh |
| 30 | + end |
| 31 | + edit "ssl.root" |
| 32 | + set vdom "root" |
| 33 | + set type tunnel |
| 34 | + set alias "SSL VPN interface" |
| 35 | + set snmp-index 4 |
| 36 | + next |
| 37 | + end |
| 38 | +
|
| 39 | + meta_data: |
| 40 | + type: string |
| 41 | + description: > |
| 42 | + meta data |
| 43 | + default: | |
| 44 | + {"uid": "fortinet","name":"fortinet"} |
| 45 | +
|
| 46 | + # cluster(kvm) settings |
| 47 | + cluster_user: |
| 48 | + type: string |
| 49 | + description: > |
| 50 | + Cluster user name. |
| 51 | + default: { get_secret: libvirt_cluster_user } |
| 52 | + |
| 53 | + cluster_key: |
| 54 | + type: string |
| 55 | + description: > |
| 56 | + SSH key for cluster user. |
| 57 | + default: { get_secret: libvirt_cluster_key } |
| 58 | + |
| 59 | + cluster_host: |
| 60 | + type: string |
| 61 | + description: > |
| 62 | + LibVirt computer ip address. |
| 63 | + default: { get_secret: libvirt_cluster_host } |
| 64 | + |
| 65 | + libvirt_common_network: |
| 66 | + type: string |
| 67 | + description: > |
| 68 | + Manager common network |
| 69 | + default: { get_secret: libvirt_common_network } |
| 70 | + |
| 71 | + external_ip: |
| 72 | + type: string |
| 73 | + description: > |
| 74 | + List external ip's separated by comma. |
| 75 | + default: { get_secret: libvirt_cluster_external_ip } |
| 76 | + |
| 77 | + external_dev: |
| 78 | + type: string |
| 79 | + description: > |
| 80 | + Device with external access (same device as used for cluster_host ip) |
| 81 | + default: { get_secret: libvirt_cluster_external_dev } |
| 82 | + |
| 83 | +dsl_definitions: |
| 84 | + |
| 85 | + libvirt_auth: &libvirt_auth |
| 86 | + concat: |
| 87 | + - "qemu+ssh://" |
| 88 | + - { get_input: cluster_user } |
| 89 | + - "@" |
| 90 | + - { get_input: cluster_host } |
| 91 | + - "/system?sshauth=privkey&keyfile=" |
| 92 | + - { get_input: cluster_key } |
| 93 | + |
| 94 | +relationships: |
| 95 | + |
| 96 | + vm_connected_to_storage: |
| 97 | + derived_from: cloudify.relationships.contained_in |
| 98 | + target_interfaces: |
| 99 | + cloudify.interfaces.relationship_lifecycle: |
| 100 | + preconfigure: |
| 101 | + implementation: scripts/vm_preconfigure.py |
| 102 | + executor: central_deployment_agent |
| 103 | + inputs: {} |
| 104 | + |
| 105 | +node_templates: |
| 106 | + |
| 107 | + manager_network: |
| 108 | + type: cloudify.libvirt.network |
| 109 | + properties: |
| 110 | + libvirt_auth: *libvirt_auth |
| 111 | + interfaces: |
| 112 | + cloudify.interfaces.lifecycle: |
| 113 | + create: |
| 114 | + inputs: |
| 115 | + params: |
| 116 | + name: manager_network |
| 117 | + dev: virbr9 |
| 118 | + forwards: |
| 119 | + - mode: nat |
| 120 | + ips: |
| 121 | + - address: 192.168.149.1 |
| 122 | + netmask: 255.255.255.0 |
| 123 | + dhcp: |
| 124 | + start: 192.168.149.2 |
| 125 | + end: 192.168.149.254 |
| 126 | + |
| 127 | + public_network: |
| 128 | + type: cloudify.libvirt.network |
| 129 | + properties: |
| 130 | + libvirt_auth: *libvirt_auth |
| 131 | + interfaces: |
| 132 | + cloudify.interfaces.lifecycle: |
| 133 | + create: |
| 134 | + inputs: |
| 135 | + params: |
| 136 | + name: public_network |
| 137 | + dev: virbr8 |
| 138 | + ips: |
| 139 | + - address: 10.10.10.1 |
| 140 | + netmask: 255.255.255.0 |
| 141 | + dhcp: |
| 142 | + start: 10.10.10.2 |
| 143 | + end: 10.10.10.254 |
| 144 | + |
| 145 | + private_network: |
| 146 | + type: cloudify.libvirt.network |
| 147 | + properties: |
| 148 | + libvirt_auth: *libvirt_auth |
| 149 | + interfaces: |
| 150 | + cloudify.interfaces.lifecycle: |
| 151 | + create: |
| 152 | + inputs: |
| 153 | + params: |
| 154 | + name: private_network |
| 155 | + dev: virbr7 |
| 156 | + ips: |
| 157 | + - address: 10.100.100.1 |
| 158 | + netmask: 255.255.255.0 |
| 159 | + dhcp: |
| 160 | + start: 10.100.100.2 |
| 161 | + end: 10.100.100.254 |
| 162 | + |
| 163 | + common_pool: |
| 164 | + type: cloudify.libvirt.pool |
| 165 | + properties: |
| 166 | + libvirt_auth: *libvirt_auth |
| 167 | + interfaces: |
| 168 | + cloudify.interfaces.lifecycle: |
| 169 | + create: |
| 170 | + inputs: |
| 171 | + params: |
| 172 | + capacity: 80 |
| 173 | + |
| 174 | + boot_volume: |
| 175 | + type: cloudify.libvirt.volume |
| 176 | + properties: |
| 177 | + libvirt_auth: *libvirt_auth |
| 178 | + interfaces: |
| 179 | + cloudify.interfaces.lifecycle: |
| 180 | + create: |
| 181 | + inputs: |
| 182 | + params: |
| 183 | + pool: { get_attribute: [common_pool, resource_id]} |
| 184 | + capacity: 12800 |
| 185 | + allocation: 12800 |
| 186 | + url: { get_input: fortigate_image } |
| 187 | + relationships: |
| 188 | + - target: common_pool |
| 189 | + type: cloudify.relationships.depends_on |
| 190 | + |
| 191 | + cloudinit_volume: |
| 192 | + type: cloudify.libvirt.volume |
| 193 | + properties: |
| 194 | + libvirt_auth: *libvirt_auth |
| 195 | + interfaces: |
| 196 | + cloudify.interfaces.lifecycle: |
| 197 | + create: |
| 198 | + inputs: |
| 199 | + params: |
| 200 | + pool: { get_attribute: [common_pool, resource_id]} |
| 201 | + capacity: 1 |
| 202 | + allocation: 1 |
| 203 | + relationships: |
| 204 | + - target: common_pool |
| 205 | + type: cloudify.relationships.depends_on |
| 206 | + |
| 207 | + cloud_init_image: |
| 208 | + type: cloudify.libvirt.ISO9660 |
| 209 | + properties: |
| 210 | + libvirt_auth: *libvirt_auth |
| 211 | + interfaces: |
| 212 | + cloudify.interfaces.lifecycle: |
| 213 | + create: |
| 214 | + inputs: |
| 215 | + params: |
| 216 | + pool: { get_attribute: [common_pool, resource_id]} |
| 217 | + volume: { get_attribute: [cloudinit_volume, resource_id]} |
| 218 | + vol_ident: config-2 |
| 219 | + files: |
| 220 | + "openstack/latest/network_data.json": "{}" |
| 221 | + "openstack/latest/user_data": { get_input: user_data } |
| 222 | + "openstack/latest/meta_data.json": { get_input: meta_data } |
| 223 | + "openstack/2015-10-15/network_data.json": "{}" |
| 224 | + "openstack/2015-10-15/user_data": { get_input: user_data } |
| 225 | + "openstack/2015-10-15/meta_data.json": { get_input: meta_data } |
| 226 | + "user_data": { get_input: user_data } |
| 227 | + "userdata.txt": { get_input: user_data } |
| 228 | + relationships: |
| 229 | + - target: cloudinit_volume |
| 230 | + type: cloudify.relationships.depends_on |
| 231 | + |
| 232 | + base_vm: |
| 233 | + type: cloudify.libvirt.domain |
| 234 | + properties: |
| 235 | + libvirt_auth: *libvirt_auth |
| 236 | + agent_config: |
| 237 | + install_method: none |
| 238 | + interfaces: |
| 239 | + cloudify.interfaces.lifecycle: |
| 240 | + create: |
| 241 | + inputs: |
| 242 | + params: |
| 243 | + vcpu: 1 |
| 244 | + memory_size: 524288 # 1Gb in Kb |
| 245 | + domain_type: kvm |
| 246 | + disks: |
| 247 | + - bus: scsi |
| 248 | + dev: sda |
| 249 | + file: { get_attribute: [boot_volume, params, path] } |
| 250 | + type: qcow2 |
| 251 | + - bus: scsi |
| 252 | + dev: sdb |
| 253 | + file: { get_attribute: [cloudinit_volume, params, path] } |
| 254 | + type: raw |
| 255 | + networks: |
| 256 | + - network: { get_attribute: [manager_network, resource_id] } |
| 257 | + dev: vnet0 |
| 258 | + mac: 52:54:00:c0:67:81 |
| 259 | + type: virtio |
| 260 | + - network: { get_attribute: [public_network, resource_id] } |
| 261 | + dev: vnet0 |
| 262 | + mac: 52:54:00:c0:67:82 |
| 263 | + - network: { get_attribute: [private_network, resource_id] } |
| 264 | + dev: vnet0 |
| 265 | + mac: 52:54:00:c0:67:83 |
| 266 | + configure: |
| 267 | + inputs: |
| 268 | + template_resource: templates/domain-x86-kvm.xml |
| 269 | + relationships: |
| 270 | + - target: manager_network |
| 271 | + type: cloudify.libvirt.relationships.connected_to |
| 272 | + - target: public_network |
| 273 | + type: cloudify.relationships.connected_to |
| 274 | + - target: private_network |
| 275 | + type: cloudify.relationships.connected_to |
| 276 | + - target: cloud_init_image |
| 277 | + type: cloudify.relationships.depends_on |
| 278 | + - target: boot_volume |
| 279 | + type: cloudify.relationships.depends_on |
| 280 | + |
| 281 | + floating_ip: |
| 282 | + type: cloudify.nodes.VirtualIP |
| 283 | + interfaces: |
| 284 | + cloudify.interfaces.lifecycle: |
| 285 | + create: |
| 286 | + implementation: fabric.fabric_plugin.tasks.run_script |
| 287 | + inputs: |
| 288 | + fabric_env: &fab_env |
| 289 | + user: { get_input: cluster_user } |
| 290 | + key_filename: { get_input: cluster_key } |
| 291 | + host_string: { get_input: cluster_host } |
| 292 | + EXTERNAL_INTERFACE: { get_input: external_dev } |
| 293 | + EXTERNAL_IP: { get_input: external_ip } |
| 294 | + INTERNAL_IP: { get_attribute: [base_vm, ip] } |
| 295 | + script_path: cluster/floating_ip.py |
| 296 | + delete: |
| 297 | + implementation: fabric.fabric_plugin.tasks.run_script |
| 298 | + inputs: |
| 299 | + fabric_env: *fab_env |
| 300 | + script_path: cluster/floating_ip_delete.py |
| 301 | + relationships: |
| 302 | + - target: base_vm |
| 303 | + type: cloudify.relationships.connected_to |
| 304 | + |
| 305 | + fortinet_vm: |
| 306 | + type: cloudify.nodes.ApplicationServer |
| 307 | + interfaces: |
| 308 | + cloudify.interfaces.lifecycle: |
| 309 | + start: |
| 310 | + implementation: terminal.cloudify_terminal.tasks.run |
| 311 | + inputs: |
| 312 | + terminal_auth: &terminal_auth |
| 313 | + user: admin |
| 314 | + password: "" |
| 315 | + ip: { get_attribute: [floating_ip, external_ip] } |
| 316 | + port: 22 |
| 317 | + store_logs: true |
| 318 | + promt_check: |
| 319 | + - '#' |
| 320 | + calls: |
| 321 | + - action: show system interface |
| 322 | + responses: # list of responses |
| 323 | + - question: "--More--" |
| 324 | + answer: "" |
| 325 | + newline: true |
| 326 | + relationships: |
| 327 | + - target: base_vm |
| 328 | + type: cloudify.relationships.depends_on |
| 329 | + - target: floating_ip |
| 330 | + type: cloudify.relationships.depends_on |
0 commit comments