Add logging and update fuel-bootstrap-image-builder

Change-Id: I397710246569d268da0d813c37a97823e084f7ff
This commit is contained in:
Andrey Shestakov 2015-09-18 12:58:13 +03:00
parent 45a8157d90
commit 93e004fc22
16 changed files with 358 additions and 33 deletions

View File

@ -1,6 +1,6 @@
VERSION?=7.0.0
VERSION?=8.0.0
top_srcdir:=$(shell pwd)
ubuntu_DATA:=$(shell cd $(top_srcdir) && find share -type f)

View File

@ -8,7 +8,7 @@ datadir="${bindir%/*}/share/fuel-bootstrap-image"
global_conf="/etc/fuel-bootstrap-image.conf"
[ -r "$global_conf" ] && . "$global_conf"
[ -z "$MOS_VERSION" ] && MOS_VERSION="7.0"
[ -z "$MOS_VERSION" ] && MOS_VERSION="8.0"
[ -z "$DISTRO_RELEASE" ] && DISTRO_RELEASE="trusty"
[ -z "$MIRROR_DISTRO" ] && MIRROR_DISTRO="http://archive.ubuntu.com/ubuntu"
[ -z "$MIRROR_MOS" ] && MIRROR_MOS="http://mirror.fuel-infra.org/mos-repos/ubuntu/$MOS_VERSION"
@ -16,18 +16,16 @@ global_conf="/etc/fuel-bootstrap-image.conf"
[ -z "$ARCH" ] && ARCH="amd64"
[ -z "$DESTDIR" ] && DESTDIR="/var/www/nailgun/bootstrap/ubuntu"
BOOTSTRAP_FUEL_PKGS_DFLT="openssh-server ntp"
# Packages required for the master node to discover a bootstrap node
BOOTSTRAP_FUEL_PKGS_DFLT="openssh-client openssh-server ntp mcollective nailgun-agent nailgun-mcagents nailgun-net-check fuel-agent"
[ -z "$BOOTSTRAP_FUEL_PKGS" ] && BOOTSTRAP_FUEL_PKGS="$BOOTSTRAP_FUEL_PKGS_DFLT"
if [ -z "$BOOTSTRAP_IRONIC" ]; then
BOOTSTRAP_FUEL_PKGS_DFLT="$BOOTSTRAP_FUEL_PKGS_DFLT openssh-client mcollective nailgun-agent nailgun-mcagents nailgun-net-check"
GONFIG_SOURCE="$datadir/ubuntu/files/"
else
GONFIG_SOURCE="$datadir/ubuntu/files.ironic/"
fi
[ -z "$BOOTSTRAP_FUEL_PKGS" ] && BOOTSTRAP_FUEL_PKGS="$BOOTSTRAP_FUEL_PKGS_DFLT"
if [ -n "$http_proxy" ]; then
export HTTP_PROXY="$http_proxy"
elif [ -n "$HTTP_PROXY" ]; then
@ -256,12 +254,33 @@ make_utf8_locale ()
chroot "$root" /bin/sh -c "locale-gen en_US.UTF-8 && dpkg-reconfigure locales"
}
# XXX: CentOS version of debootstrap produces a broken /dev:
# /dev/fd is a directory instead of a symlink to /proc/self/fd
dev_fixup ()
{
local root="$1"
if [ -z "$root" ]; then
echo "*** Error: $MYSELF: dev_fixup: \$root is not specified" >&2
exit 1
fi
mkdir -p -m755 "$root/dev"
if [ ! -L "$root/dev/fd" ]; then
rm -rf "$root/dev/fd"
# Ask MAKEDEV to re-create /dev/fd, /dev/stdin, etc
chroot "$root" /bin/sh -c "cd /dev && MAKEDEV fd"
fi
if [ ! -c "$root/dev/null" ]; then
# basic device nodes are missing => create them
chroot "$root" /bin/sh -c "cd /dev && MAKEDEV std"
fi
}
copy_conf_files ()
{
local root="$1"
local sdir="$2"
rsync -rlptDK "${sdir}" "${root%/}"
sed -i $root/etc/shadow -e '/^root/c\root:$$6$$oC7haQNQ$$LtVf6AI.QKn9Jb89r83PtQN9fBqpHT9bAFLzy.YVxTLiFgsoqlPY3awKvbuSgtxYHx4RUcpUqMotp.WZ0Hwoj.:15441:0:99999:7:::'
sed -i $root/etc/shadow -e '/^root/c\root:$6$oC7haQNQ$LtVf6AI.QKn9Jb89r83PtQN9fBqpHT9bAFLzy.YVxTLiFgsoqlPY3awKvbuSgtxYHx4RUcpUqMotp.WZ0Hwoj.:15441:0:99999:7:::'
}
install_ssh_keys ()
@ -373,6 +392,7 @@ build_image ()
chmod 755 "$root"
suppress_services_start "$root"
run_debootstrap "$root"
dev_fixup "$root"
suppress_services_start "$root"
propagate_host_resolv_conf "$root"
make_utf8_locale "$root"

