Closed TomEros closed 6 years ago
Identified bugs in the script :
Setup ssh
bash: /root/.ssh/authorized_keys: No such file or directory
bash: /root/.ssh/authorized_keys: No such file or directory
Warning: Permanently added '10.224.142.15' (ECDSA) to the list of known hosts.
Permission denied (publickey).
ssh: Could not resolve hostname : Name or service not known
[...]
Finish !
You are now ready to use this container with ansible
Ip of master : 10.224.142.15 Ip of slave :
We should add to this script :
lxc creates the .ssh directory but we need to wait.
The following script show this behavior :
#!/bin/bash
containerName="toto"
lxc launch ubuntu:16.04 $containerName
lxc exec $containerName -- bash -c "[ -d ~/.ssh/ ]"
dirExist=$?
until [ $dirExist -eq 0 ]
do
echo ".ssh doesn't exists waiting a bit"
sleep 0.1
lxc exec $containerName -- bash -c "[ -d ~/.ssh/ ]"
dirExist=$?
done
lxc exec $containerName -- bash -c "ls -la ~/.ssh/"
So we should implement a wait function before trying to add the sshKey, same for ip :
#!/bin/bash
containerName="toto"
lxc launch ubuntu:16.04 $containerName
ip=`lxc info $containerName | grep -P "eth0:\tinet\t" | awk '{print $3}'`
until ! [ -z $ip ]
do
printf "."
sleep 0.1
ip=`lxc info $containerName | grep -P "eth0:\tinet\t" | awk '{print $3}'`
done
printf "\nIP of %s is : %s\n" $containerName $ip
@zyioump can you implement that ? Use bash functions to do it.
Deploy in one command line the LXD cluster