3b14842c1f0419a5d0dffd5b73dd722a58916b49
[snaps.git] / docs / how-to-use / VirtEnvDeploy.rst
1 Try an example
2 ==============
3
4 Use launcher.py to deploy and clean up example environments.  These examples are described in YAML files.
5
6 #. Add your OpenStack connection information to the deploy-complex-network.yaml.
7
8     Edit <path to repo>/examples/complex-network/deploy-complex-network.yaml
9
10    -  openstack: the top level tag that denotes configuration for the OpenStack components
11
12    -  connection: - contains the credentials and endpoints required to
13       connect with OpenStack
14    -  username: - the project's user (required)
15    -  password: - the tentant's user password (required)
16    -  auth\_url: - the URL to the OpenStack APIs (required)
17    -  project\_name: - the name of the OpenStack project for the user
18       (required)
19    -  http\_proxy: - the {{ host }}:{{ port }} of the proxy server the
20       HTTPPhotoman01(optional)
21
22 #. Go to the examples directory.
23
24     ::
25
26       cd <snaps repo>/examples/
27
28 #. Deploy the launcher.
29
30     ::
31
32       python launch.py -t ./complex-network/deploy-complex-network.yaml -d
33
34 #. Clean the deployment.
35
36     ::
37
38       python launch.py -t ./complex-network/deploy-complex-network.yaml -c
39
40 #. Customize the deployment by changing the yaml file.
41
42     The configuration file used to deploy and provision a virtual environment has been designed to describe the required
43     images, networks, SSH public and private keys, associated VMs, as well as any required post deployment provisioning
44     tasks.
45
46 -  openstack: the top level tag that denotes configuration for the
47    OpenStack components
48
49    -  connections: the different connections/credentials to be used by the
50       launcher application
51
52        -  connection: the credentials and endpoints required to connect to an
53           OpenStack project/tenant
54
55           -  name: the name of the credentials for use when creating objects (required)
56           -  username: the project's user (required)
57           -  password: the tentant's user password (required)
58           -  auth\_url: the URL to the OpenStack APIs (required)
59           -  project\_name: the name of the OpenStack project for the user
60              (required)
61           -  identity\_api\_version: the Keystone client version to use (default = 2)
62           -  image\_api\_version: the Glance client version to use (default = 2)
63           -  network\_api\_version: the Neutron client version to use (default = 2)
64           -  compute\_api\_version: the Nova client version to use (default = 2)
65           -  heat\_api\_version: the Heat client version to use (default = 1)
66           -  volume\_api\_version: the Cinder client version to use (default = 2)
67           -  user\_domain\_id: the user domain ID to use (default = 'default')
68           -  user\_domain\_name: the user domain name to use (default = 'Default')
69           -  project\_domain\_id: the project domain ID to use (default = 'default')
70           -  project\_domain\_name: the project domain name to use (default = 'Default')
71           -  interface: Used to specify the endpoint type for keystone (default = 'public')
72           -  cacert: True for https or the certification file location (default = False)
73           -  region\_name: the region (default = None)
74           -  proxy\_settings: for accessing APIs hidden behind an HTTP proxy
75
76               - host: hostname or IP of HTTP proxy host (required)
77               - port: port number of the HTTP proxy server (required)
78               - http\_host: hostname or IP of HTTPS proxy host (default = host)
79               - port: port number of the HTTPS proxy server (default = port)
80               - ssh\_proxy\_cmd: the OpenSSH command used to access the SSH port
81                 of a VM (optional)
82
83    -  projects: the projects/tenants to create
84
85        -  project: a project/tenant to create (admin user credentials required)
86
87           -  os\_creds\_name: the connection name (default = 'default'
88              required or use "os\_user" below instead)
89           -  name: the project's name (required)
90           -  domain or domain_name: the project's domain name (default = 'Default')
91           -  description: the description (optional)
92           -  users: a list of users to associate to the project (optional)
93           -  enabled: when True the project will be enabled on creation (default = True)
94
95    -  users: the users to create
96
97        -  user: a user to create (admin user credentials required)
98
99           -  os\_creds\_name: the connection name (required)
100           -  name: the username (required)
101           -  password: the user's password (required)
102           -  project\_name: the user's primary project name (optional)
103           -  domain\_name: the user's domain name (default = 'Default')
104           -  email: the user's email address (optional)
105           -  roles: dict where key is the role's name and value is the name
106              of the project to associate with the role (optional)
107
108    -  flavors: the flavors to create
109
110        -  flavor: a flavor to create (admin user credentials required)
111
112           -  os\_creds\_name: the connection name (default = 'default'
113              required or use "os\_user" below instead)
114           -  name: the name (required)
115           -  flavor\_id: the string ID (default 'auto')
116           -  ram: the required RAM in MB (required)
117           -  disk: the size of the root disk in GB (required)
118           -  vcpus: the number of virtual CPUs (required)
119           -  ephemeral: the size of the ephemeral disk in GB (default 0)
120           -  swap: the size of the dedicated swap disk in GB (default 0)
121           -  rxtx\_factor: the receive/transmit factor to be set on ports if
122              backend supports QoS extension (default 1.0)
123           -  is\_public: denotes whether or not the flavor is public (default = True)
124           -  metadata: freeform dict() for special metadata (optional)
125
126    -  images: describes each image to create
127        -  image:
128
129           -  os\_creds\_name: the connection name (default = 'default'
130              required or use "os\_user" below instead)
131           -  os\_user: the connection from a new user defined in template
132              (required or use "os\_creds\_name" above
133
134               - name: the user's name (required)
135               - project\_name: the project name to use
136
137           -  name: The unique image name. If the name already exists for
138              your project, a new one will not be created (required)
139           -  image\_user: the image's default sudo user (required)
140           -  format or img\_format: the image format type (required i.e. qcow2)
141           -  url or download\_url: The HTTP download location of the image file
142              (required when "image_file" below has not been configured)
143           -  image\_file: the image file location (required when "url" has not
144              been configured)
145           -  kernel\_image\_settings: the settings for a kernel image (optional)
146           -  ramdisk\_image\_settings: the settings for a kernel image (optional)
147           -  public: publically visibile when True (default = True)
148
149    -  networks:
150        -  network:
151
152           -  os\_creds\_name: the connection name (default = 'default'
153              required or use "os\_user" below instead)
154           -  os\_user: the connection from a new user defined in template
155              (required or use "os\_creds\_name" above
156
157               - name: the user's name (required)
158               - project\_name: the project name to use
159
160           -  name: The name of the network to be created. If one already
161              exists, a new one will not be created (required)
162           -  admin\_state\_up: T\|F (default True)
163           -  shared: (optional)
164           -  project\_name: Name of the project who owns the network. Note:
165              only administrative users can specify projects other than their
166              own (optional)
167           -  external: T\|F whether or not network is external (default False)
168           -  network\_type: The type of network to create (optional)
169           -  physical\_network: the name of the physical network
170              (required when network_type is 'flat')
171           -  segmentation\_id: the id of the segmentation
172              (required when network_type is 'vlan')
173           -  subnets:
174               -  subnet:
175
176                  -  name: The name of the network to be created. If one already
177                     exists, a new one will not be created. Note: although
178                     OpenStack allows for multiple subnets to be applied to any
179                     given network, we have not included support as our current
180                     use cases does not utilize this functionality (required)
181                  -  cidr: The subnet mask value (required)
182                  -  dns\_nameservers: A list of IP values used for DNS
183                     resolution (default: 8.8.8.8)
184                  -  ip\_version: 4\|6 (default: 4)
185                  -  project\_name: Name of the project who owns the network.
186                     Note: only administrative users can specify projects other
187                     than their own (optional)
188                  -  start: The start address for allocation\_pools (optional)
189                  -  end: The ending address for allocation\_pools (optional)
190                  -  gateway\_ip: The IP address to the gateway (optional)
191                  -  enable\_dhcp: T\|F (optional)
192                  -  dns\_nameservers: List of DNS server IPs (default = ['8.8.8.8']
193                  -  host\_routes: A list of host route dictionaries (optional)
194                     i.e.:
195                     ``yaml    "host_routes":[    {    "destination":"0.0.0.0/0",    "nexthop":"123.456.78.9"    },    {    "destination":"192.168.0.0/24",    "nexthop":"192.168.0.1"    }    ]``
196                  -  destination: The destination for a static route (optional)
197                  -  nexthop: The next hop for the destination (optional)
198                  -  ipv6\_ra\_mode: Valid values: "dhcpv6-stateful",
199                     "dhcpv6-stateless", and "slaac" (optional)
200                  -  ipv6\_address\_mode: Valid values: "dhcpv6-stateful",
201                     "dhcpv6-stateless", and "slaac" (optional)
202
203    -  security_groups:
204
205       -  security_group:
206
207           -  os\_creds\_name: the connection name (default = 'default'
208              required or use "os\_user" below instead)
209           -  os\_user: the connection from a new user defined in template
210              (required or use "os\_creds\_name" above
211
212               - name: the user's name (required)
213               - project\_name: the project name to use
214
215           -  name: The name of the security group to be created (required)
216           -  description: The security group's description (optional)
217           -  project\_name: Name of the project who owns the security group (optional)
218           -  rule\_settings: List of rules to place onto security group (optional)
219
220               -  description: the rule's description (optional)
221               -  protocol: rule's protcol ('icmp' or 'tcp' or 'udp' or 'null')
222               -  ethertype: rule's ethertype ('4' or '6')
223               -  port\_range\_min: The minimum port number in the range that is
224                  matched by the security group rule. When the protocol is 'tcp'
225                  or 'udp', this value must be <= 'port_range_max' (optional)
226               -  port\_range\_max: The maximum port number in the range that is
227                  matched by the security group rule. When the protocol is 'tcp'
228                  or 'udp', this value must be <= 'port_range_max' (optional)
229               -  remote\_ip\_prefix: The remote IP prefix to associate with this
230                  metering rule packet (optional)
231
232    -  routers:
233
234       -  router:
235
236           -  os\_creds\_name: the connection name (default = 'default'
237              required or use "os\_user" below instead)
238           -  os\_user: the connection from a new user defined in template
239              (required or use "os\_creds\_name" above
240
241               - name: the user's name (required)
242               - project\_name: the project name to use
243
244           -  name: The name of the router to be created (required)
245           -  project\_name: Name of the project who owns the network (optional)
246           -  external\_gateway: Name of the external network to which to route
247              (optional)
248           -  admin\_state\_up: T\|F (default True)
249           -  external\_fixed\_ids: Dictionary containing the IP address
250              parameters (optional)
251           -  internal\_subnets: List of subnet names to which to connect this
252              router (optional)
253
254              -  port_settings (Leverages the same class/structure as port objects on
255                 VM instances. See port definition below for a
256                 full accounting of the port attributes. The ones listed
257                 below are generally used for routers)
258
259                 -  name: The name given to the new port (required and must be
260                    unique for project)
261                 -  network\_name: The name of the network on which to create
262                    the port (optional)
263                 -  admin\_state\_up: T\|F (default True)
264                 -  project\_name: Name of the project who owns the network (optional)
265                 -  mac\_address: The port's MAC address (optional)
266                 -  ip\_addrs: A list of k/v pairs (optional)
267                 -  security\_groups: a list of names of the the security groups
268                    to apply to the port
269                 -  opt\_value: The extra DHCP option value (optional)
270                 -  opt\_name: The extra DHCP option name (optional)
271
272    -  keypairs:
273
274       -  keypair:
275
276           -  os\_creds\_name: the connection name (default = 'default'
277              required or use "os\_user" below instead)
278           -  os\_user: the connection from a new user defined in template
279              (required or use "os\_creds\_name" above
280
281               - name: the user's name (required)
282               - project\_name: the project name to use
283
284           -  name: The name of the keypair to be created. If one already
285              exists, a new one will not be created but simply loaded from
286              its configured file location (required)
287           -  public\_filepath: The path to where the generated public key
288              will be stored if it does not exist (optional but really
289              required for provisioning purposes)
290           -  private\_filepath: The path to where the generated private key
291              will be stored if it does not exist (optional but really
292              required for provisioning purposes)
293
294    -  instances:
295
296       -  instance:
297
298           -  os\_creds\_name: the connection name (default = 'default'
299              required or use "os\_user" below instead)
300           -  os\_user: the connection from a new user defined in template
301              (required or use "os\_creds\_name" above
302
303               - name: the user's name (required)
304               - project\_name: the project name to use
305
306           -  name: The unique instance name for project. (required)
307           -  flavor: Must be one of the preconfigured flavors (required)
308           -  imageName: The name of the image to be used for deployment
309              (required)
310           -  keypair\_name: The name of the keypair to attach to instance
311              (optional but required for NIC configuration and Ansible
312              provisioning)
313           -  sudo\_user: The name of a sudo\_user that is attached to the
314              keypair (optional but required for NIC configuration and
315              Ansible provisioning)
316           -  vm\_boot\_timeout: The number of seconds to block waiting for
317              an instance to deploy and boot (default 900)
318           -  vm\_delete\_timeout: The number of seconds to block waiting for
319              an instance to be deleted (default 300)
320           -  ssh\_connect\_timeout: The number of seconds to block waiting
321              for an instance to achieve an SSH connection (default 120)
322           -  ports: A list of port configurations (should contain at least
323              one)
324           -  port: Denotes the configuration of a NIC
325
326              -  name: The unique port name for project (required)
327              -  network\_name: The name of the network to which the port is
328                 attached (required)
329              -  ip\_addrs: Static IP addresses to be added to the port by
330                 subnet (optional)
331              -  subnet\_name: The name of the subnet
332              -  ip: The assigned IP address (when null, OpenStack will
333                 assign an IP to the port)
334              -  admin\_state\_up: T\|F (default True)
335              -  project\_name: The name of the project who owns the network.
336                 Only administrative users can specify a the project ID other
337                 than their own (optional)
338              -  mac\_address: The desired MAC for the port (optional)
339              -  fixed\_ips: A dictionary that allows one to specify only a
340                 subnet ID, OpenStack Networking allocates an available IP
341                 from that subnet to the port. If you specify both a subnet
342                 ID and an IP address, OpenStack Networking tries to allocate
343                 the specified address to the port. (optional)
344              -  seurity\_groups: A list of security group IDs (optional)
345              -  allowed\_address\_pairs: A dictionary containing a set of
346                 zero or more allowed address pairs. An address pair contains
347                 an IP address and MAC address. (optional)
348              -  opt\_value: The extra DHCP option value (optional)
349              -  opt\_name: The extra DHCP option name (optional)
350              -  device\_owner: The ID of the entity that uses this port. For
351                 example, a DHCP agent (optional)
352              -  device\_id: The ID of the device that uses this port. For
353                 example, a virtual server (optional)
354
355        -  floating\_ips: list of floating\_ip configurations (optional)
356
357           -  floating\_ip:
358           -  name: Must be unique for VM instance (required)
359           -  port\_name: The name of the port requiring access to the
360              external network (required)
361           -  subnet\_name: The name of the subnet contains the IP address on
362              the port on which to create the floating IP (optional)
363           -  router\_name: The name of the router connected to an external
364              network used to attach the floating IP (required)
365           -  provisioning: (True\|False) Denotes whether or not this IP can
366              be used for Ansible provisioning (default True)
367
368 -  ansible: Each set of attributes below are contained in a list
369
370    -  playbook\_location: Full path or relative to the directory in
371       which the deployment file resides (required)
372    -  hosts: A list of hosts to which the playbook will be executed
373       (required)
374    -  variables: Should your Ansible scripts require any substitution
375       values to be applied with Jinga2templates, the values defined here
376       will be used to for substitution
377    -  tag name = substitution variable names. For instance, for any file
378       being pushed to the host being provisioned containing a value such
379       as {{ foo }}, you must specify a tag name of "foo"
380
381       -  vm\_name:
382       -  type: string\|port\|os\_creds\|vm-attr (note: will need to make
383          changes to deploy\_venv.py#\_\_get\_variable\_value() for
384          additional support)
385       -  when type == string, an tag name "value" must exist and its
386          value will be used for template substituion
387       -  when type == port, custom code has been written to extract
388          certain assigned values to the port:
389
390          -  vm\_name: must correspond to a VM's name as configured in
391             this file
392          -  port\_name: The name of the port from which to extract the
393             substitution values (required)
394          -  port\_value: The port value. Currently only supporting
395             "mac\_address" and "ip\_address" (only the first)
396
397       -  when type == os\_creds, custom code has been written to extract
398          the file's connection values:
399
400          -  username: connection's user
401          -  password: connection's password
402          -  auth\_url: connection's URL
403          -  project\_name: connection's project
404
405       -  when type == vm-attr, custom code has been written to extract
406          the following attributes from the vm:
407
408          -  vm\_name: must correspond to a VM's name as configured in
409             this file
410          -  value -> floating\_ip: is currently the only vm-attr
411             supported