Sending messages to rabbit mq using lisp inside a docker container - rabbitmq

I am attempting to use cl-rabbit to communicate with the RabbitMQ broker from a lisp process running inside a Docker container. I have code that works when I run it outside a docker container, so the problem is either related to the OS or Docker. (It runs on Mac OS X outside the container, but Ubuntu 14.04 inside the container.)
When I run the system with docker-compose up, I see output that the message broker has started successfully. The lisp client gives this output:
sbcl-rabbit_1 | This is SBCL 1.2.15, an implementation of ANSI Common Lisp.
sbcl-rabbit_1 | More information about SBCL is available at <http://www.sbcl.org/>.
sbcl-rabbit_1 |
sbcl-rabbit_1 | SBCL is free software, provided as is, with absolutely no warranty.
sbcl-rabbit_1 | It is mostly in the public domain; some portions are provided under
sbcl-rabbit_1 | BSD-style licenses. See the CREDITS and COPYING files in the
sbcl-rabbit_1 | distribution for more information.
sbcl-rabbit_1 | Created connection #<CL-RABBIT::CONNECTION {10047054F3}>
sbcl-rabbit_1 | Created socket #.(SB-SYS:INT-SAP #X00651650)
sbcl-rabbit_1 | Opened socket #.(SB-SYS:INT-SAP #X00651650)
sbcl-rabbit_1 | CORRUPTION WARNING in SBCL pid 10(tid 140737354065728):
sbcl-rabbit_1 | Memory fault at 0x7ffff266ce10 (pc=0x7ffff2c957c2, sp=0x7ffff309f3d0)
sbcl-rabbit_1 | The integrity of this image is possibly compromised.
sbcl-rabbit_1 | Continuing with fingers crossed.
sbcl-rabbit_1 | Unhandled SB-SYS:MEMORY-FAULT-ERROR in thread #<SB-THREAD:THREAD
sbcl-rabbit_1 | "main thread" RUNNING
sbcl-rabbit_1 | {1003FAF093}>:
sbcl-rabbit_1 | Unhandled memory fault at #x7FFFF266CE10.
sbcl-rabbit_1 |
sbcl-rabbit_1 | Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1003FAF093}>
sbcl-rabbit_1 | 0: ((LAMBDA NIL :IN SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX))
sbcl-rabbit_1 | 1: (SB-IMPL::CALL-WITH-SANE-IO-SYNTAX #<CLOSURE (LAMBDA NIL :IN SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX) {10047B016B}>)
sbcl-rabbit_1 | 2: (SB-IMPL::%WITH-STANDARD-IO-SYNTAX #<CLOSURE (LAMBDA NIL :IN SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX) {10047B013B}>)
sbcl-rabbit_1 | 3: (PRINT-BACKTRACE :STREAM #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDERR* {1000164243}> :START 0 :FROM :INTERRUPTED-FRAME :COUNT NIL :PRINT-THREAD T :PRINT-FRAME-SOURCE NIL :METHOD-FRAME-STYLE NIL)
sbcl-rabbit_1 | 4: (SB-DEBUG::DEBUGGER-DISABLED-HOOK #<SB-SYS:MEMORY-FAULT-ERROR {10047ACE93}> #<unavailable argument>)
sbcl-rabbit_1 | 5: (SB-DEBUG::RUN-HOOK *INVOKE-DEBUGGER-HOOK* #<SB-SYS:MEMORY-FAULT-ERROR {10047ACE93}>)
sbcl-rabbit_1 | 6: (INVOKE-DEBUGGER #<SB-SYS:MEMORY-FAULT-ERROR {10047ACE93}>)
sbcl-rabbit_1 | 7: (ERROR SB-SYS:MEMORY-FAULT-ERROR :ADDRESS 140737260211728)
sbcl-rabbit_1 | 8: (SB-SYS:MEMORY-FAULT-ERROR)
sbcl-rabbit_1 | 9: ("foreign function: call_into_lisp")
sbcl-rabbit_1 | 10: ("foreign function: post_signal_tramp")
sbcl-rabbit_1 | 11: (CFFI::PREPARE-FUNCTION "amqp_login_with_properties" (:STRUCT CL-RABBIT::AMQP-RPC-REPLY-T) (:POINTER :POINTER :INT :INT :INT :POINTER :INT :POINTER :POINTER) :DEFAULT-ABI)
sbcl-rabbit_1 | 12: (CL-RABBIT::AMQP-LOGIN-SASL-PLAIN-WITH-PROPERTIES #.(SB-SYS:INT-SAP #X00641500) "/" 0 131072 0 #.(SB-SYS:INT-SAP #X7FFFF329FFE8) 0 "guest" "guest")
sbcl-rabbit_1 | 13: ((LABELS #:FN274 :IN CL-RABBIT:LOGIN-SASL-PLAIN) (CL-RABBIT::NUM-ENTRIES 2 CL-RABBIT::ENTRIES #.(SB-SYS:INT-SAP #X00651840)))
sbcl-rabbit_1 | 14: (CL-RABBIT::CALL-WITH-AMQP-TABLE #<CLOSURE (LABELS #:FN274 :IN CL-RABBIT:LOGIN-SASL-PLAIN) {100470785B}> (("product" . "cl-rabbit") ("version" . "0.1")))
sbcl-rabbit_1 | 15: (CL-RABBIT.EXAMPLES::TROY-TEST)
sbcl-rabbit_1 | 16: (SB-INT:SIMPLE-EVAL-IN-LEXENV (CL-RABBIT.EXAMPLES::TROY-TEST) #<NULL-LEXENV>)
sbcl-rabbit_1 | 17: (EVAL (CL-RABBIT.EXAMPLES::TROY-TEST))
sbcl-rabbit_1 | 18: (SB-IMPL::PROCESS-EVAL/LOAD-OPTIONS ((:LOAD . "examples.lisp") (:EVAL . "(sleep 3)") (:EVAL . "(cl-rabbit.examples::troy-test)") (:QUIT)))
sbcl-rabbit_1 | 19: (SB-IMPL::TOPLEVEL-INIT)
sbcl-rabbit_1 | 20: ((FLET #:WITHOUT-INTERRUPTS-BODY-83 :IN SAVE-LISP-AND-DIE))
sbcl-rabbit_1 | 21: ((LABELS SB-IMPL::RESTART-LISP :IN SAVE-LISP-AND-DIE))
sbcl-rabbit_1 |
sbcl-rabbit_1 | unhandled condition in --disable-debugger mode, quitting
The stack trace seems to indicate something like a bad pointer reference inside the RabbitMq-C code.
To build the docker images, used this file to create an sbcl image:
FROM ubuntu:14.04
# Install things needed to get and install sbcl and quicklisp
RUN apt-get -y update && apt-get install -y wget make pkg-config gcc libffi-dev
# Install sbcl
RUN cd /usr/local && \
wget http://prdownloads.sourceforge.net/sbcl/sbcl-1.2.15-x86-64-linux-binary.tar.bz2 && \
tar xf sbcl-1.2.15-x86-64-linux-binary.tar.bz2 && \
cd sbcl-1.2.15-x86-64-linux && \
./install.sh
# Install quicklisp
RUN wget https://beta.quicklisp.org/quicklisp.lisp && \
yes "" | sbcl --load quicklisp.lisp \
--eval '(quicklisp-quickstart:install)' \
--eval '(ql:quickload "vecto")' \
--eval '(ql:add-to-init-file)'\
--non-interactive
# Mount workspace
WORKDIR /app
# Run sbcl
CMD sbcl
That is build with docker build -f Dockerfile-sbcl -t sbcl. I then have a second docker file to build an image with cl-rabbit.
# SBCL with cl-rabbit installed
FROM sbcl
RUN apt-get update -y && apt-get install -y librabbitmq-dev
ENV SBCL_CORE_DIR=/sbcl
RUN mkdir -p $SBCL_CORE_DIR
RUN sbcl --eval '(ql:quickload :cl-rabbit)' \
--eval '(sb-ext:save-lisp-and-die "/'${SBCL_CORE_DIR}'/sbcl-rabbit.core")'
RUN echo Saved core in $SBCL_CORE_DIR
RUN ls -l $SBCL_CORE_DIR
CMD sbcl --core $SBCL_CORE_DIR/sbcl-rabbit.core \
--non-interactive \
--load examples.lisp \
--eval '(sleep 3)' \
--eval '(cl-rabbit.examples::troy-test)'
#CMD ls -l
# EOF
This is built using docker-compose build with this docker-compose.yml.
sbcl-rabbit:
build: .
dockerfile: Dockerfile-sbcl-rabbitmq
volumes:
- ../../path/to/lisp://app
links:
- msgbroker
msgbroker:
image: rabbitmq
ports:
- "5672:5672"
When I run this with docker-compose up, I get the output described above.
Examples.lisp is the following:
(require 'cl-rabbit)
(in-package :cl-rabbit.examples)
(defvar msgbroker "msgbroker")
;;(setq msgbroker "localhost")
(defun troy-test ()
(with-connection (conn)
(format t "Created connection ~s~%" conn)
(let ((socket (tcp-socket-new conn))
(channel 1))
(format t "Created socket ~s~%" socket)
(socket-open socket msgbroker 5672)
(format t "Opened socket ~s~%" socket)
(login-sasl-plain conn "/" "guest" "guest")
(format t "logged in ~s~%" conn)
(channel-open conn channel)
(format t "Openned channel ~s~%" conn)
(queue-declare conn channel
:queue "lisp-queue"
:durable t)
(exchange-declare conn channel "lisp-exchange" "direct"
:durable t)
(queue-bind conn channel
:queue "lisp-queue"
:routing-key "lisp-queue"
:exchange "lisp-exchange")
(print "Bound queue")
(basic-publish conn channel
:exchange "lisp-exchange"
:routing-key "lisp-queue"
:body "Message from lisp")
(print "Pubished");
(basic-consume conn channel "lisp-queue")
(print "Received")
(let* ((result (consume-message conn))
(message (envelope/message result))
(formatted (format t "Got message: ~s~%content: ~s~%props: ~s"
result (babel:octets-to-string (message/body message) :encoding :utf-8)
(message/properties message))))
(prin1 formatted)
(pprint formatted)
(cl-rabbit:basic-ack conn channel (envelope/delivery-tag result))))))
Based on the print statements, the problem is happening in login-sasl-plain.
I have used docker run rabbit_sbcl-rabbit bash to start the Docker container with an interactive shell, and verified, using telnet msgbroker 5672, that port 5672 on host msgbroker does connect to the rabbit MQ server. If I type text into the telnet session, I see a message from the server that an AMQP connection has been made.
I do not see a similar message when the lisp client attempts to connect.
Using a similar configuration, I have used a Java client to send and receive messages, with the sender and receiver being in one Docker container, and the RabbitMQ server in a different one, as I am attempting here.
Any idea what is going wrong, or further suggestions on things to do to try to diagnose it?

Hey if you still have troubles try to build sbcl with statically linked librabbitmq and libffi.
Also you may find my project helpful - https://github.com/cl-rabbit/cl-bunny/

Related

ActiveMQ execution failing on IBM i

Has anyone installed/run ActiveMQ on IBM i and can help me with this?
Either the process does not run or gives ZipException.
I downloaded ActiveMQ 5.16.2 from ActiveMQ 5.16.2 (Apr 28, 2021) - Unix/Linux/Cygwin bundle
for installing on IBMi V7R3 and followed the official steps for installation mentioned on Version 5 Getting Started - 'Installation Procedure for Unix' section.
This is similar to installing on IBMi as mentioned in - Installing activeMQ on IBM i5 V5R4
On running the command ./bin/activemq start, the process starts but ends without actually running ActiveMq.
It shows below error on the console -
./bin/activemq: 001-0019 Error found searching for command whoami. No such path or directory.
Also the command ./bin/activemq status returns ActiveMQ not running .
When running the command ./bin/activemq console, the process starts but gives the same whoami error and ends with ZipException.
On Windows, I have been able to install and run successfully.
Has anyone installed ActiveMQ on IBMi and can help me with this?
You are missing the command
whoami
This is not a shell built-in, so you would need to add that package to your installation.
h/t to #nfgl for the pointer to the IBM OSS rpm repo. If you inspect their src.rpm, you'll see they patch the activemq script. Worth reviewing
SRC RPM calls for this dependency: coreutils-gnu
IBM iSeries Patch of bin/activemq:
$ more activemq-activemq.patch
--- a/bin/activemq 2020-03-30 18:50:50.000000000 +0000
+++ b/bin/activemq 2020-03-30 18:57:03.000000000 +0000
## -336,10 +336,14 ##
-Dactivemq.data=\"${ACTIVEMQ_DATA}\" \
$ACTIVEMQ_CYGWIN \
-jar \"${ACTIVEMQ_HOME}/bin/activemq.jar\" $COMMANDLINE_ARGS >> $ACTIVEMQ_OUT 2>&1 &
- RET=\"\$?\"; APID=\"\$!\";
- echo \$APID > "${PIDFILE}";
- echo \"INFO: pidfile created : '${PIDFILE}' (pid '\$APID')\";exit \$RET" $DOIT_POSTFIX
- RET="$?"
+ exit \"\$?\"" $DOIT_POSTFIX
+ RET="$?"
+ sleep 5
+ OS400_PID=`ps | grep -iE 'java|jFromPASE|jvmStartPase|qp0zspwp' | grep -v '\spgm-' | grep -vE '^\s+1\s' | tail -n 1 | awk '{print $1}'`
+ rm -f $PIDFILE
+ qsh -c "/usr/bin/touch -C 1208 $PIDFILE"
+ echo $OS400_PID > $PIDFILE
+ echo "INFO: pidfile created : '$PIDFILE' (pid '$OS400_PID')"
elif [ -n "$TASK_TODO" ] && [ "$TASK_TODO" = "stop" ];then
SPID="`cat "${PIDFILE}"`"
$EXEC_OPTION $DOIT_PREFIX "\"$JAVACMD\" $ACTIVEMQ_OPTS $ACTIVEMQ_DEBUG_OPTS \
## -384,7 +388,7 ##
return 2
fi
ACTIVEMQ_PID="`cat ${ACTIVEMQ_PIDFILE}`"
- RET="`ps -p "${ACTIVEMQ_PID}"|grep java`"
+ RET=`/QOpenSys/usr/bin/ps -p ${ACTIVEMQ_PID}|grep -iE 'java|jFromPASE|jvmStartPase'`
if [ -n "$RET" ];then
return 0;
else
## -403,7 +407,7 ##
return 2
fi
THEPID=`cat ${PID_STOP}`
- RET=`ps -p $THEPID|grep java`
+ RET=`/QOpenSys/usr/bin/ps -p ${ACTIVEMQ_PID}|grep -iE 'java|jFromPASE|jvmStartPase'`
if [ -n "$RET" ];then
return 0;
else

Unattended signing of Reprepro packages with gpg-agent

For my SolydXK repository I'd like to add some packages available in Debian stretch-backports.
I've successfully setup the conf/distributions, conf/updates and FilterList files and the following command runs successfully when logged in to the server:
reprepro -b /path_to_repository_basedir update
When adding files to the repository I correctly have to fill in my gpg passphrase to sign the files. During the session I only have to do that once.
Now I've tried to make the signing unattended by creating this script that's called from my .bash_profile:
#!/bin/sh
OURKEY=ABCDEFGH
PASSPHRASE=my_passphrase
PIDOF=`pidof gpg-agent`
RETVAL=$?
# Decide wether to start gpg-agent daemon.
if [ "$RETVAL" -eq 1 ]; then
echo "Starting gpg-agent daemon."
eval `gpg-agent --allow-preset-passphrase --allow-mark-trusted --default-cache-ttl-ssh 4294967295 --default-cache-ttl 4294967295 --max-cache-ttl 4294967295 --daemon --enable-ssh-support --write-env-file "${HOME}/.gpg-agent-info"`
else
echo "Daemon gpg-agent already running."
fi
if [ -f "${HOME}/.gpg-agent-info" ]; then
. "${HOME}/.gpg-agent-info"
export GPG_AGENT_INFO
export SSH_AUTH_SOCK
export SSH_AGENT_PID
# Create necessary symbolic link
cp -fs `echo $GPG_AGENT_INFO | cut -d':' -f 1` "${HOME}/.gnupg/"
fi
# Default trust our own key
rm ~/.gnupg/trustlist.txt
for FP in $(gpg2 --fingerprint --with-colons --fingerprint $OURKEY | grep ^fpr | cut -d':' -f 10); do
echo "$FP S" >> ~/.gnupg/trustlist.txt
echo $PASSPHRASE | /usr/lib/gnupg2/gpg-preset-passphrase --preset $FP
done
# Set GPG TTY
export GPG_TTY=$(tty)
I checked the fingerprints (a.k.a. keygrip, but this version of gpgsm does not know the --with-keygrip option) and all seems to be alright. However, when a cron job runs the above update command, an error message states that the passphrase is incorrect.
The server runs on Debian old-squeeze (I know, I have to do something about that, but that's another problem) and that might be a big problem. Here's some version info:
cat /etc/debian_version
6.0.10
uname -r
3.14.52-vs2.3.6.15-1
gpg (GnuPG) 1.4.10
gpg (GnuPG) 2.0.14
gpgsm (GnuPG) 2.0.14
gpg-agent (GnuPG) 2.0.14
So, is there somebody here who has some experience with unattended signing of packages with gpg-agent and can explain to me what I'm doing wrong?

How to deploy a PaddlePaddle Docker container with GPU support?

There're slight discrepancies in the documentation Docker deployment for PaddlePaddle as compared to the documentation to manually install PaddlePaddle from source.
The documentation from the Docker deployment states after pulling the container from Docker Hub:
docker pull paddledev/paddle
the environment variables should be set and included in the docker run, i.e.:
export CUDA_SO="$(\ls /usr/lib64/libcuda* | xargs -I{} echo '-v {}:{}') $(\ls /usr/lib64/libnvidia* | xargs -I{} echo '-v {}:{}')"
export DEVICES=$(\ls /dev/nvidia* | xargs -I{} echo '--device {}:{}')
docker run ${CUDA_SO} ${DEVICES} -it paddledev/paddle:gpu-latest
The export commands seem to be looking for libcuda* and libnvidia* in /usr/lib64/ but in the documentation from source compilation, the location of lib64/ should be in /usr/local/cuda/lib64.
Regardless, the location of lib64/ can be found with:
cat /etc/ld.so.conf.d/cuda.conf
Additionally, the export command is looking for libnvidia* which doesn't seem exist anywhere in /usr/local/cuda/, except for libnvidia-ml.so:
/usr/local/cuda$ find . -name 'libnvidia*'
./lib64/stubs/libnvidia-ml.so
I suppose the correct files the CUDA_SO is looking for are
/usr/local/cuda/lib64/libcudart.so.8.0
/usr/local/cuda/lib64/libcudart.so.7.5
But is that right? What is the environmental variable(s) for CUDA_SO to deploy PaddlePaddle with GPU support?
Even after setting the libcudart* variable, the docker container doesn't seem to find the GPU driver, i.e.:
user0#server1:~/dockdock$ echo CUDA_SO="$(\ls $CUDA_CONFILE/libcuda* | xargs -I{} echo '-v {}:{}')"
CUDA_SO=-v /usr/local/cuda/lib64/libcudadevrt.a:/usr/local/cuda/lib64/libcudadevrt.a
-v /usr/local/cuda/lib64/libcudart.so:/usr/local/cuda/lib64/libcudart.so
-v /usr/local/cuda/lib64/libcudart.so.8.0:/usr/local/cuda/lib64/libcudart.so.8.0
-v /usr/local/cuda/lib64/libcudart.so.8.0.44:/usr/local/cuda/lib64/libcudart.so.8.0.44
-v /usr/local/cuda/lib64/libcudart_static.a:/usr/local/cuda/lib64/libcudart_static.a
user0# server1:~/dockdock$ export CUDA_SO="$(\ls $CUDA_CONFILE/libcuda* | xargs -I{} echo '-v {}:{}')"
user0# server1:~/dockdock$ export DEVICES=$(\ls /dev/nvidia* | xargs -I{} echo '--device {}:{}')
user0# server1:~/dockdock$ docker run ${CUDA_SO} ${DEVICES} -it paddledev/paddle:gpu-latest
root#bd25dfd4f824:/# git clone https://github.com/baidu/Paddle paddle
Cloning into 'paddle'...
remote: Counting objects: 26626, done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 26626 (delta 3), reused 0 (delta 0), pack-reused 26603
Receiving objects: 100% (26626/26626), 25.41 MiB | 4.02 MiB/s, done.
Resolving deltas: 100% (18786/18786), done.
Checking connectivity... done.
root#bd25dfd4f824:/# cd paddle/demo/quick_start/
root#bd25dfd4f824:/paddle/demo/quick_start# sed -i 's|--use_gpu=false|--use_gpu=true|g' train.sh
root#bd25dfd4f824:/paddle/demo/quick_start# bash train.sh
I0410 09:25:37.300365 48 Util.cpp:155] commandline: /usr/local/bin/../opt/paddle/bin/paddle_trainer --config=trainer_config.lr.py --save_dir=./output --trainer_count=4 --log_period=100 --num_passes=15 --use_gpu=true --show_parameter_stats_period=100 --test_all_data_in_one_period=1
F0410 09:25:37.300940 48 hl_cuda_device.cc:526] Check failed: cudaSuccess == cudaStat (0 vs. 35) Cuda Error: CUDA driver version is insufficient for CUDA runtime version
*** Check failure stack trace: ***
# 0x7efc20557daa (unknown)
# 0x7efc20557ce4 (unknown)
# 0x7efc205576e6 (unknown)
# 0x7efc2055a687 (unknown)
# 0x895560 hl_specify_devices_start()
# 0x89576d hl_start()
# 0x80f402 paddle::initMain()
# 0x52ac5b main
# 0x7efc1f763f45 (unknown)
# 0x540c05 (unknown)
# (nil) (unknown)
/usr/local/bin/paddle: line 109: 48 Aborted (core dumped) ${DEBUGGER} $MYDIR/../opt/paddle/bin/paddle_trainer ${#:2}
[1]: http://www.paddlepaddle.org/doc/build/docker_install.html
[2]: http://paddlepaddle.org/doc/build/build_from_source.html
How to deploy a PaddlePaddle Docker container with GPU support?
Also, in Chinese: https://github.com/PaddlePaddle/Paddle/issues/1764
Please refer to http://www.paddlepaddle.org/develop/doc/getstarted/build_and_install/docker_install_en.html
The recommended way is using nvidia-docker.
Please install nvidia-docker first following this tutorial.
Now you can run a GPU image:
docker pull paddlepaddle/paddle
nvidia-docker run -it --rm paddlepaddle/paddle:0.10.0rc2-gpu /bin/bash

Docker-machine and Openstack / SSH

I have a problem with docker-machine and openstack
running this command
docker-machine --debug create -d openstack --openstack-username admin --openstack-password admin --openstack-tenant-name admin --openstack-auth-url http://163.172.5.197:5000/v2.0 --openstack-flavor-id bea5cb42-c0b3-46fd-96a6-2f4c5d4448c2 --openstack-image-id 871a5ddf-a888-4b45-9201-78da07e6cdcb testmachine
gives me the output as follow
Docker Machine Version: 0.6.0, build e27fb87
Found binary path at /usr/local/bin/docker-machine
Launching plugin server for driver openstack
Plugin server listening at address 127.0.0.1:46658
() Calling .GetVersion
Using API Version 1
() Calling .SetConfigRaw
() Calling .GetMachineName
(flag-lookup) Calling .GetMachineName
(flag-lookup) Calling .DriverName
(flag-lookup) Calling .GetCreateFlags
Found binary path at /usr/local/bin/docker-machine
Launching plugin server for driver openstack
Plugin server listening at address 127.0.0.1:44014
() Calling .GetVersion
Using API Version 1
() Calling .SetConfigRaw
() Calling .GetMachineName
(testmachine) Calling .GetMachineName
(testmachine) Calling .DriverName
(testmachine) Calling .GetCreateFlags
(testmachine) Calling .SetConfigFromFlags
Running pre-create checks...
(testmachine) Calling .PreCreateCheck
(testmachine) Calling .GetConfigRaw
Creating machine...
(testmachine) Calling .Create
(testmachine) DBG | Authenticating... map[Insecure:false DomainID: DomainName: Username:admin TenantName:admin TenantID: AuthUrl:http://163.172.5.197:5000/v2.0]
(testmachine) DBG | Found tenant id using its name map[Name:admin ID:3247c97c6abf4c07aee78043a1caa261]
(testmachine) DBG | Creating Key Pair... map[Name:testmachine-5f792f35e57c8749b3a39074cc230831a6902250f91c7f76fb30299ad00713be]
(testmachine) Creating machine...
(testmachine) DBG | Creating OpenStack instance... map[FlavorId:bea5cb42-c0b3-46fd-96a6-2f4c5d4448c2 ImageId:871a5ddf-a888-4b45-9201-78da07e6cdcb]
(testmachine) DBG | Waiting for the OpenStack instance to be ACTIVE... map[MachineId:3184e817-07d2-47af-9cb7-06634cebcc0a]
(testmachine) DBG | Looking for the IP address... map[MachineId:3184e817-07d2-47af-9cb7-06634cebcc0a]
(testmachine) Calling .GetConfigRaw
(testmachine) Calling .DriverName
(testmachine) Calling .DriverName
Waiting for machine to be running, this may take a few minutes...
(testmachine) Calling .GetState
(testmachine) DBG | IP address found map[IP:10.0.0.2 MachineId:3184e817-07d2-47af-9cb7-06634cebcc0a]
(testmachine) DBG | Get status for OpenStack instance... map[MachineId:3184e817-07d2-47af-9cb7-06634cebcc0a]
(testmachine) DBG | State for OpenStack instance map[MachineId:3184e817-07d2-47af-9cb7-06634cebcc0a State:ACTIVE]
Detecting operating system of created instance...
Waiting for SSH to be available...
Getting to WaitForSSH function...
(testmachine) Calling .GetSSHHostname
(testmachine) Calling .GetSSHPort
(testmachine) Calling .GetSSHKeyPath
(testmachine) Calling .GetSSHKeyPath
(testmachine) Calling .GetSSHUsername
Using SSH client type: external
{[-o BatchMode=yes -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none root#10.0.0.2 -o IdentitiesOnly=yes -i /home/martin/.docker/machine/machines/testmachine/id_rsa -p 22] /usr/bin/ssh}
About to run SSH command:
exit 0
SSH cmd err, output: exit status 255:
Error getting ssh command 'exit 0' : Something went wrong running an SSH command!
command : exit 0
err : exit status 255
output :
Getting to WaitForSSH function...
(testmachine) Calling .GetSSHHostname
(testmachine) Calling .GetSSHPort
(testmachine) Calling .GetSSHKeyPath
(testmachine) Calling .GetSSHKeyPath
(testmachine) Calling .GetSSHUsername
Using SSH client type: external
{[-o BatchMode=yes -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none root#10.0.0.2 -o IdentitiesOnly=yes -i /home/martin/.docker/machine/machines/testmachine/id_rsa -p 22] /usr/bin/ssh}
About to run SSH command:
exit 0
then when i am trying to run docker-machine ls
testmachine - openstack Running tcp://10.0.0.2:2376 Unknown Unable to query docker version: Unable to read TLS config: open /home/martin/.docker/machine/machines/testmachine/server.pem: no such file or directory
Logs in openstack for machine :
open-vm-tools: not starting as this is not a VMware VM
landscape-client is not configured, please run landscape-config.
* Stopping CPU interrupts balancing daemon[74G[ OK ]
* Starting automatic crash report generation[74G[ OK ]
* Restoring resolver state... [80G [74G[ OK ]
* Stopping System V runlevel compatibility[74G[ OK ]
Generating locales...
en_US.UTF-8... up-to-date
Generation complete.
Cloud-init v. 0.7.5 running 'modules:final' at Tue, 03 May 2016 11:45:45 +0000. Up 10.17 seconds.
ci-info: +++++Authorized keys from /home/ubuntu/.ssh/authorized_keys for user ubuntu++++++
ci-info: +---------+-------------------------------------------------+---------+---------+
ci-info: | Keytype | Fingerprint (md5) | Options | Comment |
ci-info: +---------+-------------------------------------------------+---------+---------+
ci-info: | ssh-rsa | fe:05:1e:f2:04:c4:df:4f:53:f2:4f:c3:ba:ac:10:51 | - | - |
ci-info: +---------+-------------------------------------------------+---------+---------+
ec2:
ec2: #############################################################
ec2: -----BEGIN SSH HOST KEY FINGERPRINTS-----
ec2: 1024 46:c0:bb:6c:65:04:13:fc:ab:2b:51:4f:1c:1e:75:dc root#testmachine (DSA)
ec2: 256 81:cd:f3:dd:66:7a:ca:4e:95:78:43:a7:dc:29:ad:fd root#testmachine (ECDSA)
ec2: 256 f5:d9:c7:59:92:af:fc:b7:56:42:ca:1e:f7:bb:5b:89 root#testmachine (ED25519)
ec2: 2048 6e:2d:1b:52:84:3f:28:04:95:41:81:15:af:61:e5:96 root#testmachine (RSA)
ec2: -----END SSH HOST KEY FINGERPRINTS-----
ec2: #############################################################
-----BEGIN SSH HOST KEY KEYS-----
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFfEl02HEegH7vohFTTS1bxA7LaIua/f+j0Uvi1u3j8fyTfzuVzqHl73QaBtE6uJ7EuTaoDhNCeeyWF+sLqMulI= root#testmachine
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGmcm55oSkblJ//oUcNQMqB2oO7BG2vXA0fhHEhlOQba root#testmachine
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDc3VqU3V9of956GD0DhCc5YEbkBzOgOazVRiFxx31I2wW3Z5vnW+BgZLoRhB8Zj2Tbn70l7cPKcN3/orklZldhoSK4u0+0buqhArqqp+/JBmR5AXn6hlcRvpLU+KM1qFovJuwwuttelaB0vS9YzwCLiCODLp9A4mvOCFiCbxOpvz7Bt5mMlvBnZnN3iWNiAn4aMjCrxwuUGruTXnO9ffRMs6GC4WVazUD42cD34g4FUlPf1Dqlinau5bRQrNbrU8vhiXE+DhxQO4WMMulsYoKfVDxhRrokwNpS9rB1HhHd+VOh7iTwkEwszCPtsYSrXYVng8JZzHBdq94SrOU3D58Z root#testmachine
-----END SSH HOST KEY KEYS-----
Cloud-init v. 0.7.5 finished at Tue, 03 May 2016 11:45:46 +0000. Datasource DataSourceConfigDriveNet [net,ver=2][source=/dev/sr0]. Up 10.27 seconds
Ubuntu 14.04.4 LTS testmachine ttyS0
testmachine login:
I precise that ports 22, 80 and 2376 are open on the machine on OpenStack.
thanks, if someone could help me, it would be nice
TL;DR Try adding the following options:
--openstack-net-id or --openstack-net-name
--openstack-floatingip-pool
--openstack-sec-groups
Original answer:
I get the very same thing when running docker-machine 0.6.0 with the openstack driver. But v0.7.0 (build a650a40) works just fine for me. I'm running a centos image not ubuntu, but otherwise the same. Sorry, I've not used docker-machine in a while but try just grabbing the latest release and see if that helps.
Update:
Just double-checked what I ran above, I actually configured this with environment variables, specifying a few things additional to yours above. Specifically though, in addition to my openstack RC file, I set:
export OS_SSH_USER=centos
export OS_IMAGE_ID=c31637b9-455a-4849-8f46-2af1715f9dee
export OS_FLAVOR_NAME=m1.small
export OS_FLOATINGIP_POOL=INTERNAL-NETWORK
export OS_SECURITY_GROUPS=default
export OS_NETWORK_ID=b32e2700-8eac-4b7c-b9a8-16b6403927a2
and then ran:
docker-machine create -d=openstack testmachine

Multi-machine ansible setup with vagrant on windows

Purpose
I want ansible to provision virtual box vm's on my windows 8 machine [via Vagrant]. Everything needs to run locally and since Ansible doesn't run on Windows, I bootstrap a debian vm with ansible as the control machine. This code served as an example.
After struggling with the system I got it somewhat working, but not completely (although ansible doesn't tell me).
Question
What configuration is required for a multi-machine setup using ansible [in a vm], vagrant and virtualbox [on windows host] if we want:
ssh acces from the host machine to the ansible-vm as well as all the slaves
ssh acces from the ansible-vm to all the slaves
being able to shield the multi-machine network from the host's network, if possible
Problem
Running ansible -m ping -all -i path-to-hosts yields ssh errors. It seems ansible tries to reach the machines named web1 and db1, but can't find such hosts.
ESTABLISH CONNECTION FOR USER: vagrant
REMOTE_MODULE ping
ESTABLISH CONNECTION FOR USER: vagrant
REMOTE_MODULE ping
EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', 'web1', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1398362619.41-142470238612762 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1398362619.41-142470238612762 && echo $HOME/.ansible/tmp/ansible-tmp-1398362619.41-142470238612762'"]
EXEC previous known host file not found for web1
EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', 'db1', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1398362619.41-4982781019922 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1398362619.41-4982781019922 && echo $HOME/.ansible/tmp/ansible-tmp-1398362619.41-4982781019922'"]
EXEC previous known host file not found for db1
web1 | FAILED => SSH encountered an unknown error. The output was:
OpenSSH_6.0p1 Debian-4, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/vagrant/.ansible/cp/ansible-ssh-web1-22-vagrant" does not exist
debug2: ssh_connect: needpriv 0
ssh: Could not resolve hostname web1: Name or service not known
db1 | FAILED => SSH encountered an unknown error. The output was:
OpenSSH_6.0p1 Debian-4, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/vagrant/.ansible/cp/ansible-ssh-db1-22-vagrant" does not exist
debug2: ssh_connect: needpriv 0
ssh: Could not resolve hostname db1: Name or service not known
Code
The following code tries to provision
1. ansible-master: the control machine running ansible
1. db1: a database server
1. web1: a web server
Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "wheezy64"
config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210.box"
config.vm.synced_folder ".", "/vagrant", :mount_options => ['dmode=777','fmode=666']
config.vm.network :public_network
config.vm.provider "virtualbox" do |v|
v.customize [
"modifyvm", :id,
"--groups", "/Vagrant/Ansible",
# "--natdnshostresolver1", "on"
]
end
config.vm.define :ansiblemaster do |ansiblemaster|
# ansiblemaster.vm.network :private_network, ip: "192.168.111.101"
ansiblemaster.vm.hostname = "ansiblemaster"
# ansiblemaster.vm.network :forwarded_port, guest: 80, host: 8080
ansiblemaster.ssh.forward_agent = true
ansiblemaster.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", 512]
vb.customize ["modifyvm", :id, "--name", "ansible-master"]
vb.name = "ansiblemaster"
end
ansiblemaster.vm.provision :shell, :inline =>
"if [[ ! -f /apt-get-run ]]; then sudo apt-get update && sudo touch /apt-get-run; fi"
ansiblemaster.vm.provision :shell do |sh|
sh.path = "provision.sh"
sh.args = "./ansible provisioning/site.yml provisioning/hosts/dev_hosts"
end
end
config.vm.define :web1 do |slave|
slave.vm.hostname = "web1"
# slave.vm.network :private_network, ip: "192.168.111.201"
slave.vm.synced_folder "./src", "/var/www/site", id: "proj-root"
slave.vm.provider :virtualbox do |vb|
vb.name = "web1"
vb.customize ["modifyvm", :id, "--memory", "512"]
end
end
config.vm.define :db1 do |slave|
slave.vm.hostname = "db1"
#slave.vm.network :private_network, ip: "192.168.111.202"
slave.vm.provider :virtualbox do |vb|
vb.name = "db1"
vb.customize ["modifyvm", :id, "--memory", "512"]
end
end
end
Provision.sh
#!/bin/bash
ANSIBLE_DIR=$1
ANSIBLE_PLAYBOOK=$2
ANSIBLE_HOSTS=$3
TEMP_HOSTS="/tmp/ansible_hosts"
if [ ! -f /vagrant/$ANSIBLE_PLAYBOOK ]; then
echo "Cannot find Ansible playbook"
exit 1
fi
if [ ! -f /vagrant/$ANSIBLE_HOSTS ]; then
echo "Cannot find Ansible hosts"
exit 2
fi
if [ ! -d $ANSIBLE_DIR ]; then
echo "Updating apt cache"
apt-get update
echo "Installing Ansible dependencies and Git"
apt-get install -y git python-yaml python-paramiko python-jinja2
echo "Cloning Ansible"
git clone git://github.com/ansible/ansible.git ${ANSIBLE_DIR}
fi
cd ${ANSIBLE_DIR}
cp /vagrant/${ANSIBLE_HOSTS} ${TEMP_HOSTS} && chmod -x ${TEMP_HOSTS}
echo "Running Ansible"
echo "dir is nu: " $(pwd)
source hacking/env-setup
echo "source ${ANSIBLE_DIR}/hacking/env-setup" >> /home/vagrant/.bashrc
ansible-playbook /vagrant/${ANSIBLE_PLAYBOOK} --inventory-file=${TEMP_HOSTS} --connection=local
rm ${TEMP_HOSTS}
provsioning/hosts/dev_hosts
[webservers]
web1
[dbservers]
db1
To answer my own question: the problem was resolved by upgrading ansible and importing the ssh keys of the other machines in Provision.sh.
# fix permissions on private key file
chmod 600 /home/vagrant/.ssh/id_rsa
# add web/database hosts to known_hosts (IP is defined in Vagrantfile)
ssh-keyscan -H 192.168.51.4 >> /home/vagrant/.ssh/known_hosts
ssh-keyscan -H 192.168.52.4 >> /home/vagrant/.ssh/known_hosts
chown vagrant:vagrant /home/vagrant/.ssh/known_hosts
# reload ssh in order to load the known hosts
/etc/init.d/ssh reload
Thats a really long question problem.
Ansible cant figure out the dns "ssh: Could not resolve hostname web1: Name or service not known"
Option 1
I like to simplify i boot my vagrant vm with static ip vm.network :private_network, ip: "xxx.xxx.xxx.xxx" and i edit my ansible host file
provsioning/hosts/dev_hosts
[webservers]
web1 ansible_ssh_host=xxx.xxx.xxx.xxx
[dbservers]
db1 ansible_ssh_host=xxx.xxx.xxx.yyy
Option 2
Use DNS or hostsfile
Hope that helps
Using "normal" Ansible modules to manage Windows boxes isn´t possible. Instead you have to use one of the windows modules. That´s the same for ping. It tries to connect via SSH to the Windows box, which doesn´t work.
Like skinnedknuckles already said, Ansible uses native Powershell remoting (and WinRM) instead of SSH to communicate with a Windows machine. So the win_ping module is the right way to do a ping with Ansible onto a Windows box:
ansible -m win_ping -all -i path-to-hosts
I assume you prepared your Windows 8 VM, like the docs are describing!?! If not, there´s this blog post explaining how to do all the steps incl. Vagrant setup with winrm connectivity in quite compact form.