1- # before use:
2- # * cat examples/cluster/id_rsa.pub | ssh <cluster_user>@<cluster_host> "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys"
3- # * and set cluster_key to examples/cluster/id_rsa
41tosca_definitions_version : cloudify_dsl_1_3
52
63imports :
@@ -18,8 +15,11 @@ inputs:
1815 agent_public_key :
1916 default : { get_secret: agent_key_public }
2017
18+ agent_key_private :
19+ default : { get_secret: agent_key_private }
20+
2121 disk_size :
22- default : 24GB
22+ default : 80GB
2323
2424 agent_private_key :
2525 default : { get_secret: agent_private_key }
@@ -37,12 +37,6 @@ inputs:
3737 SSH key for cluster user.
3838 default : { get_secret: libvirt_cluster_key }
3939
40- manager_network :
41- type : string
42- description : >
43- Manager network.
44- default : { get_secret: libvirt_common_network }
45-
4640 cluster_host :
4741 type : string
4842 description : >
@@ -61,6 +55,12 @@ inputs:
6155 Device with external access (same device as used for cluster_host ip)
6256 default : { get_secret: libvirt_cluster_external_dev }
6357
58+ libvirt_common_network :
59+ type : string
60+ description : >
61+ Manager common network
62+ default : { get_secret: libvirt_common_network }
63+
6464relationships :
6565
6666 vm_connected_to_storage :
@@ -99,10 +99,10 @@ node_templates:
9999 inputs :
100100 fabric_env : *fab_env
101101 script_path : scripts/download_vm.sh
102- CATALOG_URL : https ://cloud.centos .org/centos/7/images/
103- DISK : CentOS-7-x86_64-GenericCloud-1805 .qcow2
102+ CATALOG_URL : http ://repository.cloudifysource .org/cloudify/4.4.0/ga-release
103+ DISK : cloudify-manager-4.4ga .qcow2
104104
105- common_network :
105+ manager_network :
106106 type : cloudify.libvirt.network
107107 properties :
108108 libvirt_auth : &libvirt_auth
@@ -118,15 +118,16 @@ node_templates:
118118 create :
119119 inputs :
120120 params :
121- dev : virbr1
121+ resource_id : manager_network
122+ dev : virbr9
122123 forwards :
123124 - mode : nat
124125 ips :
125- - address : 192.168.141 .1
126+ - address : 192.168.149 .1
126127 netmask : 255.255.255.0
127128 dhcp :
128- start : 192.168.141 .2
129- end : 192.168.141 .254
129+ start : 192.168.149 .2
130+ end : 192.168.149 .254
130131 relationships :
131132 - target : vm_download
132133 type : cloudify.relationships.depends_on
@@ -146,6 +147,15 @@ node_templates:
146147 sudo : ['ALL=(ALL) NOPASSWD:ALL']
147148 ssh-authorized-keys :
148149 - { get_input: agent_public_key }
150+ write_files :
151+ - path : /etc/cloudify/kvm.key
152+ owner : cfyuser:cfyuser
153+ permissions : ' 0400'
154+ content : { get_input: agent_private_key }
155+ - path : /etc/cloudify/kvm.key.pub
156+ owner : cfyuser:cfyuser
157+ permissions : ' 0400'
158+ content : { get_input: agent_public_key }
149159
150160 disk_clone :
151161 type : cloudify.nodes.ApplicationServer
@@ -186,13 +196,13 @@ node_templates:
186196 inputs :
187197 params :
188198 vcpu : 2
189- memory_size : 1048576
199+ memory_size : 8388608 # 8Gb in Kb
190200 domain_type : kvm
191201 networks :
192- - network : { get_attribute: [common_network , resource_id] }
202+ - network : { get_attribute: [manager_network , resource_id] }
193203 dev : vnet0
194204 relationships :
195- - target : common_network
205+ - target : manager_network
196206 type : cloudify.libvirt.relationships.connected_to
197207 - target : disk_clone
198208 type : vm_connected_to_storage
@@ -218,19 +228,100 @@ node_templates:
218228 - target : base_vm
219229 type : cloudify.relationships.connected_to
220230
231+ qemu_vm :
232+ type : agent_domain
233+ properties :
234+ use_public_ip : true
235+ agent_config :
236+ user : { get_input: agent_user }
237+ key : { get_input: agent_private_key }
238+ install_method : remote
239+ interfaces :
240+ cloudify.interfaces.lifecycle :
241+ create :
242+ implementation : scripts/vm_fillip.py
243+ executor : central_deployment_agent
244+ start :
245+ implementation : terminal.cloudify_terminal.tasks.run
246+ inputs :
247+ terminal_auth : &terminal_auth
248+ user : { get_input: agent_user }
249+ ip : { get_attribute: [SELF, ip] }
250+ key_content : { get_input: agent_private_key }
251+ port : 22
252+ promt_check :
253+ - ' $'
254+ calls :
255+ # network fix
256+ - action : sudo ip link set dev eth0 mtu 1400
257+ # space fix
258+ - action : sudo sudo xfs_growfs /
259+ # add additional/support tools
260+ - action : sudo yum install -y openssl-1.0.2k deltarpm nano
261+ # add libvirt dependencies
262+ - action : sudo yum install -y libvirt-devel libvirt libvirt-python
263+ - action : sudo service libvirtd restart
264+ - action : sudo groupadd libvirt
265+ - action : sudo usermod -a -G libvirt cfyuser
266+ - action : sudo usermod -a -G kvm cfyuser
267+ - action : sudo usermod -a -G qemu cfyuser
268+ # upload plugins
269+ - action : cfy profile use localhost -u admin -p admin -t default_tenant
270+ - action : cfy plugins bundle-upload
271+ - action : cfy plugin upload -y https://github.com/cloudify-incubator/cloudify-utilities-plugin/releases/download/1.9.2/plugin.yaml http://repository.cloudifysource.org/cloudify/wagons/cloudify-utilities-plugin/1.9.2/cloudify_utilities_plugin-1.9.2-py27-none-linux_x86_64-centos-Core.wgn
272+ - action : cfy plugin upload -y https://github.com/cloudify-incubator/cloudify-libvirt-plugin/releases/download/0.5.0/plugin.yaml https://github.com/cloudify-incubator/cloudify-libvirt-plugin/releases/download/0.5.0/cloudify_libvirt_plugin-0.5.0-py27-none-linux_x86_64-centos-Core.wgn
273+ - action : cfy plugin upload -y https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/releases/download/2.3.1/plugin.yaml https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/releases/download/2.3.1/cloudify_kubernetes_plugin-2.3.1-py27-none-linux_x86_64-centos-Core.wgn
274+ # set secrets
275+ - action : sudo cfy secret create agent_key_private -u -f /etc/cloudify/kvm.key
276+ - action : sudo cfy secret create agent_key_public -u -f /etc/cloudify/kvm.key.pub
277+ - action : cfy secret create agent_use_public_ip -u -s "private"
278+ - action : {concat:["cfy secret create agent_user -u -s '", { get_input: agent_user }, "'"]}
279+ - action : cfy secret create bootstrap_hash -u -s "#"
280+ - action : cfy secret create bootstrap_token -u -s "#"
281+ - action : cfy secret create cfy_password -u -s admin
282+ - action : cfy secret create cfy_tenant -u -s default_tenant
283+ - action : cfy secret create cfy_user -u -s admin
284+ - action : cfy secret create kubernetes-admin_client_certificate_data -u -s "#"
285+ - action : cfy secret create kubernetes-admin_client_key_data -u -s "#"
286+ - action : cfy secret create kubernetes_certificate_authority_data -u -s "#"
287+ - action : cfy secret create kubernetes_master_ip -u -s "#"
288+ - action : cfy secret create kubernetes_master_port -u -s "#"
289+ - action : {concat:["cfy secret create libvirt_cluster_external_dev -u -s ", { get_input: external_dev }]}
290+ - action : {concat:["cfy secret create libvirt_cluster_external_ip -u -s '", { get_input: external_ip }, "'"]}
291+ - action : {concat:["cfy secret create libvirt_cluster_host -u -s ", { get_input: cluster_host }]}
292+ - action : {concat:["cfy secret create libvirt_cluster_key -u -s ", { get_input: cluster_key }]}
293+ - action : {concat:["cfy secret create libvirt_cluster_user -u -s ", { get_input: cluster_user }]}
294+ - action : {concat:["cfy secret create libvirt_common_network -u -s ", { get_input: libvirt_common_network }]}
295+ relationships :
296+ - target : base_vm
297+ type : cloudify.relationships.depends_on
298+ - target : floating_ip
299+ type : cloudify.relationships.depends_on
300+
221301 example_node :
222302 type : cloudify.nodes.WebServer
223303 interfaces :
224304 cloudify.interfaces.lifecycle :
225- start :
226- implementation : terminal.cloudify_terminal.tasks.run
227- inputs :
228- terminal_auth :
229- user : { get_input: agent_user }
230- key_content : { get_input: agent_private_key }
231- ip : { get_attribute: [floating_ip, external_ip] }
232- calls :
233- - action : uname -a
305+ configure :
306+ implementation : scripts/vm_check.py
234307 relationships :
235- - target : floating_ip
308+ - target : qemu_vm
236309 type : cloudify.relationships.contained_in
310+
311+ groups :
312+
313+ vm_scale :
314+ members :
315+ - disk_clone
316+ - base_vm
317+ - floating_ip
318+ - cloud_init
319+ - qemu_vm
320+
321+ policies :
322+
323+ vm_scaling_policy :
324+ type : cloudify.policies.scaling
325+ properties :
326+ default_instances : 1
327+ targets : [vm_scale]
0 commit comments