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 <<EOF
#cloud-config
# The line above is critical - without it cloud-init will not interpret the machine
# user data as a cloud-init script.
# The following logs everything cloud init does to /var/log
output: {all: '| tee -a /var/log/cloud-init-output.log'}
# Set our hostname
manage_etc_hosts: True
fqdn: #{computer.server.fqdn}
cloud_init_modules:
- bootcmd
- resizefs
- set_hostname
- update_hostname
- update_etc_hosts
- ca-certs
- rsyslog
- users-groups
- ssh
bootcmd:
# note that writefiles is not supported on precise...
- |
mkdir -p /etc/chef
touch /etc/chef/client.pem
chmod 600 /etc/chef/client.pem
chown root:root /etc/chef/client.pem
cat > /etc/chef/client.pem << EOF
#{computer.private_key.split("\n").map {|l| " "+l}.join("\n")}
EOF
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 |