View File

@ -7,6 +7,7 @@ ASTUTE_YAML="/etc/fuel/astute.yaml"
cobbler_manifest="/etc/puppet/modules/nailgun/examples/cobbler-only.pp"
astute_manifest="/etc/puppet/modules/nailgun/examples/astute-only.pp"
ubuntu_bootstrap_dir="/var/www/nailgun/bootstrap/ubuntu"
bootstrap_conf="/etc/fuel-bootstrap-image.conf"
run_puppet () {
local container="$1"
@ -36,6 +37,10 @@ maybe_build_ubuntu_bootstrap ()
need_rebuild='yes'
fi
done
if ! grep -qE '^\s*BOOTSTRAP_SSH_KEYS\s*[=]' "$bootstrap_conf" 2>/dev/null; then
echo >> "$bootstrap_conf"
echo "BOOTSTRAP_SSH_KEYS=\"/root/.ssh/id_rsa.pub\"" >> "$bootstrap_conf"
fi
if [ -n "$need_rebuild" ]; then
cat >&2 <<-EOF
$MYSELF: info: Ubuntu bootstrap image does not exist, building one
@ -72,6 +77,10 @@ verify_bootstrap_flavor () {
;;
ubuntu|Ubuntu)
flavor='ubuntu'
cat >&2 <<-EOF
$MYSELF: WARNING: Ubuntu based bootstrap is EXPERIMENTAL.
$MYSELF: WARNING: Use at your own risk.
EOF
;;
*)
cat >&2 <<-EOF

View File

@ -1,5 +1,5 @@
%define name fuel-bootstrap-image-builder
%{!?version: %define version 7.0.0}
%{!?version: %define version 8.0.0}
%{!?release: %define release 1}
Summary: Fuel bootstrap image generator

View File

@ -1,13 +0,0 @@
[problems]
# Superblock last mount time is in the future (PR_0_FUTURE_SB_LAST_MOUNT).
0x000031 = {
preen_ok = true
preen_nomessage = true
}
# Superblock last write time is in the future (PR_0_FUTURE_SB_LAST_WRITE).
0x000032 = {
preen_ok = true
preen_nomessage = true
}

View File

