./priv/roles/Common.sh in stacco-0.1.46 vs ./priv/roles/Common.sh in stacco-0.1.47

- old
+ new

@@ -6,31 +6,59 @@ set -e export HOME=/root cd "$HOME" -echo "configuring hostname from aws metadata service" -host_title="${AWS_STACK_NAME}-$(echo "${AWS_INSTANCE_LOGICAL_NAME}" | sed 's/LaunchConfiguration$//')" +stop rsyslog + +echo "configuring hostname from cloudformation and aws metadata service" +configured_hostname="${CFN_INSTANCE_HOSTNAME}" +configured_hostname_short=$(echo "${configured_hostname}" | cut -d'.' -f 1) private_hostname=$(curl -sL http://169.254.169.254/latest/meta-data/local-hostname) -short_private_hostname=$(echo "${private_hostname}" | cut -d'.' -f 1) -echo "${host_title}" > /etc/hostname +private_hostname_short=$(echo "${private_hostname}" | cut -d'.' -f 1) +private_ipv4=$(curl -fsL http://169.254.169.254/latest/meta-data/local-ipv4) +public_hostname=$(curl -fsL http://169.254.169.254/latest/meta-data/public-hostname || :) +public_hostname_short=$(echo "${public_hostname}" | cut -d'.' -f 1) +public_ipv4=$(curl -fsL http://169.254.169.254/latest/meta-data/public-ipv4 || :) + +echo "${configured_hostname_short}" > /etc/hostname hostname -b -F /etc/hostname sed -i '/127\.0\./d' /etc/hosts cat >>/etc/hosts <<EOF 127.0.0.1 localhost -127.0.1.1 ${private_hostname} ${host_title} ${short_private_hostname} +${private_ipv4} ${configured_hostname} ${configured_hostname_short} +127.0.1.1 ${private_hostname} ${private_hostname_short} EOF +if [ -n "${public_hostname}" ]; then +cat >>/etc/hosts <<EOF +127.0.2.1 ${public_hostname} ${public_hostname_short} +EOF +fi +rm -f /etc/rsyslog.d/21-cloudinit.conf + +cat >/etc/rsyslog.d/91-receive-container-logs.conf <<EOF +module(load="imfile") +module(load="imtcp" MaxSessions="500") +module(load="imudp") + +input(type="imtcp" port="514") +input(type="imudp" port="514") +EOF + if [ -n "$PAPERTRAIL_HOST" ]; then curl -sL "https://papertrailapp.com/tools/papertrail-bundle.pem" > /etc/ssl/certs/papertrail.pem -cat >>/etc/rsyslog.d/99-papertrail.conf <<EOF +cat >/etc/rsyslog.d/99-papertrail.conf <<EOF \$PreserveFQDN on \$DefaultNetstreamDriverCAFile /etc/ssl/certs/papertrail.pem \$ActionSendStreamDriver gtls \$ActionSendStreamDriverMode 1 \$ActionSendStreamDriverAuthMode x509/name \$ActionSendStreamDriverPermittedPeer *.papertrailapp.com *.* @@${PAPERTRAIL_HOST} EOF -restart rsyslog fi + +chown -R root:syslog /var/log/upstart + +start rsyslog