@@ -10,31 +10,56 @@ imports:
1010 - https://raw.githubusercontent.com/cloudify-incubator/cloudify-libvirt-plugin/0.5.0/plugin.yaml
1111
1212inputs :
13+ # agent settings
14+ agent_user :
15+ default : { get_secret: agent_user }
1316
17+ # you should use such key for kvm host
18+ agent_public_key :
19+ default : { get_secret: agent_key_public }
20+
21+ disk_size :
22+ default : 24GB
23+
24+ agent_private_key :
25+ default : { get_secret: agent_private_key }
26+
27+ # cluster(kvm) settings
1428 cluster_user :
1529 type : string
1630 description : >
1731 Cluster user name.
32+ default : { get_secret: libvirt_cluster_user }
1833
1934 cluster_key :
2035 type : string
2136 description : >
2237 SSH key for cluster user.
38+ default : { get_secret: libvirt_cluster_key }
39+
40+ manager_network :
41+ type : string
42+ description : >
43+ Manager network.
44+ default : { get_secret: libvirt_common_network }
2345
2446 cluster_host :
2547 type : string
2648 description : >
2749 LibVirt computer ip address.
50+ default : { get_secret: libvirt_cluster_host }
2851
2952 external_ip :
3053 type : string
3154 description : >
3255 List external ip's separated by comma.
56+ default : { get_secret: libvirt_cluster_external_ip }
3357
3458 external_dev :
3559 type : string
3660 description : >
3761 Device with external access (same device as used for cluster_host ip)
62+ default : { get_secret: libvirt_cluster_external_dev }
3863
3964relationships :
4065
@@ -47,9 +72,17 @@ relationships:
4772 executor : central_deployment_agent
4873 inputs : {}
4974
75+ node_types :
76+
77+ agent_domain :
78+ derived_from : cloudify.nodes.Compute
79+ properties :
80+ use_public_ip :
81+ default : false
82+
5083node_templates :
5184
52- libvirt_install :
85+ vm_download :
5386 type : cloudify.nodes.WebServer
5487 interfaces :
5588 cloudify.interfaces.lifecycle :
@@ -65,14 +98,21 @@ node_templates:
6598 implementation : fabric.fabric_plugin.tasks.run_script
6699 inputs :
67100 fabric_env : *fab_env
68- script_path : cluster /download_vm.sh
69- CATALOG_URL : https://buildlogs .centos.org/centos/7/isos/x86_64
70- DISK : CentOS-7-x86_64-GenericCloud-ContainerHost .qcow2
101+ 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
71104
72105 common_network :
73106 type : cloudify.libvirt.network
74107 properties :
75- libvirt_auth : {concat:["qemu+ssh://", { get_input: cluster_user }, "@", { get_input: cluster_host }, "/system?sshauth=privkey&keyfile=", { get_input: cluster_key }]}
108+ libvirt_auth : &libvirt_auth
109+ concat :
110+ - " qemu+ssh://"
111+ - { get_input: cluster_user }
112+ - " @"
113+ - { get_input: cluster_host }
114+ - " /system?sshauth=privkey&keyfile="
115+ - { get_input: cluster_key }
76116 interfaces :
77117 cloudify.interfaces.lifecycle :
78118 create :
@@ -82,38 +122,62 @@ node_templates:
82122 forwards :
83123 - mode : nat
84124 ips :
85- - address : 192.168.142 .1
125+ - address : 192.168.141 .1
86126 netmask : 255.255.255.0
87127 dhcp :
88- start : 192.168.142 .2
89- end : 192.168.142 .254
128+ start : 192.168.141 .2
129+ end : 192.168.141 .254
90130 relationships :
91- - target : libvirt_install
131+ - target : vm_download
92132 type : cloudify.relationships.depends_on
93133
134+ cloud_init :
135+ type : cloudify.nodes.CloudInit.CloudConfig
136+ properties :
137+ resource_config :
138+ groups :
139+ - { get_input: agent_user }
140+ users :
141+ - name : { get_input: agent_user }
142+ # group with same name as username required for agent running
143+ primary_group : { get_input: agent_user }
144+ groups : wheel
145+ shell : /bin/bash
146+ sudo : ['ALL=(ALL) NOPASSWD:ALL']
147+ ssh-authorized-keys :
148+ - { get_input: agent_public_key }
149+
94150 disk_clone :
95151 type : cloudify.nodes.ApplicationServer
96152 interfaces :
97153 cloudify.interfaces.lifecycle :
98154 create :
155+ implementation : scripts/disk_prepere.py
156+ executor : central_deployment_agent
157+ inputs :
158+ disk_image : { get_attribute: [vm_download, vm_image] }
159+ cloud_init : { get_attribute: [cloud_init, cloud_config ] }
160+ disk_size : { get_input: disk_size }
161+ configure :
99162 implementation : fabric.fabric_plugin.tasks.run_script
100163 inputs :
101164 fabric_env : *fab_env
102- DISK : { get_attribute: [libvirt_install, vm_image] }
103- script_path : cluster/copy_disk.sh
165+ script_path : scripts/copy_disk.py
104166 delete :
105167 implementation : fabric.fabric_plugin.tasks.run_script
106168 inputs :
107169 fabric_env : *fab_env
108170 script_path : scripts/remove_disk.sh
109171 relationships :
110- - target : libvirt_install
172+ - target : vm_download
173+ type : cloudify.relationships.depends_on
174+ - target : cloud_init
111175 type : cloudify.relationships.depends_on
112176
113- qemu_vm :
177+ base_vm :
114178 type : cloudify.libvirt.domain
115179 properties :
116- libvirt_auth : {concat:["qemu+ssh://", { get_input: cluster_user }, "@", { get_input: cluster_host }, "/system?sshauth=privkey&keyfile=", { get_input: cluster_key }]}
180+ libvirt_auth : *libvirt_auth
117181 agent_config :
118182 install_method : none
119183 interfaces :
@@ -123,6 +187,7 @@ node_templates:
123187 params :
124188 vcpu : 2
125189 memory_size : 1048576
190+ domain_type : kvm
126191 networks :
127192 - network : { get_attribute: [common_network, resource_id] }
128193 dev : vnet0
@@ -133,7 +198,7 @@ node_templates:
133198 type : vm_connected_to_storage
134199
135200 floating_ip :
136- type : cloudify.nodes.ApplicationServer
201+ type : cloudify.nodes.VirtualIP
137202 interfaces :
138203 cloudify.interfaces.lifecycle :
139204 create :
@@ -142,16 +207,16 @@ node_templates:
142207 fabric_env : *fab_env
143208 EXTERNAL_INTERFACE : { get_input: external_dev }
144209 EXTERNAL_IP : { get_input: external_ip }
145- INTERNAL_IP : { get_attribute: [qemu_vm , ip] }
210+ INTERNAL_IP : { get_attribute: [base_vm , ip] }
146211 script_path : cluster/floating_ip.py
147212 delete :
148213 implementation : fabric.fabric_plugin.tasks.run_script
149214 inputs :
150215 fabric_env : *fab_env
151216 script_path : cluster/floating_ip_delete.py
152217 relationships :
153- - target : qemu_vm
154- type : cloudify.relationships.depends_on
218+ - target : base_vm
219+ type : cloudify.relationships.connected_to
155220
156221 example_node :
157222 type : cloudify.nodes.WebServer
@@ -161,8 +226,8 @@ node_templates:
161226 implementation : terminal.cloudify_terminal.tasks.run
162227 inputs :
163228 terminal_auth :
164- user : centos
165- password : passw0rd
229+ user : { get_input: agent_user }
230+ key_content : { get_input: agent_private_key }
166231 ip : { get_attribute: [floating_ip, external_ip] }
167232 calls :
168233 - action : uname -a
0 commit comments