@ -0,0 +1,184 @@
[DEFAULT]
#
# Options defined in fuel_agent.manager
#
# Data driver (string value)
#data_driver=nailgun
# Path to directory with cloud init templates (string value)
#nc_template_path=/usr/share/fuel-agent/cloud-init-templates
# Temporary directory for file manipulations (string value)
#tmp_path=/tmp
# Path where to store generated config drive image (string
# value)
#config_drive_path=/tmp/config-drive.img
# Path where to store actual rules for udev daemon (string
# value)
#udev_rules_dir=/etc/udev/rules.d
# Path where to store default rules for udev daemon (string
# value)
#udev_rules_lib_dir=/lib/udev/rules.d
# Substring to which file extension .rules be renamed (string
# value)
#udev_rename_substr=.renamedrule
# Directory where we build images (string value)
#image_build_dir=/tmp
# Directory where we build images (string value)
#image_build_suffix=.fuel-agent-image
#
# Options defined in fuel_agent.cmd.agent
#
# Input data file (string value)
#input_data_file=/tmp/provision.json
# Input data (json string) (string value)
#input_data=
#
# Options defined in fuel_agent.openstack.common.log
#
# Print debugging output (set logging level to DEBUG instead
# of default WARNING level). (boolean value)
#debug=true
# Print more verbose output (set logging level to INFO instead
# of default WARNING level). (boolean value)
#verbose=false
# Log output to standard error. (boolean value)
use_stderr=false
# Format string to use for log messages with context. (string
# value)
#logging_context_format_string=%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s
# Format string to use for log messages without context.
# (string value)
#logging_default_format_string=%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s
# Data to append to log format when level is DEBUG. (string
# value)
logging_debug_format_suffix=
# Prefix each line of exception output with this format.
# (string value)
#logging_exception_prefix=%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s
# List of logger=LEVEL pairs. (list value)
#default_log_levels=amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,suds=INFO,oslo.messaging=INFO,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN
# Enables or disables publication of error events. (boolean
# value)
#publish_errors=false
# Enables or disables fatal status of deprecations. (boolean
# value)
#fatal_deprecations=false
# The format for an instance that is passed with the log
# message. (string value)
#instance_format="[instance: %(uuid)s] "
# The format for an instance UUID that is passed with the log
# message. (string value)
#instance_uuid_format="[instance: %(uuid)s] "
# The name of a logging configuration file. This file is
# appended to any existing logging configuration files. For
# details about logging configuration files, see the Python
# logging module documentation. (string value)
# Deprecated group/name - [DEFAULT]/log_config
#log_config_append=<None>
# DEPRECATED. A logging.Formatter log message format string
# which may use any of the available logging.LogRecord
# attributes. This option is deprecated. Please use
# logging_context_format_string and
# logging_default_format_string instead. (string value)
#log_format=<None>
# Format string for %%(asctime)s in log records. Default:
# %(default)s . (string value)
#log_date_format=%Y-%m-%d %H:%M:%S
# (Optional) Name of log file to output to. If no default is
# set, logging will go to stdout. (string value)
# Deprecated group/name - [DEFAULT]/logfile
log_file=/var/log/fuel-agent.log
# (Optional) The base directory used for relative --log-file
# paths. (string value)
# Deprecated group/name - [DEFAULT]/logdir
#log_dir=<None>
# Use syslog for logging. Existing syslog format is DEPRECATED
# during I, and will change in J to honor RFC5424. (boolean
# value)
use_syslog=true
# (Optional) Enables or disables syslog rfc5424 format for
# logging. If enabled, prefixes the MSG part of the syslog
# message with APP-NAME (RFC5424). The format without the APP-
# NAME is deprecated in I, and will be removed in J. (boolean
# value)
use_syslog_rfc_format=true
# Syslog facility to receive log lines. (string value)
#syslog_log_facility=LOG_USER
#
# Options defined in fuel_agent.utils.artifact
#
# Size of data chunk to operate with images (integer value)
#data_chunk_size=1048576
#
# Options defined in fuel_agent.utils.build
#
# Maximum allowed loop devices count to use (integer value)
#max_loop_count=255
# Size of sparse file in MiBs (integer value)
#sparse_file_size=2048
# System-wide major number for loop device (integer value)
#loop_dev_major=7
#
# Options defined in fuel_agent.utils.utils
#
# Maximum retries count for http requests. 0 means infinite
# (integer value)
#http_max_retries=30
# Http request timeout in seconds (floating point value)
#http_request_timeout=10.0
# Delay in seconds before the next http request retry
# (floating point value)
#http_retry_delay=2.0
# Block size of data to read for calculating checksum (integer
# value)
#read_chunk_size=1048576

View File

@ -1,6 +1,9 @@
description "Ironic call back script"
start on started ssh
pre-start script
/usr/bin/configure-remote-logging.sh
end script
task

View File

@ -0,0 +1,29 @@
#################
#### MODULES ####
#################
$ModLoad imuxsock # provides support for local system logging
$ModLoad imklog # provides kernel logging support (previously done by rklogd)
#$ModLoad immark # provides --MARK-- message capability
###########################
#### GLOBAL DIRECTIVES ####
###########################
#
# Set the default permissions for all log files.
#
$FileOwner syslog
$FileGroup syslog
$FileCreateMode 0640
$DirCreateMode 0755
$umask 0000
$PrivDropToUser syslog
$PrivDropToGroup syslog
$MaxMessageSize 32k
#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf

View File

@ -0,0 +1,36 @@
# file is managed by puppet
#
# Log to remote syslog server
# Templates
# RFC3164 emulation with long tags (32+)
$Template RemoteLog, "<%pri%>%timestamp% ironic/@DEPLOYMENT_ID@/%syslogtag%%msg:::sp-if-no-1st-sp%%msg%\n"
# RFC544 emulation would be: "<%pri%>1 %timestamp:::date-rfc3339% %hostname% %syslogtag% %procid% %msgid% %structured-data% %msg%\n"
# Note: don't use %app-name% cuz it would be empty for some cases
$ActionFileDefaultTemplate RemoteLog
$WorkDirectory /var/spool/rsyslog/
#Start remote server 0
$ActionQueueType LinkedList # use asynchronous processing
$ActionQueueFileName remote0 # set file name, also enables disk mode
$ActionQueueMaxDiskSpace 1g
$ActionQueueSaveOnShutdown on
$ActionQueueLowWaterMark 2000
$ActionQueueHighWaterMark 8000
$ActionQueueSize 1000000 # Reserve 500Mb memory, each queue element is 512b
$ActionQueueDiscardMark 950000 # If the queue looks like filling, start discarding to not block ssh/login/etc.
$ActionQueueDiscardSeverity 0 # When in discarding mode discard everything.
$ActionQueueTimeoutEnqueue 0 # When in discarding mode do not enable throttling.
$ActionQueueDequeueSlowdown 1000
$ActionQueueWorkerThreads 2
$ActionQueueDequeueBatchSize 128
$ActionResumeRetryCount -1
# Isolate sudo logs locally
# match if "program name" is equal to "sudo"
:programname, isequal, "sudo" -/var/log/sudo.log
&~
# Send messages we receive to master node via tcp
# Use an octet-counted framing (understood for rsyslog only) to ensure correct multiline messages delivery
*.* @(o)@SYSLOG_SERVER_IP@:514;RemoteLog
#End remote server 0

View File

@ -1 +0,0 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDtrVTSM8tGd4E8khJn2gfN/2fymnX/0YKAGSVZTWDNIcYL5zXTlSwrccn/8EgmnNsJNxucJRT+oWqrDGaFaehuwlY/IBqm50KJVaUr5QYzOUpqVpFIpoX3UwETCxcSB1LiQYbCvrJcqOPQ4Zu9fMhMGKaAX1ohzOumn4czuLDYIvCnPnoU5RDWt7g1GaFFlzGU3JFooj7/aWFJMqJLinvay3vr2vFpBvO1y29nKu+zgpZkzzJCc0ndoVqvB+W9DY6QtgTSWfd3ZE/8vg4h8QV8H+xxqL/uWCxDkv2Y3rviAHivR/V+1YCSQH0NBJrNSkRjd+1roLhcEGT7/YEnbgVV nailgun@bootstrap

View File

@ -0,0 +1,9 @@
#!/bin/bash
SYSLOG_SERVER_IP=$(grep -oPz '(?<=\bip=)(\d+\.?){4}:\K(\d+\.?){4}' /proc/cmdline)
DEPLOYMENT_ID=$(grep -ioP '(?<=\bdeployment_id=)([0-9a-z-]+)\b' /proc/cmdline)
sed -i /etc/rsyslog.d/00-remote.conf -re "s/@SYSLOG_SERVER_IP@/$SYSLOG_SERVER_IP/"
sed -i /etc/rsyslog.d/00-remote.conf -re "s/@DEPLOYMENT_ID@/$DEPLOYMENT_ID/"
service rsyslog restart

View File

@ -1,3 +1,6 @@
[options]
broken_system_clock = true
[problems]
# Superblock last mount time is in the future (PR_0_FUTURE_SB_LAST_MOUNT).

View File

@ -33,6 +33,8 @@ $db_name = pick($ironic_hash['db_name'], 'ironic')
$db_password = pick($ironic_hash['password'], 'ironic')
$database_connection = "mysql://${db_name}:${db_password}@${db_host}/${db_name}?charset=utf8&read_timeout=60"
include ::rsyslog::params
$tftp_root = "/var/lib/ironic/tftpboot"
class { '::ironic':
@ -116,3 +118,17 @@ file { "/etc/ironic/fuel_key":
require => Class['ironic'],
}
file { "${rsyslog::params::rsyslog_d}55-server-ironic.conf":
content => template("ironic/55-server-ironic.conf.erb"),
} ~>
service { $rsyslog::params::service_name:
ensure => running,
enable => true,
}
firewall { '100 rsyslog' :
dport => '514',
proto => 'udp',
action => 'accept',
}

View File

@ -0,0 +1,38 @@
# Load UDP module
$ModLoad imudp
$UDPServerRun 514
$EscapeControlCharactersOnReceive off
#
# Disk-Assisted Memory Queues, async writes, no escape chars
#
$OMFileASyncWriting on
$MainMsgQueueType LinkedList
$WorkDirectory /var/spool/rsyslog/
$MainMsgQueueFileName mainmsgqueue
$MainMsgQueueSaveOnShutdown on
$MainMsgQueueDequeueSlowdown 1000
$MainMsgQueueWorkerThreads 2
$MainMsgQueueDequeueBatchSize 128
$ActionQueueType LinkedList
$WorkDirectory /var/spool/rsyslog/
$ActionQueueFileName acsdbq
$ActionQueueMaxDiskSpace 1g
$ActionQueueSaveOnShutdown on
$ActionQueueLowWaterMark 2000
$ActionQueueHighWaterMark 8000
$ActionQueueSize 1000000 # Reserve 500Mb memory, each queue element is 512b
$ActionQueueDiscardMark 950000 # If the queue looks like filling, start discarding to not block ssh/login/etc.
$ActionQueueDiscardSeverity 0 # When in discarding mode discard everything.
$ActionQueueTimeoutEnqueue 0 # When in discarding mode do not enable throttling.
$ActionQueueDequeueSlowdown 1000
$ActionQueueWorkerThreads 2
$ActionQueueDequeueBatchSize 128
$ActionResumeRetryCount -1
$SystemLogRateLimitInterval 0 # disable rate limits for rsyslog
$template RemoteLogFile, "/var/log/remote/%syslogtag:R,ERE,1,DFLT:([A-Za-z][A-Za-z0-9_./-]*)--end%.log"
:FROMHOST, regex, "^[1-9]" -?RemoteLogFile;RemoteLog

View File

@ -20,16 +20,6 @@
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 3600
- id: ironicopenstack-network-compute
type: puppet
groups: ['ironic']
required_for: [ironic-physnets-conductor]
requires: [ironic-compute]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/openstack-network/openstack-network-compute.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: ironic-network-ovs
groups: ['primary-controller', 'controller', 'ironic']
type: puppet

View File

@ -14,11 +14,13 @@ else
echo "Key ${key_file} already exists"
fi
export MOS_VERSION="7.0"
export BOOTSTRAP_IRONIC="yes"
export EXTRA_DEB_REPOS="deb http://127.0.0.1:8080/plugins/fuel-plugin-ironic-1.0/repositories/ubuntu /"
export DESTDIR="/var/www/nailgun/bootstrap/ironic"
export BOOTSTRAP_SSH_KEYS="${key_file}.pub"
export AGENT_PACKAGE_PATH="${package_path}/repositories/ubuntu"
export BOOTSTRAP_FUEL_PKGS="openssh-server ntp"
mkdir -p "${DESTDIR}"
${deployment_scripts_path}/fuel-bootstrap-image-builder/bin/fuel-bootstrap-image