|
#cloud-config
|
|
<%#
|
|
kind: snippet
|
|
name: coreos_cloudconfig
|
|
%>
|
|
coreos:
|
|
etcd2:
|
|
<% if @host.params['etcd_discovery_url'] -%>
|
|
discovery: <%= @host.params['etcd_discovery_url'] %>
|
|
<% end -%>
|
|
advertise-client-urls: http://<%= @host.ip %>:2379
|
|
initial-advertise-peer-urls: http://<%= @host.ip %>:2380
|
|
listen-client-urls: http://0.0.0.0:2379
|
|
listen-peer-urls: http://0.0.0.0:2380
|
|
units:
|
|
- name: etcd2.service
|
|
command: start
|
|
- name: fleet.service
|
|
command: start
|
|
<% if @host.param_true?('expose_docker_socket') -%>
|
|
- name: docker-tcp.socket
|
|
command: start
|
|
enable: yes
|
|
content: |
|
|
[Unit]
|
|
Description=Docker Socket for the API
|
|
|
|
[Socket]
|
|
ListenStream=2375
|
|
BindIPv6Only=both
|
|
Service=docker.service
|
|
|
|
[Install]
|
|
WantedBy=sockets.target
|
|
- name: enable-docker-tcp.service
|
|
command: start
|
|
content: |
|
|
[Unit]
|
|
Description=Enable the Docker Socket for the API
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
ExecStart=/usr/bin/systemctl enable docker-tcp.socket
|
|
<% end -%>
|
|
<% if @host.subnet.respond_to?(:dhcp_boot_mode?) -%>
|
|
<% dhcp = @host.subnet.dhcp_boot_mode? && !@static -%>
|
|
<% else -%>
|
|
<% dhcp = !@static -%>
|
|
<% end -%>
|
|
<% unless dhcp -%>
|
|
- name: systemd-networkd.service
|
|
command: stop
|
|
- name: static.network
|
|
command: start
|
|
content: |
|
|
[Match]
|
|
MACAddress=<%= @host.mac %>
|
|
[Network]
|
|
<% if !@host.subnet.gateway.nil? && !@host.subnet.gateway.empty? -%>
|
|
Gateway=<%= @host.subnet.gateway %>
|
|
<% end -%>
|
|
Address=<%= @host.ip %>/<%= @host.subnet.cidr %>
|
|
<% if !@host.subnet.dns_primary.nil? && !@host.subnet.dns_primary.empty? -%>
|
|
DNS=<%= @host.subnet.dns_primary %>
|
|
<% end -%>
|
|
<% if !@host.subnet.dns_secondary.nil? && !@host.subnet.dns_secondary.empty? -%>
|
|
DNS=<%= @host.subnet.dns_secondary %>
|
|
<% end -%>
|
|
- name: down-interfaces.service
|
|
command: start
|
|
content: |
|
|
[Service]
|
|
Type=oneshot
|
|
ExecStart=/usr/bin/bash -c 'for i in $(/usr/bin/ls /sys/class/net/); do [ $i == "lo" ] || (/usr/bin/ip link set $i down; /usr/bin/ip addr flush dev $i); done'
|
|
- name: systemd-networkd.service
|
|
command: restart
|
|
<% end -%>
|
|
<% if @host.params['ssh_authorized_keys'] -%>
|
|
ssh_authorized_keys:
|
|
<% @host.params['ssh_authorized_keys'].split(',').map(&:strip).each do |ssh_key| -%>
|
|
- "<%= ssh_key %>"
|
|
<% end -%>
|
|
<% else -%>
|
|
users:
|
|
- name: core
|
|
passwd: <%= root_pass %>
|
|
<% end -%>
|