#cloud-config
<%#
kind: provision
name: CoreOS provision
oses:
- CoreOS
%>
coreos:
  units:
    - name: coreos-bootstrap.service
      runtime: no
      command: start
      content: |
        [Unit]
        Description=Install coreos to disk
        [Service]
        ExecStart=/bin/bash -c "/usr/bin/coreos-install -C  <%= @host.operatingsystem.release_name %> -d <%= @host.params['install-disk'] || '/dev/sda' %> -c /home/core/cloud-config.yml <% if @host.operatingsystem.major >= "557" -%>-b <%= @mediapath %><% end -%>  && wget -q -O /dev/null --no-check-certificate <%= foreman_url %> && 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 %>"
<% 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
