Class: Ironfan::IaasProvider::Machine
- Inherits:
-
Resource
- Object
- Resource
- Ironfan::IaasProvider::Machine
- Defined in:
- lib/ironfan/headers.rb,
lib/ironfan/provider.rb
Direct Known Subclasses
Provider::Ec2::Machine, Provider::OpenStack::Machine, Provider::Rds::Machine, Provider::Static::Machine, Provider::VirtualBox::Machine, Provider::Vsphere::Machine
Class Method Summary collapse
-
.cloud_init_user_data(computer) ⇒ Object
FIXME: users_groups only in 7.4, not 6.3 …
-
.shared? ⇒ Boolean
A Machine lives and dies with its Computer.
Class Method Details
.cloud_init_user_data(computer) ⇒ Object
FIXME: users_groups only in 7.4, not 6.3 … including
this module breaks on our Ubuntu image (with cloud-init 6.3)
note that in the sed statement in the bootcmd below,
sed expects some characters to be escaped \(\) etc.
then yaml needs \ inside double-quotes escaped as \x5c
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/ironfan/provider.rb', line 221 def self.cloud_init_user_data(computer) return "#cloud-config\n# The line above is critical - without it cloud-init will not interpret the machine\n# user data as a cloud-init script.\n\n# The following logs everything cloud init does to /var/log\noutput: {all: '| tee -a /var/log/cloud-init-output.log'}\n\n# Set our hostname\nmanage_etc_hosts: True\n\nfqdn: \#{computer.server.fqdn}\n\ncloud_init_modules:\n - bootcmd\n - resizefs\n - set_hostname\n - update_hostname\n - update_etc_hosts\n - ca-certs\n - rsyslog\n - users-groups\n - ssh\n\nbootcmd:\n # note that writefiles is not supported on precise...\n - |\nmkdir -p /etc/chef\ntouch /etc/chef/client.pem\nchmod 600 /etc/chef/client.pem\nchown root:root /etc/chef/client.pem\ncat > /etc/chef/client.pem << EOF\n\#{computer.private_key.split(\"\\n\").map {|l| \" \"+l}.join(\"\\n\")}\n" domainname #{computer.server.fqdn} IP=`curl 169.254.169.254/latest/meta-data/local-ipv4` [ -f /etc/cloud/templates/hosts.tmpl ] && sed -i -e "s/127\x5c.0\x5c.1\x5c.1/$IP/" /etc/cloud/templates/hosts.tmpl [ -f /etc/cloud/templates/hosts.debian.tmpl ] && sed -i -e "s/127\x5c.0\x5c.1\x5c.1/$IP/" /etc/cloud/templates/hosts.debian.tmpl [ -f /etc/cloud/templates/hosts.redhat.tmpl ] && sed -i -e "/::1/d" -e "s/^[0-9]*\x5c.[0-9]*\x5c.[0-9]*\x5c.[0-9]*\x5c( .*fqdn.*\x5c)/$IP\x5c1/" /etc/cloud/templates/hosts.redhat.tmpl # This is understood to fail gracefully during image creation (before # knife cluster bootstrap burninator...) due to Chef not installed yet. chef: install_type: "packages" force_install: false server_url: #{Chef::Config[:chef_server_url]} node_name: #{computer.name} initial_attributes: chef_server: #{Chef::Config[:chef_server_url]} node_name: #{computer.name} organization: #{Chef::Config[:organization]} realm_name: #{computer.server.realm_name} cluster_name: #{computer.server.cluster_name} facet_name: #{computer.server.facet_name} facet_index: #{computer.server.index} validation_name: "no-validator" validation_key: | We don't need no stinking validators. EOF end |
.shared? ⇒ Boolean
A Machine lives and dies with its Computer
214 |
# File 'lib/ironfan/provider.rb', line 214 def self.shared?() false; end |