Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Commit

Permalink
Modifies Ubuntu 18.04 task to enable node registration.
Browse files Browse the repository at this point in the history
* Modifies stages to get the ubuntu 18.04 nodes
to register.
* Changes startup method after first boot to use cron.

fix for PR based on comments
  • Loading branch information
rngkll committed Sep 18, 2019
1 parent fce5105 commit 294a756
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tasks/ubuntu/bionic.task/os_complete.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

echo Razor policy successfully applied > /tmp/razor_complete.log
echo Installed using <%= task.label %> - <%= task.description %> >> /tmp/razor_complete.log
echo Repo: <%= repo_url %> >> /tmp/razor_complete.log
echo Node: <%= node_url %> >> /tmp/razor_complete.log

sed -i '/razor_postinstall/d' /etc/crontab

curl -s <%= broker_install_url %> | bash
if [ $? -ne 0 ]; then
echo "Broker run failed; see /var/log/razor.log for more details" >> /tmp/razor_complete.log
else
echo Ran '<%= broker_install_url %>' >> /tmp/razor_complete.log
fi
56 changes: 56 additions & 0 deletions tasks/ubuntu/bionic.task/preseed.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string us
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string <%= node.metadata['hostname'] || node.hostname %>
d-i netcfg/get_domain string <%= (node.metadata['hostname'] || node.hostname).split('.').drop(1).join('.') %>
d-i netcfg/no_default_route boolean true
# This is introduced in Trusty.
d-i live-installer/net-image string <%= repo_url("install/filesystem.squashfs") %>
d-i mirror/protocol string <%= repo_uri.scheme %>
d-i mirror/country string manual
d-i mirror/http/hostname string <%= "#{repo_uri.host}:#{repo_uri.port}" %>
d-i mirror/http/directory string <%= repo_uri.path %>
d-i clock-setup/utc boolean true
d-i time/zone string <%= node.metadata['timezone'] || 'US/Pacific' %>
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string ntp.ubuntu.com
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string lvm
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-auto/choose_recipe select atomic
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman/default_filesystem string ext4
d-i partman-auto/init_automatically_partition select biggest_free
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman-md/confirm boolean true
d-i passwd/root-login boolean true
d-i passwd/make-user boolean true
d-i passwd/root-password password <%= node.metadata['root_password'] || node.root_password %>
d-i passwd/root-password-again password <%= node.metadata['root_password'] || node.root_password %>
d-i passwd/user-fullname string Ubuntu User
d-i passwd/username string ubuntu
d-i passwd/user-password password insecure
d-i passwd/user-password-again password insecure
d-i user-setup/allow-password-weak boolean true
d-i apt-setup/restricted boolean true
d-i pkgsel/include string curl openssh-server
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i finish-install/reboot_in_progress note
# Uncomment this for `nomodeset`.
# d-i debian-installer/add-kernel-opts string nomodeset
# Our callbacks
d-i preseed/early_command string wget <%= log_url("preseed start") %>
d-i preseed/late_command string wget <%= log_url("preseed end") %>; \
wget <%= file_url("os_boot") %> -O /target/usr/local/sbin/razor_postinstall.sh; \
printf %b '@reboot root (sleep 90; /bin/bash /usr/local/sbin/razor_postinstall.sh)\n' >> /target/etc/crontab; \
chmod +x /target/usr/local/sbin/razor_postinstall.sh; \
wget <%= stage_done_url("preseed") %>

10 changes: 10 additions & 0 deletions tasks/ubuntu/bionic.task/store_ip.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%# -*- shell-script -*- %>
# Get current IP
node_ip=$(ip addr show | grep -A 2 BROADCAST | grep inet | awk '{ print $2 }' | awk -F'/' '{print $1}')
echo IP is $node_ip

# Send IP up
curl -s <%= store_url("ip" => "$node_ip") %>

# Send final state
curl -s <%= stage_done_url("store_ip") %>

0 comments on commit 294a756

Please sign in to comment.