So, I’ve started to map out the first steps towards a more enjoyable experience using centos7 series with juju. I’ll focus on MAAS here, since thats my use-case. I think this would be very similar to that of other cloud-images, but I have yet to discover that I guess.
Its a strong argument for juju to be able to actually be able to use other os:es better, which is a requirement for me at least. Not all problems are related to “juju”, but rather the differences in how different linux distributions work and operate.
I think that bash-only (non python dependent) might work straight out of the box, but I’m not sure.
Centos images in MAAS
I’ve added two packages from a stock centos net-install image:
- python3
- redhat-lsb-core
After that, by “bash-only” reference charm goes along just fine.
juju deploy cs:~erik-lonroth/tiny-bash-centos
Now, my attention is towards “reactive” charms.
The “python3” package pulls in “python3.6” on at least centos7.7. This might work on cento7.6 but I’m sure there will be problems on centos6, but I will not even try to go there. Python3.6 seems to be some kind of minimal requirement.
A change request would be to have Canonical to add in python3 in MAAS builds and rebuilding images would at least go away…
Once the python3.6 prepped image boots up properly in MAAS, my juju controller can deploy bash-hooks-only charms just fine. I test this with my reference charm: https://jujucharms.com/u/erik-lonroth/tiny-bash-centos
Now, I’m turning to reactive charms for centos7.
Getting reactive charms going with centos7
So, first layer-basic has code that is ubuntu only. Have a look here: https://raw.githubusercontent.com/juju-solutions/layer-basic/master/lib/charms/layer/basic.py
What this code basically does, is to bring in needed python packages, which should be easy to replicate on centos7 at least.
Determining the “series” needs to happen here, something like the code I’ve cooked up as an example below:
def lsb_release_centos_ubuntu():
"""series for ubuntu and centos like os:es"""
series = ""
if os.path.isfile('/etc/lsb-release'): # Ubuntu
d = {}
with open('/etc/lsb-release', 'r') as lsb:
for l in lsb:
k, v = l.split('=')
d[k.strip()] = v.strip()
series = d['DISTRIB_CODENAME']
elif os.path.isfile('/etc/redhat-release'): # Centos/rhel
with open('/etc/redhat-release', 'r') as redhatlsb:
# CentOS Linux release 7.7.1908 (Core)
# return the major release number from the string.
for l in redhatlsb:
words = l.split()
release = int(words[3][0])
series = "centos{}".format(release)
else:
series = "unknown"
return series
There is basically from this a matter of installing the correct packages in the same file (layer/basic.py), using “yum” instead of “apt” and selecting the proper package-names mapped to centos7 instead of ubuntu. This is easy, but require some testing of course. I’ll get going with that this week.
I know “charm helpers” will need some patching I know @hallback has already looked at, so I will come back to this thread along the way.
By the end of all this, I hope the centos7 experience with juju can be more pleasant than it is today.