github twitter linkedin rss
Juju OpenSUSE support (1/2)
Jun 17, 2017
3 minutes read

The last hackathon in my company was dedicated to the cloud and I presented a proposal for testing Juju as the manager of our VNF.

First problem I faced was the lack of support of OpenSUSE (or SLES) in Juju, which is the operating system used by our VNF. After some (well, a lot) of problems, I created two pull request for juju/utils and juju/juju repos and now Juju supports OpenSUSE since Juju 2.2.

For the moment, I tested the manual provisioning and LXD support. It is really simple to test that using LXD containers, as you can see below.

Preparing OpenSUSE image for manual provisioning

First step is to prepare the image. For that, I use the linux containers image:

lxc image copy images:opensuse/42.2 local: --alias juju/opensuseleap/amd64
lxc launch local:juju/opensuseleap/amd64 opensuseleap

The image needs some updates, so we can create a container for updating it:

lxc launch local:juju/opensuseleap/amd64 opensuseleap
lxc exec opensuseleap bash
opensuseleap:~ # 

We need to enable SSH server (is disabled by default) and install sudo and nano packages:

opensuseleap:~ # zypper clean --all
opensuseleap:~ # systemctl unmask sshd.service
opensuseleap:~ # systemctl enable sshd.service
opensuseleap:~ # systemctl start sshd.service
opensuseleap:~ # zypper install sudo
opensuseleap:~ # zypper install nano

We also have to define a password for root and create the .ssh directory.

opensuseleap:~ # mkdir .ssh
opensuseleap:~ # chmod 700 .ssh
opensuseleap:~ # passwd

Finally, it is useful to deactivate the password for root sudo

opensuseleap:~ # nano /etc/sudoers
##
root ALL=(ALL) NOPASSWD:ALL

From our host, we can share host key:

ssh-keygen -t rsa 
scp .ssh/id_rsa.pub root@10.8.226.70:.ssh/authorized_keys

where 10.8.226.70 is the IP address of OpenSUSE container.

And that’s all. Now, we can publish the modified image in our host:

lxc publish opensuseleap --alias opensuseleap-manual --force

Preparing local tools stream

For the moment, OpenSUSE agent is not in the official repository of agents so we have to create a local strem.

First, we need the OpenSUSE agent. The simplest way to generate it is to copy an existing one

mkdir -p simplestreams/tools/released
cd simplestreams/tools/released
wget https://streams.canonical.com/juju/tools/agent/2.2.0/juju-2.2.0-ubuntu-amd64.tgz
cp juju-2.2.0-ubuntu-amd64.tgz juju-2.2.0-opensuseleap-amd64.tgz 

and to generate the stream

cd $HOME
juju metadata generate-tools -d simplestreams/ --show-log --clean --stream released

Tools should be available from juju containers and for that, we can use a web server in the host (ngnix for example). We copy the stream:

sudo rm -rf /var/www/html/tools
sudo cp -r $HOME/simplestreams/tools /var/www/html
sudo chmod -R 755 /var/www/html/tools

and we will configure juju for using this stream.

Testing the manual provisioning

For testing, we are going to create a new controller in a host with lxd and juju 2.2:

juju bootstrap localhost lxd-opensuseleap

We have to set the URL of tools to point our stream:

juju model-config agent-metadata-url=http://10.8.226.1/tools

where 10.8.226.1 is the IP address of lxdbr0 bridge.

Now, we ready for adding the OpenSUSE machine:

juju add-machine ssh:root@10.8.226.70

We can deploy a charm with opensuseleap series. I have an example in github:

git clone https://github.com/marcmolla/juju-OpenSUSE
cd juju-OpenSUSE/charms
juju deploy ./test-opensuseleap --to 0

The testing charm includes a web server that you can test:

curl 10.8.226.70
<html><head title="Testing OpenSUSE Charm"></head><body><h1>It works\! From 10.8.226.70</h1></body></html>

And the juju status shows:

juju status
Model    Controller    Cloud/Region         Version  SLA
default  lxd-opensuse  localhost/localhost  2.2.0    unsupported

App                Version  Status  Scale  Charm              Store  Rev  OS        Notes
test-opensuseleap           active      1  test-opensuseleap  local    2  opensuse  

Unit                  Workload  Agent  Machine  Public address  Ports  Message
test-opensuseleap/0*  active    idle   0        10.8.226.70            

Machine  State    DNS          Inst id             Series        AZ  Message
0        started  10.8.226.70  manual:10.8.226.70  opensuseleap      Manually provisioned machine

And you ca see, OpenSUSE charm works well.

In a next entry, I will explain how to use LXD as cloud provider.


Back to posts


comments powered by Disqus