Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions roles/dhcp-server/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
- name: restart networking
command: "/bin/systemctl restart networking.service"
ignore_errors: yes

- name: restart dnsmasq
command: "/bin/systemctl restart dnsmasq.service"
Expand Down
2 changes: 2 additions & 0 deletions roles/dhcp-server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
dest: /etc/network/interfaces
when: use_static_ip
notify: restart networking
ignore_errors: yes

- name: configure network interfaces (dhcp)
template:
src: templates/interfaces-dhcp.j2
dest: /etc/network/interfaces
when: not use_static_ip
notify: restart networking
ignore_errors: yes

- name: ensure network-manager doesn't run its own dnsmasq
lineinfile:
Expand Down
3 changes: 3 additions & 0 deletions roles/dhcp-server/templates/local.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ dhcp-boot=pxelinux.0
dhcp-authoritative
enable-tftp
tftp-root=/srv/tftp
no-hosts
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we're using our static hosts stuff, then we'll probably want to serve those over DNS too. wouldn't we?

Copy link
Owner Author

Choose a reason for hiding this comment

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

that's a bit of a contradiction. or redundancy. it is either addressing a case that will never exist, or addressing the case where things are broken. If /etc/hosts is in place, then we don't need dns.

however, even with static, dns can serve everything by putting a 2nd almost copy of the data in a file. almost = different IP for $server

I like putting the name:IP data in it's own file that is just for the dns, not also /etc/hosts.

Mainly because of waning $server:IP to be defined as something other than 127.0.1.1 like it is in /etc/hosts.

Copy link
Collaborator

Choose a reason for hiding this comment

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

or redundancy

That. You saw how it was useful at LCA, when we didn't have a global network, yet. Things still worked inside rooms. And we could ssh into things by hostname, because there was DNS with this stuff in it.

however, even with static, dns can serve everything by putting a 2nd almost copy of the data in a file. almost = different IP for $server

Sure. But we can just solve all of this by changing the server's IP in its own /etc/hosts.

Copy link
Owner Author

Choose a reason for hiding this comment

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

changing the server's IP in its own /etc/hosts

I went down that path and got angry :p

d-i builds this:
juser@dc10b:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 dc10b

is ...1.1 needed?

I made a task using lineinfile but my code kept adding additional "ip \t host" lines each time I re-ran. so I switched to not using etc/hosts and using a separate file for dnsmasq and was happy.

I have mixed feelings about dnsmasq using etc/hosts.

give me the ansible to just solve all of this and I'll give it a whirl

Copy link
Owner Author

Choose a reason for hiding this comment

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

dns can serve everything ...
Let's do that.

This only effects the dhcp server. it separates the dns config from the servers etc/hosts, andI am ok with that.

replacing "127.0.1.1 dc10b" is too hard for me, and I don't see much benefit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't like this change, I find it useful to be able to ssh into machines by hostname, on the video network.

