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

Modifies Ubuntu 18.04 task. #436

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like the only line that has changed so far. Was the other method of stopping the postinstall script not working?

Copy link
Author

Choose a reason for hiding this comment

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

post install script was never called because ubuntu 18.04 uses systemd instead of init.

adding a line to the crontab works with systemd.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah excellent, that makes sense. Is there a reason this wouldn't work for other Ubuntu versions too? This might be a more portable way to be standard across versions.

Copy link
Author

Choose a reason for hiding this comment

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

I haven't tested this with other than ubuntu 18.04, this might work for newer version but not sure for older.


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") %>