Start puppet with a non root user different than default 'puppet'

432 views
Skip to first unread message

Javi

unread,
Jul 18, 2012, 9:55:36 AM7/18/12
to puppet...@googlegroups.com
Good evening.

I tried:

cd /set
sudo chown -R myuser:myuser puppet
sudo vim /etc/puppet/puppet.conf

Add:

[main]
...
user myuser

And:

[main]
...
user myuser

sudo /etc/init.d/pupettmaster restart

But no luck. Any idea?

Thanks

Jan

unread,
Jul 18, 2012, 11:39:48 AM7/18/12
to puppet...@googlegroups.com, Javi
Hi,

On 07/18/2012 03:55 PM Javi wrote:
> Add:
>
> [main]
> ...
> user myuser
>
> And:
>
> [main]
> ...
> user myuser
>
> sudo /etc/init.d/pupettmaster restart
>
> But no luck. Any idea?

which distribution you're running on? The user might be set by the init
script by passing the necessary parameters directly to the process and
AFAIK those parameters always take precedence for those specified within
/etc/puppet/puppet.conf ..

Kill the process and try starting it directly:

------------------------------------>8------------------------------------
# sudo /etc/init.d/pupettmaster stop;
# sudo su -;
# puppetmasterd --config=/etc/puppet.conf;
# ps aux | grep 'puppet';
------------------------------------8<------------------------------------

Cheers
- Jan

signature.asc

Javi Legido

unread,
Jul 20, 2012, 6:30:57 AM7/20/12
to Jan, puppet...@googlegroups.com
Thanks for reply, but your fix didn't worked.

I use debian, and below packages versions:

ii puppet 2.6.2-5+squeeze5
Centralized configuration management - agent startup and compatibility
scripts
ii puppet-common 2.6.2-5+squeeze5
Centralized configuration management
ii puppetmaster 2.6.2-5+squeeze5
Centralized configuration management - master startup and
compatibility scripts

Do you know how to pass the user as a parameter to the puppet script?

Below content of the /etc/init.d/puppetmaster script:

#! /bin/sh
### BEGIN INIT INFO
# Provides: puppetmaster
# Required-Start: $network $named $remote_fs $syslog
# Required-Stop: $network $named $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/puppet
DAEMON_OPTS=""
NAME=master
DESC="puppet master"

test -x $DAEMON || exit 0

[ -r /etc/default/puppetmaster ] && . /etc/default/puppetmaster

. /lib/lsb/init-functions

if [ ! -d /var/run/puppet ]; then
mkdir -p /var/run/puppet
fi

chown puppet:puppet /var/run/puppet

is_true() {
if [ "x$1" = "xtrue" -o "x$1" = "xyes" -o "x$1" = "x0" ] ; then
return 0
else
return 1
fi
}

start_puppet_master() {
if is_true "$START" ; then
if [ "$SERVERTYPE" = "mongrel" ]
then
DAEMON_OPTS="$DAEMON_OPTS --servertype=mongrel"
NUMSTART=0
STARTPORT=$PORT
while [ $NUMSTART -lt $PUPPETMASTERS ]; do
start-stop-daemon --start --quiet
--pidfile=/var/run/puppet/${NAME}-${STARTPORT}.pid \
--startas $DAEMON -- $NAME $DAEMON_OPTS
--masterport=$STARTPORT
--pidfile=/var/run/puppet/${NAME}-${STARTPORT}.pid
STARTPORT=$(($STARTPORT + 1))
NUMSTART=$(($NUMSTART + 1))
done
else
start-stop-daemon --start --quiet --pidfile
/var/run/puppet/${NAME}.pid \
--startas $DAEMON -- $NAME $DAEMON_OPTS --masterport=$PORT
fi
else
echo ""
echo "puppetmaster not configured to start, please edit
/etc/default/puppetmaster to enable"
fi
}

stop_puppet_master() {
if [ "$SERVERTYPE" = "mongrel" ]
then
NUMSTART=0
STOPPORT=$PORT
while [ $NUMSTART -lt $PUPPETMASTERS ]; do
start-stop-daemon --stop --quiet --oknodo --pidfile
/var/run/puppet/${NAME}-${STOPPORT}.pid
rm -f /var/run/puppet/${NAME}-${STOPPORT}.pid
STOPPORT=$(($STOPPORT + 1))
NUMSTART=$(($NUMSTART + 1))
done
else
start-stop-daemon --stop --quiet --oknodo --pidfile
/var/run/puppet/${NAME}.pid
fi
}

status_puppet_master() {
if is_true "$START" ; then
if [ "$SERVERTYPE" = "mongrel" ]
then
NUMSTART=0
STARTPORT=$PORT
while [ $NUMSTART -lt $PUPPETMASTERS ]; do
status_of_proc -p "/var/run/puppet/${NAME}-${STARTPORT}.pid" \
"${DAEMON}" "${NAME}-${STARTPORT}"
STARTPORT=$(($STARTPORT + 1))
NUMSTART=$(($NUMSTART + 1))
done
else
status_of_proc -p "/var/run/puppet/${NAME}.pid"
"${DAEMON}" "${NAME}"
fi
else
echo ""
echo "puppetmaster not configured to start"
fi
}

case "$1" in
start)
log_begin_msg "Starting $DESC"
start_puppet_master
log_end_msg $?
;;
stop)
log_begin_msg "Stopping $DESC"
stop_puppet_master
log_end_msg $?
;;
reload)
# Do nothing, as Puppetmaster rechecks its config automatically
;;
status)
status_puppet_master
;;
restart|force-reload)
log_begin_msg "Restarting $DESC"
stop_puppet_master
sleep 1
start_puppet_master
log_end_msg $?
;;
*)
echo "Usage: $0 {start|stop|status|restart|force-reload}" >&2
exit 1
;;
esac


2012/7/18 Jan <j...@agetty.de>:

Javi Legido

unread,
Jul 20, 2012, 6:36:58 AM7/20/12
to Jan, puppet...@googlegroups.com
Fixed changing below line:

chown my_user:my_user /var/run/puppet

Regards

2012/7/20 Javi Legido <ja...@legido.com>:

Javi Legido

unread,
Jul 20, 2012, 6:47:33 AM7/20/12
to Jan, puppet...@googlegroups.com
Correction: below actions are needed:

/etc/puppet/puppet.conf

[main]
...
user=my_user

/etc/init.d/puppetmaster

...
chown my_user:my_user /var/run/puppet

Cheers


2012/7/20 Javi Legido <ja...@legido.com>:
Reply all
Reply to author
Forward
0 new messages