host-record={{ inventory_hostname }},{{ eth_local_ip_address }}
host-record={{ inventory_hostname }}.{{ domain }},{{ eth_local_ip_address }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the point of having the machine return itself in DNS, but nothing else?

1 change: 1 addition & 0 deletions roles/system-software/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: restart systemd-journald
command: systemctl restart systemd-journald
when: ansible_env.ANSIBLE_UNDER_DI is undefined
6 changes: 6 additions & 0 deletions roles/tftp-server/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ apt_proxy: false
# Defaults to deb.debian.org | archive.ubuntu.com
#mirror: deb.debian.org

web_root: /var/www/html

user_name: videoteam
# Defaults to not setting a password
#user_password_crypted: changeme
Expand All @@ -19,3 +21,7 @@ playbook_branch: master
# To replace the stock inventory with your own, point at your own github repo
#inventory_repo: https://gitlab.com/yourname/ansible-inventory
#inventory_branch: master

# What Distro to install?
# Debian or Ubuntu
distro: Debian
38 changes: 38 additions & 0 deletions roles/tftp-server/files/late_command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh

set -eufx

# This script setups ansible and runs it
# It should be ran at the end of the basic installation of a machine

# apt install -y software-properties-common
# apt-add-repository --yes --update "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main"
# apt-add-repository --yes --update ppa:ansible/ansible

apt install -y ansible git eatmydata

# We clone our ansible repository and copy the ansible config files

# git clone https://anonscm.debian.org/git/debconf-video/ansible.git /root/debconf-ansible
git clone https://github.com/CarlFK/video-stack-deploy.git /root/debconf-ansible
Copy link
Collaborator

Choose a reason for hiding this comment

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

This, and many other things in this file, should be templated.

cd /root/debconf-ansible
git checkout pxe-toucheup
cd -

git clone https://github.com/xfxf/av-foss-stack.git /root/lca2017-av

ln -s /root/lca2017-av/inventory/ansible-up.sh /usr/local/sbin/ansible-up

# not sure why sometimes this is only needed when I run from a prompt in the installer shell,
# but the istaller doesn't. or something. I'm not sure when it is needed.
mkdir /dev/shm
echo "none /dev/shm tmpfs rw,nosuid,nodev,noexec,noauto 0 0" >> /etc/fstab
mount /dev/shm

# Aaaand we run ansible
eatmydata ansible-playbook \
-vvvv \
--connection=local \
--limit=$(hostname) \
--inventory-file=/root/lca2017-av/inventory/hosts \
/root/debconf-ansible/site.yml
14 changes: 10 additions & 4 deletions roles/tftp-server/tasks/d-i.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,27 @@
- name: inject preseed into menu (do injection)
lineinfile:
dest: "{{ item.path }}"
regexp: (\s+append\s+.*\s+initrd=\S+)\s+(?!auto=true)(.*)
regexp: (\s+append vga=.*\s+initrd=\S+)\s+(?!auto=true)(.*)
backrefs: true
line: \1 auto=true interface=auto url={{ inventory_hostname }} \2
line: \1 auto=true interface=auto url={{ inventory_hostname }} DEBCONF_DEBUG=5 partman-auto/disk="/dev/sda" \2
with_items: "{{ menus.files }}"

- name: create d-i directory
file:
path: /srv/pxe/d-i/{{ debian_version }}
path: /srv/pxe/d-i/{{ item }}
state: directory
recurse: true
with_items:
- stretch
- xenial

- name: write preseed.cfg
template:
src: preseed.cfg.j2
dest: /srv/pxe/d-i/{{ debian_version }}/preseed.cfg
dest: /srv/pxe/d-i/{{ item }}/preseed.cfg
with_items:
- stretch
- xenial

- name: generate late_command.sh
template:
Expand Down
35 changes: 18 additions & 17 deletions roles/tftp-server/templates/preseed.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ d-i debian-installer/locale string en_US
#d-i localechooser/supported-locales multiselect en_US.UTF-8, nl_NL.UTF-8

# Keyboard selection.
{% if ansible_distribution == 'Debian' %}
{% if distro == 'Debian' %}
d-i keyboard-configuration/xkb-keymap select us
{% elif ansible_distribution == 'Ubuntu' %}
{% elif distro == 'Ubuntu' %}
d-i keyboard-configuration/layoutcode string us
{% endif %}
# d-i keyboard-configuration/toggle select No toggling
Expand Down Expand Up @@ -102,10 +102,10 @@ d-i netcfg/wireless_wep string
# If you select ftp, the mirror/country string does not need to be set.
#d-i mirror/protocol string ftp
d-i mirror/country string manual
{% if ansible_distribution == 'Debian' %}
{% if distro == 'Debian' %}
d-i mirror/http/hostname string {{ mirror | default('deb.debian.org') }}
d-i mirror/http/directory string /debian
{% elif ansible_distribution == 'Ubuntu' %}
{% elif distro == 'Ubuntu' %}
d-i mirror/http/hostname string {{ mirror | default('archive.ubuntu.com') }}
d-i mirror/http/directory string /ubuntu
{% endif %}
Expand All @@ -132,7 +132,7 @@ d-i passwd/username string {{ user_name }}
{% if user_password_crypted is defined %}
d-i passwd/user-password-crypted password {{ user_password_crypted }}
{% endif %}
{% if ansible_distribution == 'Ubuntu' %}
{% if distro == 'Ubuntu' %}
# Ubuntu offers encrypted home directories
d-i user-setup/encrypt-home boolean false
{% endif %}
Expand Down Expand Up @@ -165,7 +165,7 @@ d-i clock-setup/ntp boolean true
# name must be given in traditional, non-devfs format (so e.g. /dev/hda or
# /dev/sda, and not e.g. /dev/discs/disc0/disc).
# For example, to use the first SCSI/SATA hard disk:
d-i partman-auto/disk string /dev/sda
# d-i partman-auto/disk string /dev/sda
# In addition, you'll need to specify the method to use.
# The presently available methods are:
# - regular: use the usual partition types for your architecture
Expand All @@ -183,7 +183,7 @@ d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true

{% if ansible_distribution == 'Ubuntu' %}
{% if distro == 'Ubuntu' %}
# Use all the space on LVM
d-i partman-auto-lvm/guided_size string max
{% endif %}
Expand Down Expand Up @@ -239,7 +239,7 @@ d-i partman/confirm_nooverwrite boolean true
# so this will only work if the disks are the same size.
#d-i partman-auto/disk string /dev/sda /dev/sdb

# Next you need to specify the physical partitions that will be used.
# Next you need to specify the physical partitions that will be used.
#d-i partman-auto/expert_recipe string \
# multiraid :: \
# 1000 5000 4000 raid \
Expand Down Expand Up @@ -309,10 +309,6 @@ d-i apt-setup/contrib boolean true
#d-i apt-setup/services-select multiselect security, updates
#d-i apt-setup/security_host string security.debian.org

{% if ansible_distribution == 'Ubuntu' %}
d-i pkgsel/update-policy string unattended-upgrades
{% endif %}

# Additional repositories, local[0-9] available
#d-i apt-setup/local0/repository string \
# http://local.server/debian stable main
Expand All @@ -335,11 +331,15 @@ d-i apt-setup/local0/key string file:///hd-media/ac583520.asc
tasksel tasksel/first multiselect standard

# Individual additional packages to install
d-i pkgsel/include string openssh-server curl
d-i pkgsel/include string openssh-server curl python python3 # grub-ipxe
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
#d-i pkgsel/upgrade select none

{% if distro == 'Ubuntu' %}
d-i pkgsel/update-policy string unattended-upgrades
{% endif %}

# Some versions of the installer can report back on what software you have
# installed, and what software you use. The default is not to report back,
# but sending reports helps the project determine what software is most
Expand All @@ -365,9 +365,9 @@ d-i grub-installer/with_other_os boolean true

# Due notably to potential USB sticks, the location of the MBR can not be
# determined safely in general, so this needs to be specified:
d-i grub-installer/bootdev string /dev/sda
# d-i grub-installer/bootdev string /dev/sda
# To install to the first device (assuming it is not a USB stick):
#d-i grub-installer/bootdev string default
d-i grub-installer/bootdev string default

# Alternatively, if you want to install to a location other than the mbr,
# uncomment and edit these lines:
Expand Down Expand Up @@ -428,7 +428,8 @@ d-i finish-install/reboot_in_progress note

# This first command is run as early as possible, just after
# preseeding is read.
#d-i preseed/early_command string anna-install some-udeb
d-i preseed/early_command string cd /tmp && wget http://$url/ec/early_command.sh && chmod u+x early_command.sh && ./early_command.sh

# This command is run immediately before the partitioner starts. It may be
# useful to apply dynamic partitioner preseeding that depends on the state
# of the disks (which may not be visible when preseed/early_command runs).
Expand All @@ -438,7 +439,7 @@ d-i finish-install/reboot_in_progress note
# still a usable /target directory. You can chroot to /target and use it
# directly, or use the apt-install and in-target commands to easily install
# packages and run commands in the target system.
d-i preseed/late_command string in-target sh -c "curl -o late_command.sh 'http://{{ inventory_hostname }}/d-i/late_command.sh' && ANSIBLE_UNDER_DI=1 sh late_command.sh && rm late_command.sh"
d-i preseed/late_command string cd /target/tmp && wget http://$url/d-i/late_command.sh && chmod u+x late_command.sh && chroot /target unset http_proxy; ANSIBLE_UNDER_DI=1 /tmp/late_command.sh $(debconf-get mirror/suite) $(debconf-get passwd/username)

# don't ask for extra firmare
d-i hw-detect/load_firmware boolean false