Skip to content
This repository has been archived by the owner on Jul 9, 2020. It is now read-only.

WIP - Rework Container Linux (CoreOS) #389

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion provisioning_templates/PXELinux/coreos_pxelinux.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ DEFAULT coreos

LABEL coreos
KERNEL <%= @kernel %>
APPEND initrd=<%= @initrd %> cloud-config-url=<%= foreman_url('provision')%>
APPEND initrd=<%= @initrd %> coreos.config.url=<%= foreman_url('provision')%>
141 changes: 103 additions & 38 deletions provisioning_templates/provision/coreos_provision.erb
Original file line number Diff line number Diff line change
@@ -1,44 +1,109 @@
#cloud-config
<%#
kind: provision
name: CoreOS provision
oses:
- CoreOS
kind: snippet
name: coreos_cloudconfig
%>
<%
os_major = @host.operatingsystem.major.to_i
%>
coreos:
units:
- name: coreos-bootstrap.service
runtime: no
command: start
content: |
[Unit]
Description=Install coreos to disk
[Service]
Type=oneshot
ExecStart=/usr/bin/coreos-install \
-C <%= @host.operatingsystem.release_name %> \
-d <%= @host.params['install-disk'] || '/dev/sda' %> \
-c /home/core/cloud-config.yml <% if os_major >= 557 -%>-b <%= @mediapath %><% end %>
ExecStartPost=/usr/bin/wget -q -O /dev/null --no-check-certificate <%= foreman_url('built') %>
ExecStartPost=/usr/sbin/reboot
[X-Fleet]
X-Conflicts=coreos-bootstrap.service
<% if @host.params['ssh_authorized_keys'] -%>
ssh_authorized_keys:
<% @host.params['ssh_authorized_keys'].split(',').map(&:strip).each do |ssh_key| -%>
- "<%= ssh_key %>"
units = 0
unless @host.param_false?('enable_etcd')
units += 1
end
if @host.param_true?('expose_docker_socket')
units += 1
end
if @host.subnet.respond_to?(:dhcp_boot_mode?)
dhcp = @host.subnet.dhcp_boot_mode? && !@static
else
dhcp = !@static
end
unless dhcp
units += 1
end
-%>
<% if units > 0 -%>
coreos:
<% if @host.params['reboot-strategy'] -%>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace all @host.params with host_param() as in #484

update:
reboot-strategy: <%= @host.params['reboot-strategy'] %>
<% end -%>
<% unless @host.param_false?('enable_etcd') -%>
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
<% end -%>
units:
<% unless @host.param_false?('enable_etcd') -%>
- name: etcd2.service
command: start
- name: fleet.service
command: start
<% end -%>
<% 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 -%>
<% unless dhcp -%>
- name: systemd-networkd.service
command: stop
- name: static.network
command: start
content: |
[Match]
MACAddress=<%= @host.mac %>
[Network]
<% if @host.subnet.present? -%>
Gateway=<%= @host.subnet.gateway %>
<% end -%>
Address=<%= @host.ip %>/<%= @host.subnet.cidr %>
<% if @host.subnet.dns_primary.present? -%>
DNS=<%= @host.subnet.dns_primary %>
<% end -%>
<% if @host.subnet.dns_secondary.present? -%>
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 -%>
<% 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 -%>
write_files:
- content: |
<%= snippet 'coreos_cloudconfig' %>
path: /home/core/cloud-config.yml
permissions: '0600'
owner: core:core
users:
- name: core
passwd: <%= root_pass %>
<% end -%>
109 changes: 0 additions & 109 deletions provisioning_templates/snippet/coreos_cloudconfig.erb

This file was deleted.