roles/dch-storage-net: Set up/mount shared storage

The *dch-storage-net* role configures a machine to connect the storage
network and mount shared folders from the storage appliance.

The `wait-global-address.sh` script and corresponding
*wait-global-address@.service* systemd unit template are necessary to
ensure that the storage network is actually available before attempting
to mount the shared volumes. This is particularly important at boot,
since `dhcpcd` does not implement any kind of signaling that can be used
by *network-online.target*, so the network is considered "online" as
soon as the `dhcpcd` process has started. This typically results in
"network unreachable" errors.
jenkins-master
Dustin 2018-07-23 17:25:25 -05:00
parent abd05f8443
commit f8ae016042
4 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,14 @@
[Unit]
Description=Wait for global address on %I
Requires=sys-subsystem-net-devices-%i.device
After=network-pre.target
Before=network-online.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/libexec/wait-global-address.sh %I
[Install]
WantedBy=network-online.target

View File

@ -0,0 +1,6 @@
#!/bin/sh
until ip -o address show dev "$1" | grep -q global; do
printf 'Waiting for global address on %s\n' "$1"
sleep 1;
done

View File

@ -0,0 +1,2 @@
- name: reload systemd
command: systemctl daemon-reload

View File

@ -0,0 +1,29 @@
- name: ensure wait-global-address script is installed
copy:
src=wait-global-address.sh
dest=/usr/local/libexec/wait-global-address.sh
mode=0755
- name: ensure wait-global-address unit is installed
copy:
src=wait-global-address.service
dest=/etc/systemd/system/wait-global-address@.service
mode=0644
notify: reload systemd
- name: ensure wait-global-address service starts at boot
service:
name=wait-global-address@{{ storage_iface }}.service
enabled=yes
- name: ensure wait-global-address service is running
service:
name=wait-global-address@{{ storage_iface }}.service
state=started
- name: ensure storage volumes are mounted
mount:
path={{ item.mountpoint }}
src={{ item.host }}:{{ item.share }}
fstype={{ item.fstype|d('nfs') }}
opts={{ item.opts|d(omit) }}
state=mounted
with_items: '{{ mount_shared_volumes }}'