~cloud-init-dev/cloud-init/trunk

« back to all changes in this revision

Viewing changes to doc/sources/azure/README.rst

  • Committer: Scott Moser
  • Date: 2016-08-10 15:06:15 UTC
  • Revision ID: smoser@ubuntu.com-20160810150615-ma2fv107w3suy1ma
README: Mention move of revision control to git.

cloud-init development has moved its revision control to git.
It is available at 
  https://code.launchpad.net/cloud-init

Clone with 
  git clone https://git.launchpad.net/cloud-init
or
  git clone git+ssh://git.launchpad.net/cloud-init

For more information see
  https://git.launchpad.net/cloud-init/tree/HACKING.rst

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
================
2
 
Azure Datasource
3
 
================
4
 
 
5
 
This datasource finds metadata and user-data from the Azure cloud platform.
6
 
 
7
 
Azure Platform
8
 
--------------
9
 
The azure cloud-platform provides initial data to an instance via an attached
10
 
CD formated in UDF.  That CD contains a 'ovf-env.xml' file that provides some
11
 
information.  Additional information is obtained via interaction with the
12
 
"endpoint".  The ip address of the endpoint is advertised to the instance
13
 
inside of dhcp option 245.  On ubuntu, that can be seen in
14
 
/var/lib/dhcp/dhclient.eth0.leases as a colon delimited hex value (example:
15
 
``option unknown-245 64:41:60:82;`` is 100.65.96.130)
16
 
 
17
 
walinuxagent
18
 
------------
19
 
In order to operate correctly, cloud-init needs walinuxagent to provide much
20
 
of the interaction with azure.  In addition to "provisioning" code, walinux
21
 
does the following on the agent is a long running daemon that handles the
22
 
following things:
23
 
- generate a x509 certificate and send that to the endpoint
24
 
 
25
 
waagent.conf config
26
 
~~~~~~~~~~~~~~~~~~~
27
 
in order to use waagent.conf with cloud-init, the following settings are recommended.  Other values can be changed or set to the defaults.
28
 
 
29
 
  ::
30
 
 
31
 
   # disabling provisioning turns off all 'Provisioning.*' function
32
 
   Provisioning.Enabled=n
33
 
   # this is currently not handled by cloud-init, so let walinuxagent do it.
34
 
   ResourceDisk.Format=y
35
 
   ResourceDisk.MountPoint=/mnt
36
 
 
37
 
 
38
 
Userdata
39
 
--------
40
 
Userdata is provided to cloud-init inside the ovf-env.xml file. Cloud-init
41
 
expects that user-data will be provided as base64 encoded value inside the
42
 
text child of a element named ``UserData`` or ``CustomData`` which is a direct
43
 
child of the ``LinuxProvisioningConfigurationSet`` (a sibling to ``UserName``)
44
 
If both ``UserData`` and ``CustomData`` are provided behavior is undefined on
45
 
which will be selected.
46
 
 
47
 
In the example below, user-data provided is 'this is my userdata', and the
48
 
datasource config provided is ``{"agent_command": ["start", "walinuxagent"]}``.
49
 
That agent command will take affect as if it were specified in system config.
50
 
 
51
 
Example:
52
 
 
53
 
.. code::
54
 
 
55
 
 <wa:ProvisioningSection>
56
 
  <wa:Version>1.0</wa:Version>
57
 
  <LinuxProvisioningConfigurationSet
58
 
     xmlns="http://schemas.microsoft.com/windowsazure"
59
 
     xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
60
 
   <ConfigurationSetType>LinuxProvisioningConfiguration</ConfigurationSetType>
61
 
   <HostName>myHost</HostName>
62
 
   <UserName>myuser</UserName>
63
 
   <UserPassword/>
64
 
   <CustomData>dGhpcyBpcyBteSB1c2VyZGF0YQ===</CustomData>
65
 
   <dscfg>eyJhZ2VudF9jb21tYW5kIjogWyJzdGFydCIsICJ3YWxpbnV4YWdlbnQiXX0=</dscfg>
66
 
   <DisableSshPasswordAuthentication>true</DisableSshPasswordAuthentication>
67
 
   <SSH>
68
 
    <PublicKeys>
69
 
     <PublicKey>
70
 
      <Fingerprint>6BE7A7C3C8A8F4B123CCA5D0C2F1BE4CA7B63ED7</Fingerprint>
71
 
      <Path>this-value-unused</Path>
72
 
     </PublicKey>
73
 
    </PublicKeys>
74
 
   </SSH>
75
 
   </LinuxProvisioningConfigurationSet>
76
 
 </wa:ProvisioningSection>
77
 
 
78
 
Configuration
79
 
-------------
80
 
Configuration for the datasource can be read from the system config's or set
81
 
via the `dscfg` entry in the `LinuxProvisioningConfigurationSet`.  Content in
82
 
dscfg node is expected to be base64 encoded yaml content, and it will be
83
 
merged into the 'datasource: Azure' entry.
84
 
 
85
 
The '``hostname_bounce: command``' entry can be either the literal string
86
 
'builtin' or a command to execute.  The command will be invoked after the
87
 
hostname is set, and will have the 'interface' in its environment.  If
88
 
``set_hostname`` is not true, then ``hostname_bounce`` will be ignored.
89
 
 
90
 
An example might be:
91
 
  command:  ["sh", "-c", "killall dhclient; dhclient $interface"]
92
 
 
93
 
.. code::
94
 
 
95
 
  datasource:
96
 
   agent_command
97
 
   Azure:
98
 
    agent_command: [service, walinuxagent, start]
99
 
    set_hostname: True
100
 
    hostname_bounce:
101
 
     # the name of the interface to bounce
102
 
     interface: eth0
103
 
     # policy can be 'on', 'off' or 'force'
104
 
     policy: on
105
 
     # the method 'bounce' command.
106
 
     command: "builtin"
107
 
     hostname_command: "hostname"
108
 
    }
109
 
 
110
 
hostname
111
 
--------
112
 
When the user launches an instance, they provide a hostname for that instance.
113
 
The hostname is provided to the instance in the ovf-env.xml file as
114
 
``HostName``.
115
 
 
116
 
Whatever value the instance provides in its dhcp request will resolve in the
117
 
domain returned in the 'search' request.
118
 
 
119
 
The interesting issue is that a generic image will already have a hostname
120
 
configured.  The ubuntu cloud images have 'ubuntu' as the hostname of the
121
 
system, and the initial dhcp request on eth0 is not guaranteed to occur after
122
 
the datasource code has been run.  So, on first boot, that initial value will
123
 
be sent in the dhcp request and *that* value will resolve.
124
 
 
125
 
In order to make the ``HostName`` provided in the ovf-env.xml resolve, a
126
 
dhcp request must be made with the new value.  Walinuxagent (in its current
127
 
version) handles this by polling the state of hostname and bouncing ('``ifdown
128
 
eth0; ifup eth0``' the network interface if it sees that a change has been
129
 
made.
130
 
 
131
 
cloud-init handles this by setting the hostname in the DataSource's 'get_data'
132
 
method via '``hostname $HostName``', and then bouncing the interface.  This
133
 
behavior can be configured or disabled in the datasource config.  See
134
 
'Configuration' above.