Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with python on FreeBSD 12 RC1 #30

Open
fredericalix opened this issue Nov 21, 2018 · 10 comments
Open

Problem with python on FreeBSD 12 RC1 #30

fredericalix opened this issue Nov 21, 2018 · 10 comments

Comments

@fredericalix
Copy link

When cloudbaseinit run, python crash with this log stack.

Starting local daemons:2018-11-22 00:02:29.890 673 CRITICAL cloudbaseinit [-] AttributeError: Undefined symbol "ERR_load_crypto_strings"
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit Traceback (most recent call last):
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit File "/root/bsd-cloudinit/run.py", line 3, in
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit shell.main()
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit File "/root/bsd-cloudinit/cloudbaseinit/shell.py", line 29, in main
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit init.InitManager().configure_host()
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit File "/root/bsd-cloudinit/cloudbaseinit/init.py", line 107, in configure_host
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit plugins = plugins_factory.load_plugins()
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit File "/root/bsd-cloudinit/cloudbaseinit/plugins/common/factory.py", line 45, in load_plugins
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit plugins.append(cl.load_class(class_path)())
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit File "/root/bsd-cloudinit/cloudbaseinit/utils/classloader.py", line 28, in load_class
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit module = import(parts[0], fromlist=parts[1])
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit File "/root/bsd-cloudinit/cloudbaseinit/plugins/freebsd/setuserpassword.py", line 25, in
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit from cloudbaseinit.utils import crypt
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit File "/root/bsd-cloudinit/cloudbaseinit/utils/crypt.py", line 89, in
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit openssl.ERR_load_crypto_strings.restype = ctypes.c_int
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit File "/usr/local/lib/python2.7/ctypes/init.py", line 379, in getattr
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit func = self.getitem(name)
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit File "/usr/local/lib/python2.7/ctypes/init.py", line 384, in getitem
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit func = self._FuncPtr((name_or_ordinal, self))
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit AttributeError: Undefined symbol "ERR_load_crypto_strings"
2018-11-22 00:02:29.890 673 TRACE cloudbaseinit

@livenson
Copy link

Confirming the same issue also with 12 released two days ago.

@h5t4
Copy link

h5t4 commented Dec 31, 2018

#!/bin/csh
#bsd-cloudinit workaround

#usage
#echo /root/bsd-cloudinit >> /etc/rc.local
#chmod u+x /root/bsd-cloudinit

set PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
export $PATH

#disk_resize
gpart recover vtbd0
gpart resize -i 2 vtbd0
growfs -y vtbd0p2

#set passwordless sudo
echo 'freebsd ALL=(ALL) NOPASSWD: ALL' > /usr/local/etc/sudoers.d/10-cloudinit

#set_key
fetch http://169.254.169.254/openstack/latest/meta_data.json -q -o - | jq -r '.keys[] |.data' > /home/freebsd/.ssh/authorized_keys

#set_hostname
set fqdn=fetch http://169.254.169.254/openstack/latest/meta_data.json -q -o - | jq '.hostname' | sed 's/.novalocal//g'
sed -i "" "s/hostname.*/hostname=$fqdn/g" /etc/rc.conf
hostname echo $fqdn | tr -d '"'

#set root passwd
pw mod user root -w random > /dev/null

#run userdata
fetch http://169.254.169.254/latest/user-data -q -o - | sh

#make clean
set history = 0
ssh-keygen -A

#do Cheshire Cat
sed -i "" "s/.*bsd-cloudinit//g" /etc/rc.local
rm -f /root/bsd-cloudinit

@tdb
Copy link

tdb commented Jan 18, 2019

This is almost certainly due to FreeBSD 12 using OpenSSL 1.1.1. ERR_load_crypto_strings is deprecated:

https://www.openssl.org/docs/man1.1.1/man3/SSL_load_error_strings.html

I'm not clued up enough on OpenSSL to propose a fix though. But I do note the same issue exists in the original cloudbase-init, so maybe it'll get fixed there at some point:

https://github.com/openstack/cloudbase-init/blob/master/cloudbaseinit/utils/crypt.py

@tuanvu958
Copy link

tuanvu958 commented Jul 4, 2019

After install bsd-cloudinit:

  1. Install OpenSSL1.0.2 on /usr/ports/security/openssl port
  2. Edit this file: /root/bsd-cloudinit/cloudbaseinit/utils/crypt.py
    Replace openssl_lib_path = ctypes.util.find_library("ssl")
    by openssl_lib_path = "/usr/local/lib/libssl.so"
    Finish

@tdb
Copy link

tdb commented Jul 4, 2019

Maybe this fix for cloudbase-init will help?

cloudbase/cloudbase-init@a2434e4

@tuanvu958
Copy link

@tdb I tried it, but could not create the freebsd user and could not expand the hard disk capacity when start instance

@br-olf
Copy link

br-olf commented May 28, 2020

@h5t4
Thank you very much this one helped!

I added a few improvements:

#!/bin/csh
#bsd-cloudinit workaround

#usage
#echo /root/bsd-cloudinit >> /etc/rc.local
#chmod u+x /root/bsd-cloudinit

set PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
export $PATH

#disk_resize
gpart recover vtbd0
gpart resize -i 2 vtbd0
growfs -y vtbd0p2

#install needed packages
export ASSUME_ALWAYS_YES=yes
pkg install sudo jq 

#create freebsd user
pw useradd -n freebsd || true

#create home directory and .ssh
mkdir -p /home/freebsd/.ssh/
chown -R freebsd:freebsd /home/freebsd

#set passwordless sudo
echo 'freebsd ALL=(ALL) NOPASSWD: ALL' > /usr/local/etc/sudoers.d/10-cloudinit

#set_key
fetch http://169.254.169.254/openstack/latest/meta_data.json -q -o - | jq -r '.keys[] |.data' > /home/freebsd/.ssh/authorized_keys

#set_hostname
set fqdn=`fetch http://169.254.169.254/openstack/latest/meta_data.json -q -o - | jq '.hostname' | sed 's/.novalocal//g'`
sed -i "" "s/hostname.*/hostname=$fqdn/g" /etc/rc.conf
hostname `echo $fqdn | tr -d '"'`

#set root passwd
pw mod user root -w random > /dev/null

#run userdata
fetch http://169.254.169.254/latest/user-data -q -o - | sh

#make clean
set history = 0
ssh-keygen -A

#do Cheshire Cat
sed -i "" "s/.*bsd-cloudinit//g" /etc/rc.local
rm -f /root/bsd-cloudinit

@EhsanSaZ
Copy link

EhsanSaZ commented Nov 9, 2020

Hi, @br-olf
How should I use this script? where should I put it if I want to make a cloud template image for OpenStack?

@h5t4
Copy link

h5t4 commented Nov 9, 2020

root@hack:/ # head -n 3 /root/bsd-cloudinit
#!/bin/csh
#bsd-cloudinit workaround

@br-olf
Copy link

br-olf commented Nov 13, 2020

@EhsanSaZ
copy the script to the file /root/bsd-cloudinit and look at line 4-6 in the script ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants