forked from leifj/multiverse
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathhost-puppet-conf-test
More file actions
executable file
·41 lines (35 loc) · 1.51 KB
/
host-puppet-conf-test
File metadata and controls
executable file
·41 lines (35 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
set +x
HOSTNAME=$1
PUPPET_ARGS=()
PUPPET_ARGS+=("$2")
PUPPET_ARGS+=("--verbose")
if [ -z "$HOSTNAME" ]; then
echo "Usage: $0 fqdn"
exit 1
fi
if [ ! -d "$HOSTNAME" ]; then
echo "$0: No host-directory for '$HOSTNAME' found - execute in top-level cosmos dir"
exit 1
fi
# Check if cosmos or puppet is already running on host
echo "Checking if puppet or cosmos is already running..."
ssh root@"$HOSTNAME" ps aux | grep -Ev "grep|edit-secrets|gpg-agent" | grep -Eq "cosmos|puppet"
if [ $? -eq 1 ]; then
echo "Copying files to host..."
rsync -av --exclude '*~' global/overlay/etc/puppet/cosmos-rules.yaml root@"$HOSTNAME":/etc/puppet/cosmos-rules.yaml
rsync -av --exclude '*~' global/overlay/etc/puppet/manifests/cosmos-site.pp root@"$HOSTNAME":/etc/puppet/manifests/cosmos-site.pp
rsync -av --exclude '*~' global/overlay/etc/hiera/data/common.yaml root@"$HOSTNAME":/etc/hiera/data/common.yaml
# Test if the user has symlinked puppet-sunet correctly
# by first checking if the link exits and then whether
# or not the directory contains any files.
if [ -L global/overlay/etc/puppet/cosmos-modules/sunet ] &&
[ -n "$(ls -A global/overlay/etc/puppet/cosmos-modules/sunet/*)" ]; then
rsync -av --delete --exclude '*~' global/overlay/etc/puppet/cosmos-modules/sunet/* root@"$HOSTNAME":/etc/puppet/cosmos-modules/sunet/.
fi
echo "Running puppet apply..."
ssh root@"$HOSTNAME" /usr/bin/puppet apply "${PUPPET_ARGS[@]}" /etc/puppet/manifests/cosmos-site.pp
else
echo "Cosmos or puppet already running. Exiting."
exit 1
fi